Bug 177805: Fix the use of units in Gecko. r+sr=roc

This commit is contained in:
sharparrow1%yahoo.com 2007-02-07 07:46:44 +00:00
Родитель 629e79c742
Коммит c78720aa24
164 изменённых файлов: 1364 добавлений и 2226 удалений

Просмотреть файл

@ -877,11 +877,9 @@ PRBool nsAccessible::IsVisible(PRBool *aIsOffscreen)
relFrameRect.y = frameOffset.y;
}
float p2t;
p2t = presContext->PixelsToTwips();
nsRectVisibility rectVisibility;
viewManager->GetRectVisibility(containingView, relFrameRect,
NS_STATIC_CAST(PRUint16, (kMinPixels * p2t)),
viewManager->GetRectVisibility(containingView, relFrameRect,
nsPresContext::CSSPixelsToAppUnits(kMinPixels),
&rectVisibility);
if (rectVisibility == nsRectVisibility_kZeroAreaRect) {
@ -1173,9 +1171,6 @@ NS_IMETHODIMP nsAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PR
return NS_ERROR_FAILURE;
}
float t2p;
t2p = presContext->TwipsToPixels(); // Get pixels to twips conversion factor
nsRect unionRectTwips;
nsIFrame* aBoundingFrame = nsnull;
GetBoundsRect(unionRectTwips, &aBoundingFrame); // Unions up all primary frames for this node and all siblings after it
@ -1184,10 +1179,10 @@ NS_IMETHODIMP nsAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PR
return NS_ERROR_FAILURE;
}
*x = NSTwipsToIntPixels(unionRectTwips.x, t2p);
*y = NSTwipsToIntPixels(unionRectTwips.y, t2p);
*width = NSTwipsToIntPixels(unionRectTwips.width, t2p);
*height = NSTwipsToIntPixels(unionRectTwips.height, t2p);
*x = presContext->AppUnitsToDevPixels(unionRectTwips.x);
*y = presContext->AppUnitsToDevPixels(unionRectTwips.y);
*width = presContext->AppUnitsToDevPixels(unionRectTwips.width);
*height = presContext->AppUnitsToDevPixels(unionRectTwips.height);
// We have the union of the rectangle, now we need to put it in absolute screen coords

Просмотреть файл

@ -163,14 +163,10 @@ NS_IMETHODIMP nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument *aDoc, ns
if (!widget)
return NS_OK;
float t2p = presContext->TwipsToPixels();
// Convert to pixels using that scale
caretRect.x = NSTwipsToIntPixels(caretRect.x, t2p);
caretRect.y = NSTwipsToIntPixels(caretRect.y, t2p);
caretRect.width = NSTwipsToIntPixels(caretRect.width, t2p);
caretRect.height = NSTwipsToIntPixels(caretRect.height, t2p);
caretRect.x = presContext->AppUnitsToDevPixels(caretRect.x);
caretRect.y = presContext->AppUnitsToDevPixels(caretRect.y);
caretRect.width = presContext->AppUnitsToDevPixels(caretRect.width);
caretRect.height = presContext->AppUnitsToDevPixels(caretRect.height);
widget->WidgetToScreen(caretRect, mCaretRect);

Просмотреть файл

@ -144,16 +144,13 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *w
rv = map->GetBoundsForAreaContent(ourContent, presContext, rect);
NS_ENSURE_SUCCESS(rv, rv);
// Convert from twips to pixels
float t2p;
t2p = presContext->TwipsToPixels(); // Get pixels conversion factor
*x = NSTwipsToIntPixels(rect.x, t2p);
*y = NSTwipsToIntPixels(rect.y, t2p);
*x = presContext->AppUnitsToDevPixels(rect.x);
*y = presContext->AppUnitsToDevPixels(rect.y);
// XXX Areas are screwy; they return their rects as a pair of points, one pair
// stored into the width and height.
*width = NSTwipsToIntPixels(rect.width, t2p) - *x;
*height = NSTwipsToIntPixels(rect.height, t2p) - *y;
*width = presContext->AppUnitsToDevPixels(rect.width - rect.x);
*height = presContext->AppUnitsToDevPixels(rect.height - rect.y);
// Put coords in absolute screen coords
orgRectPixels = frame->GetScreenRectExternal();

Просмотреть файл

@ -257,7 +257,6 @@ nsIntRect nsHyperTextAccessible::GetBoundsForString(nsIFrame *aFrame, PRInt32 aS
NS_ENSURE_SUCCESS(rv, screenRect);
nsPresContext *context = shell->GetPresContext();
float t2p = context->TwipsToPixels();
while (frame && aLength > 0) {
// Start with this frame's screen rect, which we will
@ -276,13 +275,13 @@ nsIntRect nsHyperTextAccessible::GetBoundsForString(nsIFrame *aFrame, PRInt32 aS
nsPoint frameTextStartPoint;
rv = frame->GetPointFromOffset(context, rc, aStartOffset, &frameTextStartPoint);
NS_ENSURE_SUCCESS(rv, nsRect());
frameScreenRect.x += NSTwipsToIntPixels(frameTextStartPoint.x, t2p);
frameScreenRect.x += context->AppUnitsToDevPixels(frameTextStartPoint.x);
// Use the point for the end offset to calculate the width
nsPoint frameTextEndPoint;
rv = frame->GetPointFromOffset(context, rc, aStartOffset + frameSubStringLength, &frameTextEndPoint);
NS_ENSURE_SUCCESS(rv, nsRect());
frameScreenRect.width = NSTwipsToIntPixels(frameTextEndPoint.x - frameTextStartPoint.x, t2p);
frameScreenRect.width = context->AppUnitsToDevPixels(frameTextEndPoint.x - frameTextStartPoint.x);
screenRect.UnionRect(frameScreenRect, screenRect);
@ -925,10 +924,8 @@ NS_IMETHODIMP nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, ns
nsPoint pointInHyperText(aX - frameScreenRect.x, aY - frameScreenRect.y);
nsPresContext *context = GetPresContext();
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
// Convert to twips
float p2t = context->PixelsToTwips();
pointInHyperText.x = NSIntPixelsToTwips(pointInHyperText.x, p2t);
pointInHyperText.y = NSIntPixelsToTwips(pointInHyperText.y, p2t);
pointInHyperText.x = context->DevPixelsToAppUnits(pointInHyperText.x);
pointInHyperText.y = context->DevPixelsToAppUnits(pointInHyperText.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

Просмотреть файл

@ -221,7 +221,6 @@ nsresult nsTextAccessibleWrap::GetCharacterExtents(PRInt32 aStartOffset, PRInt32
{
nsPresContext *presContext = GetPresContext();
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
float t2p = presContext->TwipsToPixels();
nsIFrame *frame = GetFrame();
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
@ -245,8 +244,8 @@ nsresult nsTextAccessibleWrap::GetCharacterExtents(PRInt32 aStartOffset, PRInt32
nsIFrame *stopLoopFrame = endFrame->GetNextContinuation();
for (; iter != stopLoopFrame; iter = iter->GetNextContinuation()) {
nsRect rect = iter->GetScreenRectExternal();
nscoord start = (iter == startFrame) ? NSTwipsToIntPixels(startPoint.x, t2p) : 0;
nscoord end = (iter == endFrame) ? NSTwipsToIntPixels(endPoint.x, t2p) :
nscoord start = (iter == startFrame) ? presContext->AppUnitsToDevPixels(startPoint.x) : 0;
nscoord end = (iter == endFrame) ? presContext->AppUnitsToDevPixels(endPoint.x) :
rect.width;
rect.x += start;
rect.width = end - start;

Просмотреть файл

@ -102,8 +102,8 @@ NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetBounds(PRInt32 *x, PRInt32 *y, PRI
PRInt32 cellStartX, cellStartY;
mTree->GetCoordsForCellItem(mRow, mColumn, EmptyCString(), &cellStartX, &cellStartY, width, height);
// Use entire row width, not just key column's width
float t2p = GetPresContext()->TwipsToPixels();
*width = NSTwipsToIntPixels(frame->GetRect().width, t2p) - cellStartX;
*width = GetPresContext()->AppUnitsToDevPixels(frame->GetRect().width) -
cellStartX;
}
return NS_OK;
}

Просмотреть файл

@ -2619,10 +2619,6 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, PRInt32 aX, PRInt3
nsresult rv = mCSSParser->ParseColorString(PromiseFlatString(aBGColor),
nsnull, 0, PR_TRUE, &bgColor);
NS_ENSURE_SUCCESS(rv, rv);
float p2t = presContext->PixelsToTwips();
nsRect r(aX, aY, aW, aH);
r.ScaleRoundOut(p2t);
#ifndef MOZILLA_1_8_BRANCH
nsIPresShell* presShell = presContext->PresShell();
@ -2652,8 +2648,10 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, PRInt32 aX, PRInt3
nsIFrame* rootFrame = presShell->FrameManager()->GetRootFrame();
if (rootFrame) {
// XXX This shadows the other |r|, above.
nsRect r(aX, aY, aW, aH);
r.ScaleRoundOut(presContext->PixelsToTwips());
nsRect r(nsPresContext::CSSPixelsToAppUnits(aX),
nsPresContext::CSSPixelsToAppUnits(aY),
nsPresContext::CSSPixelsToAppUnits(aW),
nsPresContext::CSSPixelsToAppUnits(aH));
nsDisplayListBuilder builder(rootFrame, PR_FALSE, PR_FALSE);
nsDisplayList list;
@ -2669,7 +2667,7 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, PRInt32 aX, PRInt3
rv = rootFrame->BuildDisplayListForStackingContext(&builder, r, &list);
if (NS_SUCCEEDED(rv)) {
float t2p = presContext->TwipsToPixels();
float t2p = presContext->AppUnitsPerDevPixel();
// Ensure that r.x,r.y gets drawn at (0,0)
mThebesContext->Save();
mThebesContext->Translate(gfxPoint(-r.x*t2p, -r.y*t2p));

Просмотреть файл

@ -129,7 +129,8 @@ nsPoint nsDOMUIEvent::GetScreenPoint() {
nsRect bounds(mEvent->refPoint, nsSize(1, 1));
nsRect offset;
((nsGUIEvent*)mEvent)->widget->WidgetToScreen ( bounds, offset );
return offset.TopLeft();
return nsPoint(nsPresContext::AppUnitsToIntCSSPixels(mPresContext->DevPixelsToAppUnits(offset.x)),
nsPresContext::AppUnitsToIntCSSPixels(mPresContext->DevPixelsToAppUnits(offset.y)));
}
nsPoint nsDOMUIEvent::GetClientPoint() {
@ -223,7 +224,8 @@ nsPoint nsDOMUIEvent::GetClientPoint() {
}
}
return pt;
return nsPoint(nsPresContext::AppUnitsToIntCSSPixels(mPresContext->DevPixelsToAppUnits(pt.x)),
nsPresContext::AppUnitsToIntCSSPixels(mPresContext->DevPixelsToAppUnits(pt.y)));
}
NS_IMETHODIMP
@ -262,13 +264,12 @@ nsDOMUIEvent::GetPageX(PRInt32* aPageX)
nsresult ret = NS_OK;
PRInt32 scrollX = 0;
nsIScrollableView* view = nsnull;
float p2t, t2p;
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if(view) {
nscoord xPos, yPos;
ret = view->GetScrollPosition(xPos, yPos);
scrollX = NSTwipsToIntPixels(xPos, t2p);
scrollX = nsPresContext::AppUnitsToIntCSSPixels(xPos);
}
if (NS_SUCCEEDED(ret)) {
@ -285,13 +286,12 @@ nsDOMUIEvent::GetPageY(PRInt32* aPageY)
nsresult ret = NS_OK;
PRInt32 scrollY = 0;
nsIScrollableView* view = nsnull;
float p2t, t2p;
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if(view) {
nscoord xPos, yPos;
ret = view->GetScrollPosition(xPos, yPos);
scrollY = NSTwipsToIntPixels(yPos, t2p);
scrollY = nsPresContext::AppUnitsToIntCSSPixels(yPos);
}
if (NS_SUCCEEDED(ret)) {
@ -382,7 +382,6 @@ nsPoint nsDOMUIEvent::GetLayerPoint() {
// XXX This is supposed to be relative to the nearest view?
// Any element can have a view, not just positioned ones.
float t2p = mPresContext->TwipsToPixels();
nsIFrame* targetFrame;
nsPoint pt;
mPresContext->EventStateManager()->GetEventTarget(&targetFrame);
@ -391,8 +390,8 @@ nsPoint nsDOMUIEvent::GetLayerPoint() {
}
if (targetFrame) {
pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, targetFrame);
pt.x = NSTwipsToIntPixels(pt.x, t2p);
pt.y = NSTwipsToIntPixels(pt.y, t2p);
pt.x = nsPresContext::AppUnitsToIntCSSPixels(pt.x);
pt.y = nsPresContext::AppUnitsToIntCSSPixels(pt.y);
return pt;
} else {
return nsPoint(0,0);
@ -442,27 +441,18 @@ nsDOMUIEvent::GetPreventDefault(PRBool* aReturn)
}
nsresult
nsDOMUIEvent::GetScrollInfo(nsIScrollableView** aScrollableView,
float* aP2T, float* aT2P)
nsDOMUIEvent::GetScrollInfo(nsIScrollableView** aScrollableView)
{
NS_ENSURE_ARG_POINTER(aScrollableView);
NS_ENSURE_ARG_POINTER(aP2T);
NS_ENSURE_ARG_POINTER(aT2P);
if (!mPresContext) {
*aScrollableView = nsnull;
return NS_ERROR_FAILURE;
}
*aP2T = mPresContext->PixelsToTwips();
*aT2P = mPresContext->TwipsToPixels();
nsIViewManager *vm = mPresContext->GetViewManager();
if (vm)
return vm->GetRootScrollableView(aScrollableView);
nsIPresShell *presShell = mPresContext->GetPresShell();
if (presShell) {
nsIViewManager* vm = presShell->GetViewManager();
if(vm) {
return vm->GetRootScrollableView(aScrollableView);
}
}
return NS_OK;
}

Просмотреть файл

@ -72,8 +72,7 @@ public:
protected:
// Internal helper functions
nsresult GetScrollInfo(nsIScrollableView** aScrollableView, float* aP2T,
float* aT2P);
nsresult GetScrollInfo(nsIScrollableView** aScrollableView);
nsPoint GetClientPoint();
nsPoint GetScreenPoint();
nsPoint GetLayerPoint();

Просмотреть файл

@ -1675,13 +1675,14 @@ nsEventListenerManager::FixContextMenuEvent(nsPresContext* aPresContext,
// nsEventListenerManager::PrepareToUseCaretPosition
//
// This checks to see if we should use the caret position for popup context
// menus. Returns true if the caret position should be used, and the window
// coordinates of that position are placed into WindowX/Y. This function
// menus. Returns true if the caret position should be used, and the
// coordinates of that position is returned in aTargetPt. This function
// will also scroll the window as needed to make the caret visible.
//
// The event widget should be the widget that generated the event, and
// whose coordinate system the resulting event's refPoint should be
// relative to.
// relative to. The returned point is in device pixels realtive to the
// widget passed in.
PRBool
nsEventListenerManager::PrepareToUseCaretPosition(nsIWidget* aEventWidget,
@ -1779,14 +1780,14 @@ nsEventListenerManager::PrepareToUseCaretPosition(nsIWidget* aEventWidget,
nsPoint viewDelta = view->GetOffsetTo(widgetView) + viewToWidget;
// caret coordinates are in twips, convert to pixels
float t2p = aShell->GetPresContext()->TwipsToPixels();
aTargetPt.x = NSTwipsToIntPixels(viewDelta.x + caretCoords.x + caretCoords.width, t2p);
aTargetPt.y = NSTwipsToIntPixels(viewDelta.y + caretCoords.y + caretCoords.height, t2p);
nsPresContext* presContext = aShell->GetPresContext();
aTargetPt.x = presContext->AppUnitsToDevPixels(viewDelta.x + caretCoords.x + caretCoords.width);
aTargetPt.y = presContext->AppUnitsToDevPixels(viewDelta.y + caretCoords.y + caretCoords.height);
return PR_TRUE;
}
// Get coordinates relative to root view for element,
// Get coordinates in device pixels relative to root view for element,
// first ensuring the element is onscreen
void
nsEventListenerManager::GetCoordinatesFor(nsIDOMElement *aCurrentEl,
@ -1883,10 +1884,8 @@ nsEventListenerManager::GetCoordinatesFor(nsIDOMElement *aCurrentEl,
}
#endif
// Convert from twips to pixels
float t2p = aPresContext->TwipsToPixels();
aTargetPt.x = NSTwipsToIntPixels(frameOrigin.x + extra, t2p);
aTargetPt.y = NSTwipsToIntPixels(frameOrigin.y + extra, t2p) + extraPixelsY;
aTargetPt.x = aPresContext->AppUnitsToDevPixels(frameOrigin.x + extra);
aTargetPt.y = aPresContext->AppUnitsToDevPixels(frameOrigin.y + extra) + extraPixelsY;
}
}

Просмотреть файл

@ -717,16 +717,12 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
// XXX We should really consider subtracting out padding for
// content-box sizing, but we should see what IE does....
// Get the scale from that Presentation Context
float scale;
scale = context->TwipsToPixels();
// Convert to pixels using that scale
aRect.x = NSTwipsToIntPixels(origin.x, scale);
aRect.y = NSTwipsToIntPixels(origin.y, scale);
aRect.width = NSTwipsToIntPixels(rcFrame.width, scale);
aRect.height = NSTwipsToIntPixels(rcFrame.height, scale);
aRect.x = nsPresContext::AppUnitsToIntCSSPixels(origin.x);
aRect.y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);
aRect.width = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.width);
aRect.height = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.height);
}
nsresult
@ -886,12 +882,9 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML)
void
nsGenericHTMLElement::GetScrollInfo(nsIScrollableView **aScrollableView,
float *aP2T, float *aT2P,
nsIFrame **aFrame)
{
*aScrollableView = nsnull;
*aP2T = 0.0f;
*aT2P = 0.0f;
nsIDocument *document = GetCurrentDoc();
if (!document) {
@ -909,12 +902,6 @@ nsGenericHTMLElement::GetScrollInfo(nsIScrollableView **aScrollableView,
return;
}
// Get the presentation context
nsPresContext *presContext = presShell->GetPresContext();
if (!presContext) {
return;
}
// Get the primary frame for this element
nsIFrame *frame = presShell->GetPrimaryFrameFor(this);
if (!frame) {
@ -925,9 +912,6 @@ nsGenericHTMLElement::GetScrollInfo(nsIScrollableView **aScrollableView,
*aFrame = frame;
}
*aP2T = presContext->PixelsToTwips();
*aT2P = presContext->TwipsToPixels();
// Get the scrollable frame
nsIScrollableFrame *scrollFrame = nsnull;
CallQueryInterface(frame, &scrollFrame);
@ -983,15 +967,14 @@ nsGenericHTMLElement::GetScrollTop(PRInt32* aScrollTop)
nsIScrollableView *view = nsnull;
nsresult rv = NS_OK;
float p2t, t2p;
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if (view) {
nscoord xPos, yPos;
rv = view->GetScrollPosition(xPos, yPos);
*aScrollTop = NSTwipsToIntPixels(yPos, t2p);
*aScrollTop = nsPresContext::AppUnitsToIntCSSPixels(yPos);
}
return rv;
@ -1002,9 +985,8 @@ nsGenericHTMLElement::SetScrollTop(PRInt32 aScrollTop)
{
nsIScrollableView *view = nsnull;
nsresult rv = NS_OK;
float p2t, t2p;
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if (view) {
nscoord xPos, yPos;
@ -1012,7 +994,7 @@ nsGenericHTMLElement::SetScrollTop(PRInt32 aScrollTop)
rv = view->GetScrollPosition(xPos, yPos);
if (NS_SUCCEEDED(rv)) {
rv = view->ScrollTo(xPos, NSIntPixelsToTwips(aScrollTop, p2t),
rv = view->ScrollTo(xPos, nsPresContext::CSSPixelsToAppUnits(aScrollTop),
NS_VMREFRESH_IMMEDIATE);
}
}
@ -1028,15 +1010,14 @@ nsGenericHTMLElement::GetScrollLeft(PRInt32* aScrollLeft)
nsIScrollableView *view = nsnull;
nsresult rv = NS_OK;
float p2t, t2p;
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if (view) {
nscoord xPos, yPos;
rv = view->GetScrollPosition(xPos, yPos);
*aScrollLeft = NSTwipsToIntPixels(xPos, t2p);
*aScrollLeft = nsPresContext::AppUnitsToIntCSSPixels(xPos);
}
return rv;
@ -1047,16 +1028,15 @@ nsGenericHTMLElement::SetScrollLeft(PRInt32 aScrollLeft)
{
nsIScrollableView *view = nsnull;
nsresult rv = NS_OK;
float p2t, t2p;
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if (view) {
nscoord xPos, yPos;
rv = view->GetScrollPosition(xPos, yPos);
if (NS_SUCCEEDED(rv)) {
rv = view->ScrollTo(NSIntPixelsToTwips(aScrollLeft, p2t),
rv = view->ScrollTo(nsPresContext::CSSPixelsToAppUnits(aScrollLeft),
yPos, NS_VMREFRESH_IMMEDIATE);
}
}
@ -1072,9 +1052,8 @@ nsGenericHTMLElement::GetScrollHeight(PRInt32* aScrollHeight)
nsIScrollableView *scrollView = nsnull;
nsresult rv = NS_OK;
float p2t, t2p;
GetScrollInfo(&scrollView, &p2t, &t2p);
GetScrollInfo(&scrollView);
if (!scrollView) {
return GetOffsetHeight(aScrollHeight);
@ -1084,7 +1063,7 @@ nsGenericHTMLElement::GetScrollHeight(PRInt32* aScrollHeight)
nscoord xMax, yMax;
rv = scrollView->GetContainerSize(&xMax, &yMax);
*aScrollHeight = NSTwipsToIntPixels(yMax, t2p);
*aScrollHeight = nsPresContext::AppUnitsToIntCSSPixels(yMax);
return rv;
}
@ -1097,9 +1076,8 @@ nsGenericHTMLElement::GetScrollWidth(PRInt32* aScrollWidth)
nsIScrollableView *scrollView = nsnull;
nsresult rv = NS_OK;
float p2t, t2p;
GetScrollInfo(&scrollView, &p2t, &t2p);
GetScrollInfo(&scrollView);
if (!scrollView) {
return GetOffsetWidth(aScrollWidth);
@ -1108,7 +1086,7 @@ nsGenericHTMLElement::GetScrollWidth(PRInt32* aScrollWidth)
nscoord xMax, yMax;
rv = scrollView->GetContainerSize(&xMax, &yMax);
*aScrollWidth = NSTwipsToIntPixels(xMax, t2p);
*aScrollWidth = nsPresContext::AppUnitsToIntCSSPixels(xMax);
return rv;
}
@ -1127,22 +1105,21 @@ nsGenericHTMLElement::GetClientHeight(PRInt32* aClientHeight)
*aClientHeight = 0;
nsIScrollableView *scrollView = nsnull;
float p2t, t2p;
nsIFrame *frame = nsnull;
GetScrollInfo(&scrollView, &p2t, &t2p, &frame);
GetScrollInfo(&scrollView, &frame);
if (scrollView) {
nsRect r = scrollView->View()->GetBounds();
*aClientHeight = NSTwipsToIntPixels(r.height, t2p);
*aClientHeight = nsPresContext::AppUnitsToIntCSSPixels(r.height);
} else if (frame &&
(frame->GetStyleDisplay()->mDisplay != NS_STYLE_DISPLAY_INLINE ||
(frame->IsFrameOfType(nsIFrame::eReplaced)))) {
// Special case code to make clientHeight work even when there isn't
// a scroll view, see bug 180552 and bug 227567.
*aClientHeight = NSTwipsToIntPixels(GetClientAreaSize(frame).height, t2p);
*aClientHeight = nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaSize(frame).height);
}
return NS_OK;
@ -1155,22 +1132,21 @@ nsGenericHTMLElement::GetClientWidth(PRInt32* aClientWidth)
*aClientWidth = 0;
nsIScrollableView *scrollView = nsnull;
float p2t, t2p;
nsIFrame *frame = nsnull;
GetScrollInfo(&scrollView, &p2t, &t2p, &frame);
GetScrollInfo(&scrollView, &frame);
if (scrollView) {
nsRect r = scrollView->View()->GetBounds();
*aClientWidth = NSTwipsToIntPixels(r.width, t2p);
*aClientWidth = nsPresContext::AppUnitsToIntCSSPixels(r.width);
} else if (frame &&
(frame->GetStyleDisplay()->mDisplay != NS_STYLE_DISPLAY_INLINE ||
(frame->IsFrameOfType(nsIFrame::eReplaced)))) {
// Special case code to make clientWidth work even when there isn't
// a scroll view, see bug 180552 and bug 227567.
*aClientWidth = NSTwipsToIntPixels(GetClientAreaSize(frame).width, t2p);
*aClientWidth = nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaSize(frame).width);
}
return NS_OK;

Просмотреть файл

@ -172,8 +172,8 @@ public:
* [OUT]
*/
void GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent);
void GetScrollInfo(nsIScrollableView **aScrollableView, float *aP2T,
float *aT2P, nsIFrame **aFrame = nsnull);
void GetScrollInfo(nsIScrollableView **aScrollableView,
nsIFrame **aFrame = nsnull);
/**
* Get an element's client info if the element doesn't have a

Просмотреть файл

@ -52,12 +52,10 @@
#include "nsIScriptContext.h"
#include "nsIURL.h"
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNetUtil.h"
#include "nsContentUtils.h"
#include "nsIFrame.h"
#include "nsIImageFrame.h"
#include "nsNodeInfoManager.h"
#include "nsGUIEvent.h"
#include "nsContentPolicyUtils.h"
@ -148,7 +146,6 @@ public:
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
protected:
void GetImageFrame(nsIImageFrame** aImageFrame);
nsPoint GetXY();
nsSize GetWidthHeight();
};
@ -218,21 +215,6 @@ NS_IMPL_URI_ATTR(nsHTMLImageElement, Src, src)
NS_IMPL_STRING_ATTR(nsHTMLImageElement, UseMap, usemap)
NS_IMPL_INT_ATTR(nsHTMLImageElement, Vspace, vspace)
void
nsHTMLImageElement::GetImageFrame(nsIImageFrame** aImageFrame)
{
*aImageFrame = nsnull;
// If we have no parent, then we won't have a frame yet
if (!GetParent())
return;
nsIFrame* frame = GetPrimaryFrame(Flush_Frames);
if (frame) {
CallQueryInterface(frame, aImageFrame);
}
}
NS_IMETHODIMP
nsHTMLImageElement::GetComplete(PRBool* aComplete)
{
@ -257,34 +239,13 @@ nsHTMLImageElement::GetXY()
{
nsPoint point(0, 0);
nsIDocument *document = GetCurrentDoc();
if (!document) {
return point;
}
// Get Presentation shell 0
nsIPresShell *presShell = document->GetShellAt(0);
if (!presShell) {
return point;
}
// Get the Presentation Context from the Shell
nsPresContext *context = presShell->GetPresContext();
if (!context) {
return point;
}
// Flush all pending notifications so that our frames are laid out correctly
document->FlushPendingNotifications(Flush_Layout);
// Get the Frame for this image
nsIFrame* frame = presShell->GetPrimaryFrameFor(this);
nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
if (!frame) {
return point;
}
// XXX This should search for the nearest abs. pos. container
nsPoint origin(0, 0);
nsIView* parentView;
nsresult rv = frame->GetOffsetFromView(origin, &parentView);
@ -292,13 +253,9 @@ nsHTMLImageElement::GetXY()
return point;
}
// Get the scale from that Presentation Context
float scale;
scale = context->TwipsToPixels();
// Convert to pixels using that scale
point.x = NSTwipsToIntPixels(origin.x, scale);
point.y = NSTwipsToIntPixels(origin.y, scale);
point.x = nsPresContext::AppUnitsToIntCSSPixels(origin.x);
point.y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);
return point;
}
@ -324,37 +281,13 @@ nsHTMLImageElement::GetWidthHeight()
{
nsSize size(0,0);
nsIDocument* doc = GetCurrentDoc();
if (doc) {
// Flush all pending notifications so that our frames are up to date.
// If we're not in a document, we don't have a frame anyway, so we
// don't care.
doc->FlushPendingNotifications(Flush_Layout);
}
nsIImageFrame* imageFrame;
GetImageFrame(&imageFrame);
nsIFrame* frame = nsnull;
if (imageFrame) {
CallQueryInterface(imageFrame, &frame);
NS_ASSERTION(frame,"Should not happen - image frame is not frame");
}
nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
if (frame) {
// XXX we could put an accessor on nsIImageFrame to return its
// mComputedSize.....
size = frame->GetContentRect().Size();
nsPresContext *context = GetPresContext();
if (context) {
float t2p;
t2p = context->TwipsToPixels();
size.width = NSTwipsToIntPixels(size.width, t2p);
size.height = NSTwipsToIntPixels(size.height, t2p);
}
size.width = nsPresContext::AppUnitsToIntCSSPixels(size.width);
size.height = nsPresContext::AppUnitsToIntCSSPixels(size.height);
} else {
const nsAttrValue* value;
nsCOMPtr<imgIContainer> image;

Просмотреть файл

@ -2666,15 +2666,8 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell,
size = frame->GetSize();
}
// Convert from twips to pixels
nsPresContext *context = aShell->GetPresContext();
if (context) {
float scale;
scale = context->TwipsToPixels();
*aWidth = NSTwipsToIntPixels(size.width, scale);
*aHeight = NSTwipsToIntPixels(size.height, scale);
}
*aWidth = nsPresContext::AppUnitsToIntCSSPixels(size.width);
*aHeight = nsPresContext::AppUnitsToIntCSSPixels(size.height);
}
return NS_OK;

Просмотреть файл

@ -449,8 +449,8 @@ nsImageDocument::RestoreImageTo(PRInt32 aX, PRInt32 aY)
return NS_OK;
nsRect portRect = view->View()->GetBounds();
view->ScrollTo(NSToCoordRound((aX/ratio)*context->PixelsToTwips() - portRect.width/2),
NSToCoordRound((aY/ratio)*context->PixelsToTwips() - portRect.height/2),
view->ScrollTo(nsPresContext::CSSPixelsToAppUnits(aX/ratio) - portRect.width/2,
nsPresContext::CSSPixelsToAppUnits(aY/ratio) - portRect.height/2,
NS_VMREFRESH_IMMEDIATE);
return NS_OK;
}
@ -624,10 +624,8 @@ nsImageDocument::CheckOverflowing(PRBool changeState)
if (styleContext->GetStylePadding()->GetPadding(m))
visibleArea.Deflate(m);
float t2p;
t2p = context->TwipsToPixels();
mVisibleWidth = NSTwipsToIntPixels(visibleArea.width, t2p);
mVisibleHeight = NSTwipsToIntPixels(visibleArea.height, t2p);
mVisibleWidth = nsPresContext::AppUnitsToIntCSSPixels(visibleArea.width);
mVisibleHeight = nsPresContext::AppUnitsToIntCSSPixels(visibleArea.height);
PRBool imageWasOverflowing = mImageIsOverflowing;
mImageIsOverflowing =

Просмотреть файл

@ -282,7 +282,7 @@ nsSVGSVGElement::GetPixelUnitToMillimeterX(float *aPixelUnitToMillimeterX)
nsPresContext *context = presShell->GetPresContext();
if (!context) return NS_OK;
*aPixelUnitToMillimeterX = context->ScaledPixelsToTwips() / TWIPS_PER_POINT_FLOAT / (72.0f * 0.03937f);
*aPixelUnitToMillimeterX = 25.4f / nsPresContext::AppUnitsToIntCSSPixels(context->AppUnitsPerInch());
return NS_OK;
}
@ -312,9 +312,7 @@ nsSVGSVGElement::GetScreenPixelToMillimeterX(float *aScreenPixelToMillimeterX)
nsPresContext *context = presShell->GetPresContext();
if (!context) return NS_OK;
float TwipsPerPx;
TwipsPerPx = context->PixelsToTwips();
*aScreenPixelToMillimeterX = TwipsPerPx / TWIPS_PER_POINT_FLOAT / (72.0f * 0.03937f);
*aScreenPixelToMillimeterX = 25.4f / context->AppUnitsToDevPixels(context->AppUnitsPerInch());
return NS_OK;
}
@ -1296,8 +1294,8 @@ void nsSVGSVGElement::GetOffsetToAncestor(nsIContent* ancestor,
if (frame && ancestorFrame) {
nsPoint point = frame->GetOffsetTo(ancestorFrame);
x = point.x * context->TwipsToPixels();
y = point.y * context->TwipsToPixels();
x = nsPresContext::AppUnitsToFloatCSSPixels(point.x);
y = nsPresContext::AppUnitsToFloatCSSPixels(point.y);
}
}

Просмотреть файл

@ -1352,11 +1352,8 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth,
size = frame->GetSize();
}
// Convert from twips to pixels
float scale = aShell->GetPresContext()->TwipsToPixels();
*aWidth = NSTwipsToIntPixels(size.width, scale);
*aHeight = NSTwipsToIntPixels(size.height, scale);
*aWidth = nsPresContext::AppUnitsToIntCSSPixels(size.width);
*aHeight = nsPresContext::AppUnitsToIntCSSPixels(size.height);
}
else {
*aWidth = 0;

Просмотреть файл

@ -4838,12 +4838,6 @@ nsDocShell::EnsureDeviceContext()
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
mDeviceContext->Init(widget->GetNativeData(NS_NATIVE_WIDGET));
float dev2twip;
dev2twip = mDeviceContext->DevUnitsToTwips();
mDeviceContext->SetDevUnitsToAppUnits(dev2twip);
float twip2dev;
twip2dev = mDeviceContext->TwipsToDevUnits();
mDeviceContext->SetAppUnitsToDevUnits(twip2dev);
return NS_OK;
}

Просмотреть файл

@ -3070,10 +3070,9 @@ nsGlobalWindow::GetScrollMaxXY(PRInt32* aScrollMaxX, PRInt32* aScrollMaxY)
nsresult rv;
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
FlushPendingNotifications(Flush_Layout);
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if (!view)
return NS_OK; // bug 230965 changed from NS_ERROR_FAILURE
@ -3085,10 +3084,10 @@ nsGlobalWindow::GetScrollMaxXY(PRInt32* aScrollMaxX, PRInt32* aScrollMaxY)
if (aScrollMaxX)
*aScrollMaxX = PR_MAX(0,
(PRInt32)floor(t2p*(scrolledSize.width - portRect.width)));
(PRInt32)floor(nsPresContext::AppUnitsToFloatCSSPixels(scrolledSize.width - portRect.width)));
if (aScrollMaxY)
*aScrollMaxY = PR_MAX(0,
(PRInt32)floor(t2p*(scrolledSize.height - portRect.height)));
(PRInt32)floor(nsPresContext::AppUnitsToFloatCSSPixels(scrolledSize.height - portRect.height)));
return NS_OK;
}
@ -3118,7 +3117,6 @@ nsGlobalWindow::GetScrollXY(PRInt32* aScrollX, PRInt32* aScrollY,
nsresult rv;
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
if (aDoFlush) {
FlushPendingNotifications(Flush_Layout);
@ -3126,7 +3124,7 @@ nsGlobalWindow::GetScrollXY(PRInt32* aScrollX, PRInt32* aScrollY,
EnsureSizeUpToDate();
}
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if (!view)
return NS_OK; // bug 202206 changed from NS_ERROR_FAILURE
@ -3142,9 +3140,9 @@ nsGlobalWindow::GetScrollXY(PRInt32* aScrollX, PRInt32* aScrollY,
}
if (aScrollX)
*aScrollX = NSTwipsToIntPixels(xPos, t2p);
*aScrollX = nsPresContext::AppUnitsToIntCSSPixels(xPos);
if (aScrollY)
*aScrollY = NSTwipsToIntPixels(yPos, t2p);
*aScrollY = nsPresContext::AppUnitsToIntCSSPixels(yPos);
return NS_OK;
}
@ -4051,10 +4049,9 @@ nsGlobalWindow::ScrollTo(PRInt32 aXScroll, PRInt32 aYScroll)
{
nsresult result;
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
FlushPendingNotifications(Flush_Layout);
result = GetScrollInfo(&view, &p2t, &t2p);
result = GetScrollInfo(&view);
if (view) {
// Here we calculate what the max pixel value is that we can
@ -4062,7 +4059,7 @@ nsGlobalWindow::ScrollTo(PRInt32 aXScroll, PRInt32 aYScroll)
// twips conversion factor, and substracting 4, the 4 comes from
// experimenting with this value, anything less makes the view
// code not scroll correctly, I have no idea why. -- jst
const PRInt32 maxpx = (PRInt32)((float)0x7fffffff / p2t) - 4;
const PRInt32 maxpx = nsPresContext::AppUnitsToIntCSSPixels(0x7fffffff) - 4;
if (aXScroll > maxpx) {
aXScroll = maxpx;
@ -4072,8 +4069,8 @@ nsGlobalWindow::ScrollTo(PRInt32 aXScroll, PRInt32 aYScroll)
aYScroll = maxpx;
}
result = view->ScrollTo(NSIntPixelsToTwips(aXScroll, p2t),
NSIntPixelsToTwips(aYScroll, p2t),
result = view->ScrollTo(nsPresContext::CSSPixelsToAppUnits(aXScroll),
nsPresContext::CSSPixelsToAppUnits(aYScroll),
NS_VMREFRESH_IMMEDIATE);
}
@ -4085,17 +4082,16 @@ nsGlobalWindow::ScrollBy(PRInt32 aXScrollDif, PRInt32 aYScrollDif)
{
nsresult result;
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
FlushPendingNotifications(Flush_Layout);
result = GetScrollInfo(&view, &p2t, &t2p);
result = GetScrollInfo(&view);
if (view) {
nscoord xPos, yPos;
result = view->GetScrollPosition(xPos, yPos);
if (NS_SUCCEEDED(result)) {
result = ScrollTo(NSTwipsToIntPixels(xPos, t2p) + aXScrollDif,
NSTwipsToIntPixels(yPos, t2p) + aYScrollDif);
result = ScrollTo(nsPresContext::AppUnitsToIntCSSPixels(xPos) + aXScrollDif,
nsPresContext::AppUnitsToIntCSSPixels(yPos) + aYScrollDif);
}
}
@ -4107,10 +4103,9 @@ nsGlobalWindow::ScrollByLines(PRInt32 numLines)
{
nsresult result;
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
FlushPendingNotifications(Flush_Layout);
result = GetScrollInfo(&view, &p2t, &t2p);
result = GetScrollInfo(&view);
if (view) {
result = view->ScrollByLines(0, numLines);
}
@ -4123,10 +4118,9 @@ nsGlobalWindow::ScrollByPages(PRInt32 numPages)
{
nsresult result;
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
FlushPendingNotifications(Flush_Layout);
result = GetScrollInfo(&view, &p2t, &t2p);
result = GetScrollInfo(&view);
if (view) {
result = view->ScrollByPages(0, numPages);
}
@ -7128,15 +7122,12 @@ nsGlobalWindow::GetWebBrowserChrome(nsIWebBrowserChrome **aBrowserChrome)
}
nsresult
nsGlobalWindow::GetScrollInfo(nsIScrollableView **aScrollableView, float *aP2T,
float *aT2P)
nsGlobalWindow::GetScrollInfo(nsIScrollableView **aScrollableView)
{
FORWARD_TO_OUTER(GetScrollInfo, (aScrollableView, aP2T, aT2P),
FORWARD_TO_OUTER(GetScrollInfo, (aScrollableView),
NS_ERROR_NOT_INITIALIZED);
*aScrollableView = nsnull;
*aP2T = 0.0f;
*aT2P = 0.0f;
if (!mDocShell) {
return NS_OK;
@ -7145,9 +7136,6 @@ nsGlobalWindow::GetScrollInfo(nsIScrollableView **aScrollableView, float *aP2T,
nsCOMPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
if (presContext) {
*aP2T = presContext->PixelsToTwips();
*aT2P = presContext->TwipsToPixels();
nsIViewManager* vm = presContext->GetViewManager();
if (vm)
return vm->GetRootScrollableView(aScrollableView);

Просмотреть файл

@ -515,8 +515,7 @@ protected:
nsresult GetWebBrowserChrome(nsIWebBrowserChrome** aBrowserChrome);
// GetScrollInfo does not flush. Callers should do it themselves as needed,
// depending on which info they actually want off the scrollable view.
nsresult GetScrollInfo(nsIScrollableView** aScrollableView, float* aP2T,
float* aT2P);
nsresult GetScrollInfo(nsIScrollableView** aScrollableView);
nsresult SecurityCheckURL(const char *aURL);
nsresult BuildURIfromBase(const char *aURL,
nsIURI **aBuiltURI,

Просмотреть файл

@ -241,16 +241,10 @@ nsScreen::GetRect(nsRect& aRect)
context->GetRect(aRect);
float devUnits;
devUnits = context->DevUnitsToAppUnits();
aRect.x = NSToIntRound(float(aRect.x) / devUnits);
aRect.y = NSToIntRound(float(aRect.y) / devUnits);
context->GetDeviceSurfaceDimensions(aRect.width, aRect.height);
aRect.height = NSToIntRound(float(aRect.height) / devUnits);
aRect.width = NSToIntRound(float(aRect.width) / devUnits);
aRect.x = nsPresContext::AppUnitsToIntCSSPixels(aRect.x);
aRect.y = nsPresContext::AppUnitsToIntCSSPixels(aRect.y);
aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
return NS_OK;
}
@ -266,13 +260,10 @@ nsScreen::GetAvailRect(nsRect& aRect)
context->GetClientRect(aRect);
float devUnits;
devUnits = context->DevUnitsToAppUnits();
aRect.x = NSToIntRound(float(aRect.x) / devUnits);
aRect.y = NSToIntRound(float(aRect.y) / devUnits);
aRect.height = NSToIntRound(float(aRect.height) / devUnits);
aRect.width = NSToIntRound(float(aRect.width) / devUnits);
aRect.x = nsPresContext::AppUnitsToIntCSSPixels(aRect.x);
aRect.y = nsPresContext::AppUnitsToIntCSSPixels(aRect.y);
aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
return NS_OK;
}

Просмотреть файл

@ -5711,8 +5711,6 @@ nsHTMLEditor::GetElementOrigin(nsIDOMElement * aElement, PRInt32 & aX, PRInt32 &
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
nsIFrame *frame = ps->GetPrimaryFrameFor(content); // not ref-counted
float t2p = ps->GetPresContext()->TwipsToPixels();
if (nsHTMLEditUtils::IsHR(aElement) && frame) {
frame = frame->GetNextSibling();
}
@ -5731,8 +5729,8 @@ nsHTMLEditor::GetElementOrigin(nsIDOMElement * aElement, PRInt32 & aX, PRInt32 &
frame = frame->GetParent();
}
aX = NSTwipsToIntPixels(offsetX , t2p);
aY = NSTwipsToIntPixels(offsetY , t2p);
aX = nsPresContext::AppUnitsToIntCSSPixels(offsetX);
aY = nsPresContext::AppUnitsToIntCSSPixels(offsetY);
return NS_OK;
}

Просмотреть файл

@ -471,10 +471,8 @@ nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
nsRect shellArea = presContext->GetVisibleArea();
float pixelScale;
pixelScale = presContext->TwipsToPixels();
PRInt32 browserCX = PRInt32((float)shellArea.width*pixelScale);
PRInt32 browserCY = PRInt32((float)shellArea.height*pixelScale);
PRInt32 browserCX = presContext->AppUnitsToDevPixels(shellArea.width);
PRInt32 browserCY = presContext->AppUnitsToDevPixels(shellArea.height);
return webBrowserChrome->SizeBrowserTo(browserCX, browserCY);
}

Просмотреть файл

@ -2594,6 +2594,7 @@ nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell,
// Set up the variables we need, return true if we can't get at them all
const PRUint16 kMinPixels = 12;
PRUint16 minPixels = PRUint16(nsPresContext::CSSPixelsToAppUnits(kMinPixels));
nsIViewManager* viewManager = aPresShell->GetViewManager();
if (!viewManager) {
@ -2606,8 +2607,6 @@ nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell,
// for only needs to be a rough indicator
nsIView *containingView = nsnull;
nsPoint frameOffset;
float p2t;
p2t = aPresContext->PixelsToTwips();
nsRectVisibility rectVisibility = nsRectVisibility_kAboveViewport;
if (!aGetTopVisibleLeaf) {
@ -2623,7 +2622,7 @@ nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell,
relFrameRect.y = frameOffset.y;
viewManager->GetRectVisibility(containingView, relFrameRect,
NS_STATIC_CAST(PRUint16, (kMinPixels * p2t)),
minPixels,
&rectVisibility);
if (rectVisibility != nsRectVisibility_kAboveViewport &&
@ -2667,9 +2666,7 @@ nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell,
relFrameRect.x = frameOffset.x;
relFrameRect.y = frameOffset.y;
viewManager->GetRectVisibility(containingView, relFrameRect,
NS_STATIC_CAST(PRUint16,
(kMinPixels * p2t)),
&rectVisibility);
minPixels, &rectVisibility);
}
}

Просмотреть файл

@ -100,9 +100,6 @@ public:
NS_IMETHOD CreateRenderingContext(nsIDrawingSurface* aSurface, nsIRenderingContext *&aContext);
NS_IMETHOD CreateRenderingContextInstance(nsIRenderingContext *&aContext);
NS_IMETHOD GetCanonicalPixelScale(float &aScale) const;
NS_IMETHOD SetCanonicalPixelScale(float aScale);
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
nsIFontMetrics*& aMetrics);
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics*& aMetrics);
@ -152,7 +149,6 @@ protected:
nsFontCache *mFontCache;
nsCOMPtr<nsIAtom> mLocaleLangGroup; // XXX temp fix for performance bug - erik
nsHashtable* mFontAliasTable;
float mCPixelScale;
#ifdef NS_PRINT_PREVIEW
nsCOMPtr<nsIDeviceContext> mAltDC;

Просмотреть файл

@ -282,84 +282,22 @@ public:
NS_IMETHOD PrepareNativeWidget(nsIWidget* aWidget, void** aOut) = 0;
/**
* Obtain the size of a device unit relative to a Twip. A twip is 1/20 of
* a point (which is 1/72 of an inch).
* @return conversion value
* Gets the number of app units in one CSS pixel; this number is global,
* not unique to each device context.
*/
float DevUnitsToTwips() const { return mPixelsToTwips; }
static PRInt32 AppUnitsPerCSSPixel() { return 60; }
/**
* Obtain the size of a Twip relative to a device unit.
* @return conversion value
* Gets the number of app units in one device pixel; this number is usually
* a factor of AppUnitsPerCSSPixel(), although that is not guaranteed.
*/
float TwipsToDevUnits() const { return mTwipsToPixels; }
PRInt32 AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
/**
* Set the scale factor to convert units used by the application
* to device units. Typically, an application will query the device
* for twips to device units scale and then set the scale
* to convert from whatever unit the application wants to use
* to device units. From that point on, all other parts of the
* app can use the Get* methods below to figure out how
* to convert device units <-> app units.
* @param aAppUnits scale value to convert from application defined
* units to device units.
* Gets the number of app units in one inch; this is the device's DPI
* times AppUnitsPerDevPixel().
*/
void SetAppUnitsToDevUnits(float aAppUnits)
{
mAppUnitsToDevUnits = aAppUnits;
}
/**
* Set the scale factor to convert device units to units
* used by the application. This should generally be
* 1.0f / the value passed into SetAppUnitsToDevUnits().
* @param aDevUnits scale value to convert from device units to
* application defined units
*/
void SetDevUnitsToAppUnits(float aDevUnits)
{
mDevUnitsToAppUnits = aDevUnits;
}
/**
* Get the scale factor to convert from application defined
* units to device units.
* @param aAppUnits scale value
*/
float AppUnitsToDevUnits() const { return mAppUnitsToDevUnits; }
/**
* Get the scale factor to convert from device units to
* application defined units.
* @param aDevUnits out paramater for scale value
* @return error status
*/
float DevUnitsToAppUnits() const { return mDevUnitsToAppUnits; }
/**
* Get the value used to scale a "standard" pixel to a pixel
* of the same physical size for this device. a standard pixel
* is defined as a pixel on display 0. this is used to make
* sure that entities defined in pixel dimensions maintain a
* constant relative size when displayed from one output
* device to another.
* @param aScale out parameter for scale value
* @return error status
*/
NS_IMETHOD GetCanonicalPixelScale(float &aScale) const = 0;
/**
* Get the value used to scale a "standard" pixel to a pixel
* of the same physical size for this device. a standard pixel
* is defined as a pixel on display 0. this is used to make
* sure that entities defined in pixel dimensions maintain a
* constant relative size when displayed from one output
* device to another.
* @param aScale in parameter for scale value
* @return error status
*/
NS_IMETHOD SetCanonicalPixelScale(float aScale) = 0;
PRInt32 AppUnitsPerInch() const { return mAppUnitsPerInch; }
/**
* Fill in an nsFont based on the ID of a system font. This function
@ -433,7 +371,7 @@ public:
* @param aHeight out parameter for height
* @return error status
*/
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight) = 0;
NS_IMETHOD GetDeviceSurfaceDimensions(nscoord &aWidth, nscoord &aHeight) = 0;
/**
* Get the size of the content area of the output device in app units.
@ -560,10 +498,8 @@ public:
NS_IMETHOD ClearCachedSystemFonts() = 0;
protected:
float mTwipsToPixels;
float mPixelsToTwips;
float mAppUnitsToDevUnits;
float mDevUnitsToAppUnits;
PRInt32 mAppUnitsPerDevPixel;
PRInt32 mAppUnitsPerInch;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDeviceContext, NS_IDEVICE_CONTEXT_IID)

Просмотреть файл

@ -55,13 +55,9 @@ NS_IMPL_ISUPPORTS3(DeviceContextImpl, nsIDeviceContext, nsIObserver, nsISupports
DeviceContextImpl::DeviceContextImpl()
{
mDevUnitsToAppUnits = 1.0f;
mAppUnitsToDevUnits = 1.0f;
mTwipsToPixels = 1.0f;
mPixelsToTwips = 1.0f;
mAppUnitsPerDevPixel = -1;
mAppUnitsPerInch = -1;
mFontCache = nsnull;
mCPixelScale = 1.0f;
mWidget = nsnull;
mFontAliasTable = nsnull;
@ -130,18 +126,6 @@ void DeviceContextImpl::CommonInit(void)
obs->AddObserver(this, "memory-pressure", PR_TRUE);
}
NS_IMETHODIMP DeviceContextImpl::GetCanonicalPixelScale(float &aScale) const
{
aScale = mCPixelScale;
return NS_OK;
}
NS_IMETHODIMP DeviceContextImpl::SetCanonicalPixelScale(float aScale)
{
mCPixelScale = aScale;
return NS_OK;
}
NS_IMETHODIMP DeviceContextImpl::CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext)
{
#ifdef NS_PRINT_PREVIEW

Просмотреть файл

@ -38,6 +38,7 @@
#include "nsRect.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "nsIDeviceContext.h"
#ifdef MIN
#undef MIN
@ -210,15 +211,19 @@ FILE* operator<<(FILE* out, const nsRect& rect)
{
nsAutoString tmp;
// Output the coordinates in fractional points so they're easier to read
// Output the coordinates in fractional pixels so they're easier to read
tmp.AppendLiteral("{");
tmp.AppendFloat(NSTwipsToFloatPoints(rect.x));
tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.x,
nsIDeviceContext::AppUnitsPerCSSPixel()));
tmp.AppendLiteral(", ");
tmp.AppendFloat(NSTwipsToFloatPoints(rect.y));
tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.y,
nsIDeviceContext::AppUnitsPerCSSPixel()));
tmp.AppendLiteral(", ");
tmp.AppendFloat(NSTwipsToFloatPoints(rect.width));
tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.width,
nsIDeviceContext::AppUnitsPerCSSPixel()));
tmp.AppendLiteral(", ");
tmp.AppendFloat(NSTwipsToFloatPoints(rect.height));
tmp.AppendFloat(NSAppUnitsToFloatPixels(rect.height,
nsIDeviceContext::AppUnitsPerCSSPixel()));
tmp.AppendLiteral("}");
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
return out;

Просмотреть файл

@ -115,12 +115,10 @@ nsresult nsRenderingContextImpl::AllocateBackbuffer(const nsRect &aRequestedSize
} else {
SelectOffScreenDrawingSurface(gBackbuffer);
float p2t;
nsCOMPtr<nsIDeviceContext> dx;
GetDeviceContext(*getter_AddRefs(dx));
p2t = dx->DevUnitsToAppUnits();
nsRect bounds = aRequestedSize;
bounds *= p2t;
bounds *= dx->AppUnitsPerDevPixel();
SetClipRect(bounds, nsClipCombine_kReplace);
}
@ -229,17 +227,16 @@ void nsRenderingContextImpl::GetDrawingSurfaceSize(const nsRect& aMaxBackbufferS
void nsRenderingContextImpl::CalculateDiscreteSurfaceSize(const nsRect& aMaxBackbufferSize, const nsRect& aRequestedSize, nsRect& aSurfaceSize)
{
// Get the height and width of the screen
PRInt32 height;
PRInt32 width;
nscoord height;
nscoord width;
nsCOMPtr<nsIDeviceContext> dx;
GetDeviceContext(*getter_AddRefs(dx));
dx->GetDeviceSurfaceDimensions(width, height);
float devUnits;
devUnits = dx->DevUnitsToAppUnits();
PRInt32 screenHeight = NSToIntRound(float( height) / devUnits );
PRInt32 screenWidth = NSToIntRound(float( width) / devUnits );
PRInt32 p2a = dx->AppUnitsPerDevPixel();
PRInt32 screenHeight = NSAppUnitsToIntPixels(height, p2a);
PRInt32 screenWidth = NSAppUnitsToIntPixels(width, p2a);
// These tests must go from smallest rectangle to largest rectangle.

Просмотреть файл

@ -141,14 +141,11 @@ nsThebesDeviceContext::~nsThebesDeviceContext()
nsresult
nsThebesDeviceContext::SetDPI(PRInt32 aPrefDPI)
{
PRInt32 OSVal;
PRBool do_round = PR_TRUE; // XXX bogus -- only caller for which it's false is a round number
PRInt32 dpi = 96;
#if defined(MOZ_ENABLE_GTK2)
float screenWidthIn = float(::gdk_screen_width_mm()) / 25.4f;
OSVal = NSToCoordRound(float(::gdk_screen_width()) / screenWidthIn);
PRInt32 OSVal = NSToCoordRound(float(::gdk_screen_width()) / screenWidthIn);
if (aPrefDPI > 0) {
// If there's a valid pref value for the logical resolution,
@ -169,16 +166,13 @@ nsThebesDeviceContext::SetDPI(PRInt32 aPrefDPI)
// notion of DPI so we have to use 72...
// XXX is this an issue? we force everything else to be 96+
dpi = 72;
do_round = PR_FALSE;
}
#elif defined(XP_WIN)
// XXX we should really look at the widget for printing and such, but this widget is currently always null...
HDC dc = GetHDC() ? GetHDC() : GetDC((HWND)nsnull);
OSVal = GetDeviceCaps(dc, LOGPIXELSY);
if (GetDeviceCaps(dc, TECHNOLOGY) != DT_RASDISPLAY)
do_round = PR_FALSE;
PRInt32 OSVal = GetDeviceCaps(dc, LOGPIXELSY);
if (dc != GetHDC())
ReleaseDC((HWND)nsnull, dc);
@ -190,18 +184,15 @@ nsThebesDeviceContext::SetDPI(PRInt32 aPrefDPI)
if (mPrinter) {
dpi = 72;
do_round = PR_FALSE;
}
#endif
int in2pt = 72;
if (aPrefDPI > 0 && !mPrinter)
dpi = aPrefDPI;
// make p2t a nice round number - this prevents rounding problems
mPixelsToTwips = float(NSIntPointsToTwips(in2pt)) / float(dpi);
if (do_round)
mPixelsToTwips = float(NSToIntRound(mPixelsToTwips));
mTwipsToPixels = 1.0f / mPixelsToTwips;
mAppUnitsPerDevPixel = AppUnitsPerCSSPixel() / PR_MAX(1, (dpi + 48) / 96);
mAppUnitsPerInch = NSIntPixelsToAppUnits(dpi, mAppUnitsPerDevPixel);
return NS_OK;
}
@ -391,7 +382,7 @@ nsThebesDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
aFont->familyNameQuirks = fontStyle.familyNameQuirks;
aFont->weight = fontStyle.weight;
aFont->decorations = fontStyle.decorations;
aFont->size = NSToCoordRound(fontStyle.size * mPixelsToTwips);
aFont->size = NSFloatPixelsToAppUnits(fontStyle.size, AppUnitsPerDevPixel());
//aFont->langGroup = fontStyle.langGroup;
aFont->sizeAdjust = fontStyle.sizeAdjust;
@ -430,7 +421,7 @@ nsThebesDeviceContext::ConvertPixel(nscolor aColor, PRUint32 & aPixel)
}
NS_IMETHODIMP
nsThebesDeviceContext::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
nsThebesDeviceContext::GetDeviceSurfaceDimensions(nscoord &aWidth, nscoord &aHeight)
{
if (mPrinter) {
// we have a printer device
@ -512,17 +503,6 @@ nsThebesDeviceContext::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
newDevCon->Init(nsnull);
float newscale = newDevCon->TwipsToDevUnits();
float origscale = this->TwipsToDevUnits();
newDevCon->SetCanonicalPixelScale(newscale / origscale);
float t2d = this->TwipsToDevUnits();
float a2d = this->AppUnitsToDevUnits();
newDevCon->SetAppUnitsToDevUnits((a2d / t2d) * newDevCon->mTwipsToPixels);
newDevCon->SetDevUnitsToAppUnits(1.0f / newDevCon->mAppUnitsToDevUnits);
newDevCon->CalcPrintingSize();
return NS_OK;
@ -668,10 +648,10 @@ nsThebesDeviceContext::ComputeClientRectUsingScreen(nsRect* outRect)
screen->GetAvailRect(&x, &y, &width, &height);
// convert to device units
outRect->y = NSToIntRound(y * mDevUnitsToAppUnits);
outRect->x = NSToIntRound(x * mDevUnitsToAppUnits);
outRect->width = NSToIntRound(width * mDevUnitsToAppUnits);
outRect->height = NSToIntRound(height * mDevUnitsToAppUnits);
outRect->y = NSIntPixelsToAppUnits(y, AppUnitsPerDevPixel());
outRect->x = NSIntPixelsToAppUnits(x, AppUnitsPerDevPixel());
outRect->width = NSIntPixelsToAppUnits(width, AppUnitsPerDevPixel());
outRect->height = NSIntPixelsToAppUnits(height, AppUnitsPerDevPixel());
}
}
@ -689,10 +669,10 @@ nsThebesDeviceContext::ComputeFullAreaUsingScreen(nsRect* outRect)
screen->GetRect ( &x, &y, &width, &height );
// convert to device units
outRect->y = NSToIntRound(y * mDevUnitsToAppUnits);
outRect->x = NSToIntRound(x * mDevUnitsToAppUnits);
outRect->width = NSToIntRound(width * mDevUnitsToAppUnits);
outRect->height = NSToIntRound(height * mDevUnitsToAppUnits);
outRect->y = NSIntPixelsToAppUnits(y, AppUnitsPerDevPixel());
outRect->x = NSIntPixelsToAppUnits(x, AppUnitsPerDevPixel());
outRect->width = NSIntPixelsToAppUnits(width, AppUnitsPerDevPixel());
outRect->height = NSIntPixelsToAppUnits(height, AppUnitsPerDevPixel());
mWidth = outRect->width;
mHeight = outRect->height;
@ -753,8 +733,8 @@ nsThebesDeviceContext::CalcPrintingSize()
{
inPoints = PR_FALSE;
HDC dc = GetHDC() ? GetHDC() : GetDC((HWND)mWidget);
size.width = NSToIntRound(::GetDeviceCaps(dc, HORZRES) * mDevUnitsToAppUnits);
size.height = NSToIntRound(::GetDeviceCaps(dc, VERTRES) * mDevUnitsToAppUnits);
size.width = NSIntPixelsToAppUnits(::GetDeviceCaps(dc, HORZRES), AppUnitsPerDevPixel());
size.height = NSIntPixelsToAppUnits(::GetDeviceCaps(dc, VERTRES), AppUnitsPerDevPixel());
mDepth = (PRUint32)::GetDeviceCaps(dc, BITSPIXEL);
if (dc != (HDC)GetHDC())
ReleaseDC((HWND)mWidget, dc);
@ -766,8 +746,8 @@ nsThebesDeviceContext::CalcPrintingSize()
}
if (inPoints) {
mWidth = NSFloatPointsToTwips(size.width);
mHeight = NSFloatPointsToTwips(size.height);
mWidth = float(size.width) * AppUnitsPerInch() / 72;
mHeight = float(size.height) * AppUnitsPerInch() / 72;
printf("%f %f\n", size.width, size.height);
printf("%d %d\n", (PRInt32)mWidth, (PRInt32)mHeight);
} else {

Просмотреть файл

@ -77,12 +77,12 @@ nsThebesFontMetrics::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mFont = aFont;
mLangGroup = aLangGroup;
mDeviceContext = (nsThebesDeviceContext*)aContext;
mDev2App = aContext->DevUnitsToAppUnits();
mP2A = mDeviceContext->AppUnitsPerDevPixel();
mIsRightToLeft = PR_FALSE;
mTextRunRTL = PR_FALSE;
// work around layout giving us 0 sized fonts...
double size = aFont.size * mDeviceContext->AppUnitsToDevUnits();
double size = NSAppUnitsToFloatPixels(aFont.size, mP2A);
if (size == 0.0)
size = 1.0;
@ -119,7 +119,8 @@ nsThebesFontMetrics::Destroy()
return NS_OK;
}
#define ROUND_TO_TWIPS(x) (nscoord)floor(((x) * mDev2App) + 0.5)
// XXXTODO get rid of this macro
#define ROUND_TO_TWIPS(x) (nscoord)floor(((x) * mP2A) + 0.5)
const gfxFont::Metrics& nsThebesFontMetrics::GetMetrics() const
{

Просмотреть файл

@ -165,14 +165,14 @@ protected:
const char* aString, PRInt32 aLength, PRBool aEnableSpacing) {
mTextRun = gfxTextRunCache::GetCache()->GetOrMakeTextRun(
NS_STATIC_CAST(gfxContext*, aRC->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT)),
aMetrics->mFontGroup, aString, aLength, aMetrics->mDev2App,
aMetrics->mFontGroup, aString, aLength, aMetrics->mP2A,
aMetrics->GetRightToLeftTextRunMode(), aEnableSpacing, &mOwning);
}
AutoTextRun(nsThebesFontMetrics* aMetrics, nsIRenderingContext* aRC,
const PRUnichar* aString, PRInt32 aLength, PRBool aEnableSpacing) {
mTextRun = gfxTextRunCache::GetCache()->GetOrMakeTextRun(
NS_STATIC_CAST(gfxContext*, aRC->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT)),
aMetrics->mFontGroup, aString, aLength, aMetrics->mDev2App,
aMetrics->mFontGroup, aString, aLength, aMetrics->mP2A,
aMetrics->GetRightToLeftTextRunMode(), aEnableSpacing, &mOwning);
}
~AutoTextRun() {
@ -194,7 +194,7 @@ protected:
private:
nsThebesDeviceContext *mDeviceContext;
nsCOMPtr<nsIAtom> mLangGroup;
float mDev2App;
PRInt32 mP2A;
PRPackedBool mIsRightToLeft;
PRPackedBool mTextRunRTL;
};

Просмотреть файл

@ -415,6 +415,7 @@ nsThebesImage::Draw(nsIRenderingContext &aContext, nsIDrawingSurface *aSurface,
nsresult
nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
nsIDeviceContext* dx,
const gfxPoint& offset,
const gfxRect& targetRect,
const PRInt32 xPadding,
@ -494,7 +495,12 @@ nsThebesImage::ThebesDrawTile(gfxContext *thebesContext,
p0.x = - floor(offset.x + 0.5);
p0.y = - floor(offset.y + 0.5);
}
// Scale factor to account for CSS pixels; note that the offset (and
// therefore p0) is in device pixels, while the width and height are in
// CSS pixels.
gfxFloat scale = gfxFloat(nsIDeviceContext::AppUnitsPerCSSPixel()) /
gfxFloat(dx->AppUnitsPerDevPixel());
patMat.Scale(1.0 / scale, 1.0 / scale);
patMat.Translate(p0);
pat = new gfxPattern(surface);

Просмотреть файл

@ -88,6 +88,7 @@ public:
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
nsresult ThebesDrawTile(gfxContext *thebesContext,
nsIDeviceContext* dx,
const gfxPoint& aOffset,
const gfxRect& aTileRect,
const PRInt32 aXPadding,

Просмотреть файл

@ -72,9 +72,10 @@ static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
//////////////////////////////////////////////////////////////////////
#define FROM_TWIPS(_x) ((gfxFloat)((_x)/(mP2T)))
#define FROM_TWIPS_INT(_x) (NSToIntRound((gfxFloat)((_x)/(mP2T))))
#define TO_TWIPS(_x) ((nscoord)((_x)*(mP2T)))
// XXXTodo: rename FORM_TWIPS to FROM_APPUNITS
#define FROM_TWIPS(_x) ((gfxFloat)((_x)/(mP2A)))
#define FROM_TWIPS_INT(_x) (NSToIntRound((gfxFloat)((_x)/(mP2A))))
#define TO_TWIPS(_x) ((nscoord)((_x)*(mP2A)))
#define GFX_RECT_FROM_TWIPS_RECT(_r) (gfxRect(FROM_TWIPS((_r).x), FROM_TWIPS((_r).y), FROM_TWIPS((_r).width), FROM_TWIPS((_r).height)))
//////////////////////////////////////////////////////////////////////
@ -173,8 +174,7 @@ nsThebesRenderingContext::CommonInit(void)
mThebes->SetLineWidth(1.0);
mT2P = mDeviceContext->AppUnitsToDevUnits();
mP2T = mDeviceContext->DevUnitsToAppUnits();
mP2A = mDeviceContext->AppUnitsPerDevPixel();
return NS_OK;
}
@ -673,7 +673,7 @@ nsThebesRenderingContext::FillRect(const nsRect& aRect)
gfxRect r(GFX_RECT_FROM_TWIPS_RECT(aRect));
/* Clamp coordinates to work around a design bug in cairo */
nscoord bigval = (nscoord)(CAIRO_COORD_MAX*mP2T);
nscoord bigval = (nscoord)(CAIRO_COORD_MAX*mP2A);
if (aRect.width > bigval ||
aRect.height > bigval ||
aRect.x < -bigval ||
@ -993,11 +993,11 @@ nsThebesRenderingContext::DrawImage(imgIContainer *aImage,
// twSrcRect is always in appunits (twips),
// and has nothing to do with the current transform (it's a region
// of the image)
nsIntRect pxSr;
pxSr.x = NSToIntRound(FROM_TWIPS(twSrcRect.x));
pxSr.y = NSToIntRound(FROM_TWIPS(twSrcRect.y));
pxSr.width = NSToIntRound(FROM_TWIPS(twSrcRect.width));
pxSr.height = NSToIntRound(FROM_TWIPS(twSrcRect.height));
double p2a = nsIDeviceContext::AppUnitsPerCSSPixel();
nsIntRect pxSr(NSAppUnitsToIntPixels(twSrcRect.x, p2a),
NSAppUnitsToIntPixels(twSrcRect.y, p2a),
NSAppUnitsToIntPixels(twSrcRect.width, p2a),
NSAppUnitsToIntPixels(twSrcRect.height, p2a));
// the dest rect is affected by the current transform; that'll be
// handled by Image::Draw(), when we actually set up the rectangle.
@ -1112,7 +1112,7 @@ nsThebesRenderingContext::DrawTile(imgIContainer *aImage,
phase.y -= imgFrameRect.y;
}
return thebesImage->ThebesDrawTile (mThebes, phase,
return thebesImage->ThebesDrawTile (mThebes, mDeviceContext, phase,
GFX_RECT_FROM_TWIPS_RECT(*twTargetRect),
xPadding, yPadding);
}

Просмотреть файл

@ -274,7 +274,7 @@ public:
protected:
nsCOMPtr<nsIDeviceContext> mDeviceContext;
// cached pixels2twips, twips2pixels values
double mP2T, mT2P;
double mP2A;
nsCOMPtr<nsIWidget> mWidget;

Просмотреть файл

@ -60,6 +60,9 @@ typedef struct _cairo cairo_t;
* The functions like Rectangle and Arc do not do any drawing themselves.
* When a path is drawn (stroked or filled), it is filled/stroked with a
* pattern set by SetPattern, SetColor or SetSource.
*
* Note that the gfxContext takes coordinates in device pixels,
* as opposed to app units.
*/
class THEBES_API gfxContext {
THEBES_INLINE_DECL_REFCOUNTING(gfxContext)

Просмотреть файл

@ -243,7 +243,7 @@ public:
PRUint32 *mInitialBreaks;
PRUint32 mInitialBreakCount;
// The ratio to use to convert device pixels to application layout units
gfxFloat mPixelsToUnits;
PRUint32 mAppUnitsPerDevUnit;
// Flags --- see above
PRUint32 mFlags;
};
@ -703,11 +703,12 @@ public:
void *GetUserData() const { return mUserData; }
PRUint32 GetFlags() const { return mFlags; }
const gfxSkipChars& GetSkipChars() const { return mSkipChars; }
gfxFloat GetPixelsToAppUnits() { return mPixelsToAppUnits; }
float GetAppUnitsPerDevUnit() { return mAppUnitsPerDevUnit; }
protected:
gfxTextRun(gfxTextRunFactory::Parameters *aParams, PRBool aIs8Bit)
: mUserData(aParams->mUserData), mPixelsToAppUnits(aParams->mPixelsToUnits),
: mUserData(aParams->mUserData),
mAppUnitsPerDevUnit(aParams->mAppUnitsPerDevUnit),
mFlags(aParams->mFlags)
{
mSkipChars.TakeFrom(aParams->mSkipChars);
@ -718,7 +719,9 @@ protected:
void * mUserData;
gfxSkipChars mSkipChars;
gfxFloat mPixelsToAppUnits;
// This is actually an integer, but we keep it in float form to reduce
// the conversions required
float mAppUnitsPerDevUnit;
PRUint32 mFlags;
};
#endif

Просмотреть файл

@ -64,11 +64,13 @@ public:
* the next GetOrMakeTextRun call and the caller must not delete it.
*/
gfxTextRun *GetOrMakeTextRun (gfxContext* aContext, gfxFontGroup *aFontGroup,
const char *aString, PRUint32 aLength, gfxFloat aDevToApp,
PRBool aIsRTL, PRBool aEnableSpacing, PRBool *aCallerOwns);
const char *aString, PRUint32 aLength,
PRUint32 aAppUnitsPerDevUnit, PRBool aIsRTL,
PRBool aEnableSpacing, PRBool *aCallerOwns);
gfxTextRun *GetOrMakeTextRun (gfxContext* aContext, gfxFontGroup *aFontGroup,
const PRUnichar *aString, PRUint32 aLength, gfxFloat aDevToApp,
PRBool aIsRTL, PRBool aEnableSpacing, PRBool *aCallerOwns);
const PRUnichar *aString, PRUint32 aLength,
PRUint32 aAppUnitsPerDevUnit, PRBool aIsRTL,
PRBool aEnableSpacing, PRBool *aCallerOwns);
protected:
gfxTextRunCache();

Просмотреть файл

@ -444,11 +444,11 @@ gfxWrapperTextRun::SetupSpacingFromProvider(PropertyProvider* aProvider)
nsTArray<gfxFloat> spaceArray;
PRUint32 i;
gfxFloat offset = 0;
gfxFloat offset = 0; // in device pixels
for (i = 0; i < mLength; ++i) {
NS_ASSERTION(spacing.Elements()[i].mBefore == 0,
"Can't handle before-spacing!");
gfxFloat nextOffset = offset + spacing.Elements()[i].mAfter/mPixelsToAppUnits;
gfxFloat nextOffset = offset + spacing.Elements()[i].mAfter/mAppUnitsPerDevUnit;
spaceArray.AppendElement(ROUND(nextOffset) - ROUND(offset));
offset = nextOffset;
}
@ -464,7 +464,7 @@ gfxWrapperTextRun::Draw(gfxContext *aContext, gfxPoint aPt,
{
NS_ASSERTION(aStart == 0 && aLength == mLength, "Can't handle substrings");
SetupSpacingFromProvider(aBreakProvider);
gfxPoint pt(aPt.x/mPixelsToAppUnits, aPt.y/mPixelsToAppUnits);
gfxPoint pt(aPt.x/mAppUnitsPerDevUnit, aPt.y/mAppUnitsPerDevUnit);
return mInner.Draw(mContext, pt);
}
@ -474,7 +474,7 @@ gfxWrapperTextRun::GetAdvanceWidth(PRUint32 aStart, PRUint32 aLength,
{
NS_ASSERTION(aStart == 0 && aLength == mLength, "Can't handle substrings");
SetupSpacingFromProvider(aBreakProvider);
return mInner.Measure(mContext)*mPixelsToAppUnits;
return mInner.Measure(mContext)*mAppUnitsPerDevUnit;
}
gfxTextRun *

Просмотреть файл

@ -851,7 +851,7 @@ gfxPangoTextRun::ComputeLigatureData(PRUint32 aPartOffset, PropertyProvider *aPr
} while (!charGlyphs[ligStart].IsClusterStart());
}
result.mStartOffset = ligStart;
result.mLigatureWidth = ComputeClusterAdvance(ligStart)*mPixelsToAppUnits;
result.mLigatureWidth = ComputeClusterAdvance(ligStart)*mAppUnitsPerDevUnit;
result.mPartClusterIndex = PR_UINT32_MAX;
PRUint32 charIndex = ligStart;
@ -927,7 +927,7 @@ gfxPangoTextRun::GetAdjustedSpacing(PRUint32 aStart, PRUint32 aEnd,
if (i > aStart) {
aSpacing[i - 1 - aStart].mAfter -= clusterWidth;
}
clusterWidth = glyphData->GetSimpleAdvance()*mPixelsToAppUnits;
clusterWidth = glyphData->GetSimpleAdvance()*mAppUnitsPerDevUnit;
} else if (glyphData->IsComplexCluster()) {
NS_ASSERTION(mDetailedGlyphs, "No details but we have a complex cluster...");
if (i > aStart) {
@ -941,7 +941,7 @@ gfxPangoTextRun::GetAdjustedSpacing(PRUint32 aStart, PRUint32 aEnd,
break;
++details;
}
clusterWidth *= mPixelsToAppUnits;
clusterWidth *= mAppUnitsPerDevUnit;
}
}
aSpacing[aEnd - 1 - aStart].mAfter -= clusterWidth;
@ -969,7 +969,7 @@ gfxPangoTextRun::ProcessCairoGlyphsWithSpacing(CairoGlyphProcessorCallback aCB,
if (aStart >= aEnd)
return;
double appUnitsToPixels = 1/mPixelsToAppUnits;
double appUnitsToPixels = 1/mAppUnitsPerDevUnit;
CompressedGlyph *charGlyphs = mCharacterGlyphs;
double direction = GetDirection();
@ -1127,7 +1127,7 @@ gfxPangoTextRun::DrawPartialLigature(gfxContext *aCtx, PRUint32 aOffset,
if (!mCharacterGlyphs[aOffset].IsClusterStart() || !aDirtyRect)
return;
gfxFloat appUnitsToPixels = 1.0/mPixelsToAppUnits;
gfxFloat appUnitsToPixels = 1.0/mAppUnitsPerDevUnit;
// Draw partial ligature. We hack this by clipping the ligature.
LigatureData data = ComputeLigatureData(aOffset, aProvider);
@ -1149,7 +1149,7 @@ gfxPangoTextRun::DrawPartialLigature(gfxContext *aCtx, PRUint32 aOffset,
left = PR_MAX(left, aPt->x);
}
widthBeforeCluster = clusterWidth*data.mPartClusterIndex +
data.mBeforeSpacing/mPixelsToAppUnits;
data.mBeforeSpacing*appUnitsToPixels;
} else {
// We're drawing the start of the ligature, so our cluster includes any
// before-spacing.
@ -1165,7 +1165,7 @@ gfxPangoTextRun::DrawPartialLigature(gfxContext *aCtx, PRUint32 aOffset,
}
afterSpace = 0;
} else {
afterSpace = data.mAfterSpacing/mPixelsToAppUnits;
afterSpace = data.mAfterSpacing*appUnitsToPixels;
}
aCtx->Save();
@ -1186,7 +1186,7 @@ gfxPangoTextRun::Draw(gfxContext *aContext, gfxPoint aPt,
{
NS_ASSERTION(aStart + aLength <= mCharacterCount, "Substring out of range");
gfxFloat appUnitsToPixels = 1/mPixelsToAppUnits;
gfxFloat appUnitsToPixels = 1/mAppUnitsPerDevUnit;
CompressedGlyph *charGlyphs = mCharacterGlyphs;
gfxFloat direction = GetDirection();
@ -1224,7 +1224,7 @@ gfxPangoTextRun::Draw(gfxContext *aContext, gfxPoint aPt,
}
if (aAdvanceWidth) {
*aAdvanceWidth = (pt.x - startX)*direction*mPixelsToAppUnits;
*aAdvanceWidth = (pt.x - startX)*direction*mAppUnitsPerDevUnit;
}
}
@ -1235,7 +1235,7 @@ gfxPangoTextRun::DrawToPath(gfxContext *aContext, gfxPoint aPt,
{
NS_ASSERTION(aStart + aLength <= mCharacterCount, "Substring out of range");
gfxFloat appUnitsToPixels = 1/mPixelsToAppUnits;
gfxFloat appUnitsToPixels = 1/mAppUnitsPerDevUnit;
CompressedGlyph *charGlyphs = mCharacterGlyphs;
gfxFloat direction = GetDirection();
@ -1263,7 +1263,7 @@ gfxPangoTextRun::DrawToPath(gfxContext *aContext, gfxPoint aPt,
}
if (aAdvanceWidth) {
*aAdvanceWidth = (pt.x - startX)*direction*mPixelsToAppUnits;
*aAdvanceWidth = (pt.x - startX)*direction*mAppUnitsPerDevUnit;
}
}
@ -1303,7 +1303,7 @@ gfxPangoTextRun::AccumulatePangoMetricsForRun(PangoFont *aPangoFont, PRUint32 aS
nsAutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
PRBool haveSpacing = GetAdjustedSpacingArray(aStart, aEnd, aProvider, &spacingBuffer);
gfxFloat appUnitsToPango = gfxFloat(PANGO_SCALE)/mPixelsToAppUnits;
gfxFloat appUnitsToPango = gfxFloat(PANGO_SCALE)/mAppUnitsPerDevUnit;
// We start by assuming every character is a cluster and subtract off
// characters where that's not true
@ -1376,7 +1376,8 @@ gfxPangoTextRun::AccumulatePangoMetricsForRun(PangoFont *aPangoFont, PRUint32 aS
glyphs.glyphs = glyphBuffer.Elements();
glyphs.log_clusters = nsnull;
glyphs.space = glyphBuffer.Length();
Metrics metrics = GetPangoMetrics(&glyphs, aPangoFont, mPixelsToAppUnits, clusterCount);
Metrics metrics = GetPangoMetrics(&glyphs, aPangoFont, mAppUnitsPerDevUnit,
clusterCount);
if (IsRightToLeft()) {
metrics.CombineWith(*aMetrics);
@ -1563,7 +1564,7 @@ gfxPangoTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength,
PRBool lineBreakHere = mCharacterGlyphs[i].CanBreakBefore() &&
(!aSuppressInitialBreak || i > aStart);
if (lineBreakHere || (haveHyphenation && hyphenBuffer[i - bufferStart])) {
gfxFloat advance = gfxFloat(pixelAdvance)*mPixelsToAppUnits + floatAdvanceUnits;
gfxFloat advance = gfxFloat(pixelAdvance)*mAppUnitsPerDevUnit + floatAdvanceUnits;
gfxFloat hyphenatedAdvance = advance;
PRBool hyphenation = !lineBreakHere;
if (hyphenation) {
@ -1594,7 +1595,7 @@ gfxPangoTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength,
NS_ASSERTION(mDetailedGlyphs, "No details but we have a complex cluster...");
DetailedGlyph *details = mDetailedGlyphs[i];
for (;;) {
floatAdvanceUnits += details->mAdvance*mPixelsToAppUnits;
floatAdvanceUnits += details->mAdvance*mAppUnitsPerDevUnit;
if (details->mIsLastGlyph)
break;
++details;
@ -1610,7 +1611,7 @@ gfxPangoTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength,
}
if (!aborted) {
gfxFloat advance = gfxFloat(pixelAdvance)*mPixelsToAppUnits + floatAdvanceUnits;
gfxFloat advance = gfxFloat(pixelAdvance)*mAppUnitsPerDevUnit + floatAdvanceUnits;
width += advance;
}
@ -1691,7 +1692,7 @@ gfxPangoTextRun::GetAdvanceWidth(PRUint32 aStart, PRUint32 aLength,
NS_ASSERTION(mDetailedGlyphs, "No details but we have a complex cluster...");
DetailedGlyph *details = mDetailedGlyphs[i];
for (;;) {
result += details->mAdvance*mPixelsToAppUnits;
result += details->mAdvance*mAppUnitsPerDevUnit;
if (details->mIsLastGlyph)
break;
++details;
@ -1699,7 +1700,7 @@ gfxPangoTextRun::GetAdvanceWidth(PRUint32 aStart, PRUint32 aLength,
}
}
return result + gfxFloat(pixelAdvance)*mPixelsToAppUnits;
return result + gfxFloat(pixelAdvance)*mAppUnitsPerDevUnit;
}
#define IS_MISSING_GLYPH(g) (((g) & 0x10000000) || (g) == 0x0FFFFFFF)
@ -1807,14 +1808,14 @@ gfxPangoTextRun::MeasureTextSpecialString(SpecialString aString,
return Metrics();
PangoFont *pangoFont = mFontGroup->GetFontAt(0)->GetPangoFont();
return GetPangoMetrics(data->mGlyphs, pangoFont, mPixelsToAppUnits, 1);
return GetPangoMetrics(data->mGlyphs, pangoFont, mAppUnitsPerDevUnit, 1);
}
void
gfxPangoTextRun::DrawSpecialString(gfxContext *aContext, gfxPoint aPt,
SpecialString aString)
{
gfxFloat appUnitsToPixels = 1/mPixelsToAppUnits;
gfxFloat appUnitsToPixels = 1.0/mAppUnitsPerDevUnit;
gfxPoint pt(NSToCoordRound(aPt.x*appUnitsToPixels),
NSToCoordRound(aPt.y*appUnitsToPixels));
const gfxPangoFontGroup::SpecialStringData *data = GetSpecialStringData(aString, mFontGroup);
@ -1864,32 +1865,32 @@ gfxPangoTextRun::DrawSpecialString(gfxContext *aContext, gfxPoint aPt,
gfxFloat
gfxPangoTextRun::GetAdvanceWidthSpecialString(SpecialString aString)
{
return GetSpecialStringData(aString, mFontGroup)->mAdvance*mPixelsToAppUnits;
return GetSpecialStringData(aString, mFontGroup)->mAdvance*mAppUnitsPerDevUnit;
}
gfxFont::Metrics
gfxPangoTextRun::GetDecorationMetrics()
{
gfxFont::Metrics metrics = mFontGroup->GetFontAt(0)->GetMetrics();
metrics.xHeight *= mPixelsToAppUnits;
metrics.superscriptOffset *= mPixelsToAppUnits;
metrics.subscriptOffset *= mPixelsToAppUnits;
metrics.strikeoutSize *= mPixelsToAppUnits;
metrics.strikeoutOffset *= mPixelsToAppUnits;
metrics.underlineSize *= mPixelsToAppUnits;
metrics.underlineOffset *= mPixelsToAppUnits;
metrics.height *= mPixelsToAppUnits;
metrics.internalLeading *= mPixelsToAppUnits;
metrics.externalLeading *= mPixelsToAppUnits;
metrics.emHeight *= mPixelsToAppUnits;
metrics.emAscent *= mPixelsToAppUnits;
metrics.emDescent *= mPixelsToAppUnits;
metrics.maxHeight *= mPixelsToAppUnits;
metrics.maxAscent *= mPixelsToAppUnits;
metrics.maxDescent *= mPixelsToAppUnits;
metrics.maxAdvance *= mPixelsToAppUnits;
metrics.aveCharWidth *= mPixelsToAppUnits;
metrics.spaceWidth *= mPixelsToAppUnits;
metrics.xHeight *= mAppUnitsPerDevUnit;
metrics.superscriptOffset *= mAppUnitsPerDevUnit;
metrics.subscriptOffset *= mAppUnitsPerDevUnit;
metrics.strikeoutSize *= mAppUnitsPerDevUnit;
metrics.strikeoutOffset *= mAppUnitsPerDevUnit;
metrics.underlineSize *= mAppUnitsPerDevUnit;
metrics.underlineOffset *= mAppUnitsPerDevUnit;
metrics.height *= mAppUnitsPerDevUnit;
metrics.internalLeading *= mAppUnitsPerDevUnit;
metrics.externalLeading *= mAppUnitsPerDevUnit;
metrics.emHeight *= mAppUnitsPerDevUnit;
metrics.emAscent *= mAppUnitsPerDevUnit;
metrics.emDescent *= mAppUnitsPerDevUnit;
metrics.maxHeight *= mAppUnitsPerDevUnit;
metrics.maxAscent *= mAppUnitsPerDevUnit;
metrics.maxDescent *= mAppUnitsPerDevUnit;
metrics.maxAdvance *= mAppUnitsPerDevUnit;
metrics.aveCharWidth *= mAppUnitsPerDevUnit;
metrics.spaceWidth *= mAppUnitsPerDevUnit;
return metrics;
}

Просмотреть файл

@ -101,13 +101,14 @@ static PRUint32 ComputeFlags(PRBool aIsRTL, PRBool aEnableSpacing)
gfxTextRun*
gfxTextRunCache::GetOrMakeTextRun (gfxContext* aContext, gfxFontGroup *aFontGroup,
const PRUnichar *aString, PRUint32 aLength, gfxFloat aDevToApp,
PRBool aIsRTL, PRBool aEnableSpacing, PRBool *aCallerOwns)
const PRUnichar *aString, PRUint32 aLength,
PRUint32 aAppUnitsPerDevUnit, PRBool aIsRTL,
PRBool aEnableSpacing, PRBool *aCallerOwns)
{
gfxSkipChars skipChars;
// Choose pessimistic flags since we don't want to bother analyzing the string
gfxTextRunFactory::Parameters params =
{ aContext, nsnull, nsnull, &skipChars, nsnull, 0, aDevToApp,
{ aContext, nsnull, nsnull, &skipChars, nsnull, 0, aAppUnitsPerDevUnit,
ComputeFlags(aIsRTL, aEnableSpacing) };
gfxTextRun* tr = nsnull;
@ -125,7 +126,7 @@ gfxTextRunCache::GetOrMakeTextRun (gfxContext* aContext, gfxFontGroup *aFontGrou
// Check that this matches what we wanted. If it doesn't, we leave
// this cache entry alone and return a fresh, caller-owned textrun
// below.
if (cachedTR->GetPixelsToAppUnits() == aDevToApp &&
if (cachedTR->GetAppUnitsPerDevUnit() == aAppUnitsPerDevUnit &&
cachedTR->IsRightToLeft() == aIsRTL) {
entry->Used();
tr = cachedTR;
@ -156,13 +157,14 @@ gfxTextRunCache::GetOrMakeTextRun (gfxContext* aContext, gfxFontGroup *aFontGrou
gfxTextRun*
gfxTextRunCache::GetOrMakeTextRun (gfxContext* aContext, gfxFontGroup *aFontGroup,
const char *aString, PRUint32 aLength, gfxFloat aDevToApp,
PRBool aIsRTL, PRBool aEnableSpacing, PRBool *aCallerOwns)
const char *aString, PRUint32 aLength,
PRUint32 aAppUnitsPerDevUnit, PRBool aIsRTL,
PRBool aEnableSpacing, PRBool *aCallerOwns)
{
gfxSkipChars skipChars;
// Choose pessimistic flags since we don't want to bother analyzing the string
gfxTextRunFactory::Parameters params =
{ aContext, nsnull, nsnull, &skipChars, nsnull, 0, aDevToApp,
{ aContext, nsnull, nsnull, &skipChars, nsnull, 0, aAppUnitsPerDevUnit,
ComputeFlags(aIsRTL, aEnableSpacing) };
const PRUint8* str = NS_REINTERPRET_CAST(const PRUint8*, aString);
@ -181,7 +183,7 @@ gfxTextRunCache::GetOrMakeTextRun (gfxContext* aContext, gfxFontGroup *aFontGrou
// Check that this matches what we wanted. If it doesn't, we leave
// this cache entry alone and return a fresh, caller-owned textrun
// below.
if (cachedTR->GetPixelsToAppUnits() == aDevToApp &&
if (cachedTR->GetAppUnitsPerDevUnit() == aAppUnitsPerDevUnit &&
cachedTR->IsRightToLeft() == aIsRTL) {
entry->Used();
tr = cachedTR;

Просмотреть файл

@ -626,7 +626,7 @@ gfxWrapperTextRun::SetupSpacingFromProvider(PropertyProvider* aProvider)
for (i = 0; i < mLength; ++i) {
NS_ASSERTION(spacing.Elements()[i].mBefore == 0,
"Can't handle before-spacing!");
gfxFloat nextOffset = offset + spacing.Elements()[i].mAfter/mPixelsToAppUnits;
gfxFloat nextOffset = offset + spacing.Elements()[i].mAfter/mAppUnitsPerDevUnit;
spaceArray.AppendElement(ROUND(nextOffset) - ROUND(offset));
offset = nextOffset;
}
@ -642,7 +642,7 @@ gfxWrapperTextRun::Draw(gfxContext *aContext, gfxPoint aPt,
{
NS_ASSERTION(aStart == 0 && aLength == mLength, "Can't handle substrings");
SetupSpacingFromProvider(aBreakProvider);
gfxPoint pt(aPt.x/mPixelsToAppUnits, aPt.y/mPixelsToAppUnits);
gfxPoint pt(aPt.x/mAppUnitsPerDevUnit, aPt.y/mAppUnitsPerDevUnit);
return mInner.Draw(mContext, pt);
}
@ -652,7 +652,7 @@ gfxWrapperTextRun::GetAdvanceWidth(PRUint32 aStart, PRUint32 aLength,
{
NS_ASSERTION(aStart == 0 && aLength == mLength, "Can't handle substrings");
SetupSpacingFromProvider(aBreakProvider);
return mInner.Measure(mContext)*mPixelsToAppUnits;
return mInner.Measure(mContext)*mAppUnitsPerDevUnit;
}
gfxTextRun *

Просмотреть файл

@ -6205,22 +6205,6 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsFrameConstructorState& aState,
PRBool aIsRoot,
nsIFrame*& aNewFrame)
{
// Check to see the type of parent frame so we know whether we need to
// turn off/on scaling for the scrollbars
//
// If the parent is a viewportFrame then we are the scrollbars for the UI
// if not then we are scrollbars inside the document.
PRBool noScalingOfTwips = PR_FALSE;
PRBool isPrintPreview =
aState.mPresContext->Type() == nsPresContext::eContext_PrintPreview;
if (isPrintPreview) {
noScalingOfTwips = aParentFrame->GetType() == nsGkAtoms::viewportFrame;
if (noScalingOfTwips) {
aState.mPresContext->SetScalingOfTwips(PR_FALSE);
}
}
nsIFrame* parentFrame = nsnull;
nsIFrame* gfxScrollFrame = aNewFrame;
@ -6262,11 +6246,7 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsFrameConstructorState& aState,
gfxScrollFrame->SetInitialChildList(nsnull, anonymousItems.childList);
}
if (isPrintPreview && noScalingOfTwips) {
aState.mPresContext->SetScalingOfTwips(PR_TRUE);
}
return aScrolledChildStyle;;
return aScrolledChildStyle;
}
void

Просмотреть файл

@ -1711,7 +1711,7 @@ void nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
}
}
/* Get our conversion values */
nscoord twipsPerPixel = NSIntPixelsToTwips(1, aPresContext->PixelsToTwips());
nscoord twipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
static PRUint8 sideOrder[] = { NS_SIDE_BOTTOM, NS_SIDE_LEFT, NS_SIDE_TOP, NS_SIDE_RIGHT };
nscolor sideColor;
@ -2072,7 +2072,7 @@ nscoord width, offset;
// Draw all the other sides
nscoord twipsPerPixel = NSIntPixelsToTwips(1, aPresContext->PixelsToTwips());
PRInt32 appUnitsPerPixel = aPresContext->DevPixelsToAppUnits(1);
// default to current color in case it is invert color
// and the platform does not support that
@ -2095,25 +2095,25 @@ nscoord width, offset;
outlineStyle,
outlineColor,
bgColor->mBackgroundColor, outside, inside, aSkipSides,
twipsPerPixel, aGap);
appUnitsPerPixel, aGap);
DrawSide(aRenderingContext, NS_SIDE_LEFT,
outlineStyle,
outlineColor,
bgColor->mBackgroundColor,outside, inside,aSkipSides,
twipsPerPixel, aGap);
appUnitsPerPixel, aGap);
DrawSide(aRenderingContext, NS_SIDE_TOP,
outlineStyle,
outlineColor,
bgColor->mBackgroundColor,outside, inside,aSkipSides,
twipsPerPixel, aGap);
appUnitsPerPixel, aGap);
DrawSide(aRenderingContext, NS_SIDE_RIGHT,
outlineStyle,
outlineColor,
bgColor->mBackgroundColor,outside, inside,aSkipSides,
twipsPerPixel, aGap);
appUnitsPerPixel, aGap);
if(modeChanged ) {
aRenderingContext.SetPenMode(nsPenMode_kNone);
@ -2161,10 +2161,7 @@ void nsCSSRendering::PaintBorderEdges(nsPresContext* aPresContext,
DrawDashedSegments(aRenderingContext, aBorderArea, aBorderEdges, aSkipSides, aGap);
// Draw all the other sides
nscoord twipsPerPixel;
float p2t;
p2t = aPresContext->PixelsToTwips();
twipsPerPixel = (nscoord) p2t;/* XXX huh!*/
nscoord appUnitsPerPixel = nsPresContext::AppUnitsPerCSSPixel();
if (0 == (aSkipSides & (1<<NS_SIDE_TOP))) {
PRInt32 segmentCount = aBorderEdges->mEdges[NS_SIDE_TOP].Count();
@ -2187,7 +2184,7 @@ void nsCSSRendering::PaintBorderEdges(nsPresContext* aPresContext,
borderEdge->mColor,
bgColor->mBackgroundColor,
inside, outside,aSkipSides,
twipsPerPixel, aGap);
appUnitsPerPixel, aGap);
}
}
if (0 == (aSkipSides & (1<<NS_SIDE_LEFT))) {
@ -2209,7 +2206,7 @@ void nsCSSRendering::PaintBorderEdges(nsPresContext* aPresContext,
borderEdge->mColor,
bgColor->mBackgroundColor,
inside, outside, aSkipSides,
twipsPerPixel, aGap);
appUnitsPerPixel, aGap);
}
}
if (0 == (aSkipSides & (1<<NS_SIDE_BOTTOM))) {
@ -2234,7 +2231,7 @@ void nsCSSRendering::PaintBorderEdges(nsPresContext* aPresContext,
borderEdge->mColor,
bgColor->mBackgroundColor,
inside, outside,aSkipSides,
twipsPerPixel, aGap);
appUnitsPerPixel, aGap);
}
}
if (0 == (aSkipSides & (1<<NS_SIDE_RIGHT))) {
@ -2266,7 +2263,7 @@ void nsCSSRendering::PaintBorderEdges(nsPresContext* aPresContext,
borderEdge->mColor,
bgColor->mBackgroundColor,
inside, outside,aSkipSides,
twipsPerPixel, aGap);
appUnitsPerPixel, aGap);
}
}
}
@ -2848,10 +2845,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
image->GetWidth(&imageSize.width);
image->GetHeight(&imageSize.height);
float p2t;
p2t = aPresContext->ScaledPixelsToTwips();
imageSize.width = NSIntPixelsToTwips(imageSize.width, p2t);
imageSize.height = NSIntPixelsToTwips(imageSize.height, p2t);
imageSize.width = nsPresContext::CSSPixelsToAppUnits(imageSize.width);
imageSize.height = nsPresContext::CSSPixelsToAppUnits(imageSize.height);
req = nsnull;
@ -3170,6 +3165,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
// Take the intersection again to paint only the required area.
nsRect absTileRect = tileRect + aBorderArea.TopLeft();
nsRect drawRect;
if (drawRect.IntersectRect(absTileRect, dirtyRect)) {
// Note that due to the way FindTileStart works we're guaranteed
@ -3299,12 +3295,9 @@ nsCSSRendering::PaintRoundedBackground(nsPresContext* aPresContext,
nsFloatPoint thePath[MAXPATHSIZE];
static nsPoint polyPath[MAXPOLYPATHSIZE];
PRInt16 np;
nscoord twipsPerPixel;
float p2t;
// needed for our border thickness
p2t = aPresContext->PixelsToTwips();
twipsPerPixel = NSToCoordRound(p2t);
nscoord appUnitsPerPixel = nsPresContext::AppUnitsPerCSSPixel();
nscolor color = aColor.mBackgroundColor;
if (!aCanPaintNonWhite) {
@ -3325,7 +3318,8 @@ nsCSSRendering::PaintRoundedBackground(nsPresContext* aPresContext,
}
// set the rounded rect up, and let'er rip
outerPath.Set(aBgClipArea.x,aBgClipArea.y,aBgClipArea.width,aBgClipArea.height,aTheRadius,twipsPerPixel);
outerPath.Set(aBgClipArea.x, aBgClipArea.y, aBgClipArea.width,
aBgClipArea.height, aTheRadius, appUnitsPerPixel);
outerPath.GetRoundedBorders(UL,UR,LL,LR);
// BUILD THE ENTIRE OUTSIDE PATH
@ -3407,8 +3401,6 @@ nsCSSRendering::PaintRoundedBorder(nsPresContext* aPresContext,
nsFloatPoint thePath[MAXPATHSIZE];
PRInt16 np;
nsMargin border;
nscoord twipsPerPixel,qtwips;
float p2t;
NS_ASSERTION((aIsOutline && aOutlineStyle) || (!aIsOutline && aBorderStyle), "null params not allowed");
if (!aIsOutline) {
@ -3429,13 +3421,11 @@ nsCSSRendering::PaintRoundedBorder(nsPresContext* aPresContext,
}
// needed for our border thickness
twipsPerPixel = NSIntPixelsToTwips(1, aPresContext->PixelsToTwips());
nscoord appUnitsPerPixel = aPresContext->DevPixelsToAppUnits(1);
nscoord quarterPixel = appUnitsPerPixel / 4;
// Base our thickness check on the segment being less than a pixel and 1/2
qtwips = twipsPerPixel >> 2;
//qtwips = twipsPerPixel;
outerPath.Set(aBorderArea.x,aBorderArea.y,aBorderArea.width,aBorderArea.height,aBorderRadius,twipsPerPixel);
outerPath.Set(aBorderArea.x, aBorderArea.y, aBorderArea.width,
aBorderArea.height, aBorderRadius, appUnitsPerPixel);
outerPath.GetRoundedBorders(UL,UR,LL,LR);
outerPath.CalcInsetCurves(IUL,IUR,ILL,ILR,border);
@ -3459,7 +3449,8 @@ nsCSSRendering::PaintRoundedBorder(nsPresContext* aPresContext,
thePath[np++].MoveTo(Icr2.mAnc2.x, Icr2.mAnc2.y);
thePath[np++].MoveTo(Icr2.mCon.x, Icr2.mCon.y);
thePath[np++].MoveTo(Icr2.mAnc1.x, Icr2.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_TOP,border,qtwips, aIsOutline);
RenderSide(thePath, aRenderingContext, aBorderStyle, aOutlineStyle,
aStyleContext, NS_SIDE_TOP, border, quarterPixel, aIsOutline);
}
// RIGHT LINE ----------------------------------------------------------------
LR.MidPointDivide(&cr2,&cr3);
@ -3479,7 +3470,8 @@ nsCSSRendering::PaintRoundedBorder(nsPresContext* aPresContext,
thePath[np++].MoveTo(Icr4.mAnc2.x,Icr4.mAnc2.y);
thePath[np++].MoveTo(Icr4.mCon.x, Icr4.mCon.y);
thePath[np++].MoveTo(Icr4.mAnc1.x,Icr4.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_RIGHT,border,qtwips, aIsOutline);
RenderSide(thePath, aRenderingContext, aBorderStyle, aOutlineStyle,
aStyleContext, NS_SIDE_RIGHT, border, quarterPixel, aIsOutline);
}
// bottom line ----------------------------------------------------------------
@ -3500,7 +3492,8 @@ nsCSSRendering::PaintRoundedBorder(nsPresContext* aPresContext,
thePath[np++].MoveTo(Icr3.mAnc2.x, Icr3.mAnc2.y);
thePath[np++].MoveTo(Icr3.mCon.x, Icr3.mCon.y);
thePath[np++].MoveTo(Icr3.mAnc1.x, Icr3.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_BOTTOM,border,qtwips, aIsOutline);
RenderSide(thePath, aRenderingContext, aBorderStyle, aOutlineStyle,
aStyleContext, NS_SIDE_BOTTOM, border, quarterPixel, aIsOutline);
}
// left line ----------------------------------------------------------------
if(0==border.left)
@ -3521,7 +3514,8 @@ nsCSSRendering::PaintRoundedBorder(nsPresContext* aPresContext,
thePath[np++].MoveTo(Icr4.mCon.x, Icr4.mCon.y);
thePath[np++].MoveTo(Icr4.mAnc1.x, Icr4.mAnc1.y);
RenderSide(thePath,aRenderingContext,aBorderStyle,aOutlineStyle,aStyleContext,NS_SIDE_LEFT,border,qtwips, aIsOutline);
RenderSide(thePath, aRenderingContext, aBorderStyle, aOutlineStyle,
aStyleContext, NS_SIDE_LEFT, border, quarterPixel, aIsOutline);
}
@ -4196,7 +4190,7 @@ nsCSSRendering::DrawTableBorderSegment(nsIRenderingContext& aContext,
aContext.SetColor (aBorderColor);
PRBool horizontal = ((NS_SIDE_TOP == aStartBevelSide) || (NS_SIDE_BOTTOM == aStartBevelSide));
nscoord twipsPerPixel = NSIntPixelsToTwips(1, aPixelsToTwips);
nscoord twipsPerPixel = NSIntPixelsToAppUnits(1, aPixelsToTwips);
PRBool ridgeGroove = NS_STYLE_BORDER_STYLE_RIDGE;
if ((twipsPerPixel >= aBorder.width) || (twipsPerPixel >= aBorder.height) ||

Просмотреть файл

@ -125,12 +125,10 @@ NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell)
mShowDuringSelection = tempInt ? PR_TRUE : PR_FALSE;
}
float tDevUnitsToTwips;
tDevUnitsToTwips = presContext->DeviceContext()->DevUnitsToTwips();
mCaretTwipsWidth = (nscoord)(tDevUnitsToTwips * (float)caretPixelsWidth);
mBidiIndicatorTwipsSize = (nscoord)(tDevUnitsToTwips * (float)kMinBidiIndicatorPixels);
if (mBidiIndicatorTwipsSize < mCaretTwipsWidth) {
mBidiIndicatorTwipsSize = mCaretTwipsWidth;
mCaretWidth = presContext->DevPixelsToAppUnits(caretPixelsWidth);
mBidiIndicatorSize = presContext->DevPixelsToAppUnits(kMinBidiIndicatorPixels);
if (mBidiIndicatorSize < mCaretWidth) {
mBidiIndicatorSize = mCaretWidth;
}
// get the selection from the pres shell, and set ourselves up as a selection
@ -350,7 +348,7 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType,
outCoordinates->x = viewOffset.x;
outCoordinates->y = viewOffset.y;
outCoordinates->height = theFrame->GetSize().height;
outCoordinates->width = mCaretTwipsWidth;
outCoordinates->width = mCaretWidth;
return NS_OK;
}
@ -1049,7 +1047,7 @@ nsresult nsCaret::UpdateCaretRects(nsIFrame* aFrame, PRInt32 aFrameOffset)
}
mCaretRect += framePos;
mCaretRect.width = mCaretTwipsWidth;
mCaretRect.width = mCaretWidth;
// on RTL frames the right edge of mCaretRect must be equal to framePos
const nsStyleVisibility* vis = aFrame->GetStyleVisibility();
@ -1106,10 +1104,10 @@ nsresult nsCaret::UpdateHookRect(nsPresContext* aPresContext)
// The height of the hook rectangle is the same as the width of the caret
// rectangle.
mHookRect.SetRect(mCaretRect.x + ((isCaretRTL) ?
mBidiIndicatorTwipsSize * -1 :
mBidiIndicatorSize * -1 :
mCaretRect.width),
mCaretRect.y + mBidiIndicatorTwipsSize,
mBidiIndicatorTwipsSize,
mCaretRect.y + mBidiIndicatorSize,
mBidiIndicatorSize,
mCaretRect.width);
}
#endif //IBMBIDI

Просмотреть файл

@ -165,8 +165,8 @@ protected:
PRUint32 mBlinkRate; // time for one cyle (off then on), in milliseconds
nscoord mCaretTwipsWidth; // caret width in twips. this gets calculated laziiy
nscoord mBidiIndicatorTwipsSize; // width and height of bidi indicator
nscoord mCaretWidth; // caret width. this gets calculated laziiy
nscoord mBidiIndicatorSize; // width and height of bidi indicator
PRPackedBool mVisible; // is the caret blinking
PRPackedBool mDrawn; // this should be mutable

Просмотреть файл

@ -808,17 +808,17 @@ void nsDisplayOpacity::Paint(nsDisplayListBuilder* aBuilder,
nsCOMPtr<nsIDeviceContext> devCtx;
aCtx->GetDeviceContext(*getter_AddRefs(devCtx));
float t2p = devCtx->AppUnitsToDevUnits();
float a2p = 1.0f / devCtx->AppUnitsPerDevPixel();
nsRefPtr<gfxContext> ctx = (gfxContext*)aCtx->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
ctx->Save();
ctx->NewPath();
ctx->Rectangle(gfxRect(bounds.x * t2p,
bounds.y * t2p,
bounds.width * t2p,
bounds.height * t2p),
ctx->Rectangle(gfxRect(bounds.x * a2p,
bounds.y * a2p,
bounds.width * a2p,
bounds.height * a2p),
PR_TRUE);
ctx->Clip();

Просмотреть файл

@ -686,12 +686,8 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow)
nsRect bounds;
mWindow->GetBounds(bounds);
float p2t;
p2t = mPresContext->PixelsToTwips();
nscoord width = NSIntPixelsToTwips(bounds.width, p2t);
nscoord height = NSIntPixelsToTwips(bounds.height, p2t);
nscoord width = mPresContext->DevPixelsToAppUnits(bounds.width);
nscoord height = mPresContext->DevPixelsToAppUnits(bounds.height);
mViewManager->DisableRefresh();
mViewManager->SetWindowDimensions(width, height);
@ -802,7 +798,6 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
// Clear PrintPreview Alternate Device
if (mDeviceContext) {
mDeviceContext->SetAltDevice(nsnull);
mDeviceContext->SetCanonicalPixelScale(1.0);
}
#endif
@ -924,9 +919,8 @@ DocumentViewerImpl::DumpContentToPPM(const char* aFileName)
mViewManager->GetRootView(view);
}
nsRect r = view->GetBounds() - view->GetPosition();
float p2t = mPresContext->PixelsToTwips();
// Limit the bitmap size to 5000x5000
nscoord twipLimit = NSIntPixelsToTwips(5000, p2t);
nscoord twipLimit = mPresContext->DevPixelsToAppUnits(5000);
if (r.height > twipLimit)
r.height = twipLimit;
if (r.width > twipLimit)
@ -950,9 +944,8 @@ DocumentViewerImpl::DumpContentToPPM(const char* aFileName)
if (!surface) {
status = "NOSURFACE";
} else {
float t2p = mPresContext->TwipsToPixels();
PRUint32 width = NSTwipsToIntPixels(view->GetBounds().width, t2p);
PRUint32 height = NSTwipsToIntPixels(view->GetBounds().height, t2p);
PRUint32 width = mPresContext->AppUnitsToDevPixels(view->GetBounds().width);
PRUint32 height = mPresContext->AppUnitsToDevPixels(view->GetBounds().height);
PRUint8* data;
PRInt32 rowLen, rowSpan;
@ -2318,9 +2311,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
nsIDeviceContext *dx = mPresContext->DeviceContext();
nsRect tbounds = aBounds;
float p2t;
p2t = mPresContext->PixelsToTwips();
tbounds *= p2t;
tbounds *= mPresContext->AppUnitsPerDevPixel();
// Initialize the view manager with an offset. This allows the viewmanager
// to manage a coordinate space offset from (0,0)
@ -3150,7 +3141,6 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent()
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
PRInt32 width, height;
float pixelScale;
// so how big is it?
nsRect shellArea = presContext->GetVisibleArea();
@ -3159,9 +3149,8 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent()
// Protect against bogus returns here
return NS_ERROR_FAILURE;
}
pixelScale = presContext->TwipsToPixels();
width = PRInt32((float)shellArea.width*pixelScale);
height = PRInt32((float)shellArea.height*pixelScale);
width = presContext->AppUnitsToDevPixels(shellArea.width);
height = presContext->AppUnitsToDevPixels(shellArea.height);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));

Просмотреть файл

@ -196,12 +196,10 @@ NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer,
nsRect r(*dirtyRect);
float p2t;
p2t = mPresContext->PixelsToTwips();
r.x = NSIntPixelsToTwips(r.x, p2t);
r.y = NSIntPixelsToTwips(r.y, p2t);
r.width = NSIntPixelsToTwips(r.width, p2t);
r.height = NSIntPixelsToTwips(r.height, p2t);
r.x = nsPresContext::CSSPixelsToAppUnits(r.x);
r.y = nsPresContext::CSSPixelsToAppUnits(r.y);
r.width = nsPresContext::CSSPixelsToAppUnits(r.width);
r.height = nsPresContext::CSSPixelsToAppUnits(r.height);
RedrawDirtyFrame(&r);

Просмотреть файл

@ -658,10 +658,9 @@ nsLayoutUtils::TranslateWidgetToView(nsPresContext* aPresContext,
nsPoint viewToWidget;
nsIWidget* wid = baseView->GetNearestWidget(&viewToWidget);
NS_ASSERTION(aWidget == wid, "Clashing widgets");
float pixelsToTwips = aPresContext->PixelsToTwips();
nsPoint refPointTwips(NSIntPixelsToTwips(aPt.x, pixelsToTwips),
NSIntPixelsToTwips(aPt.y, pixelsToTwips));
return refPointTwips - viewToWidget - aView->GetOffsetTo(baseView);
nsPoint refPointAppUnits(aPresContext->DevPixelsToAppUnits(aPt.x),
aPresContext->DevPixelsToAppUnits(aPt.y));
return refPointAppUnits - viewToWidget - aView->GetOffsetTo(baseView);
}
// Combine aNewBreakType with aOrigBreakType, but limit the break types
@ -1397,9 +1396,7 @@ nsLayoutUtils::IntrinsicForContainer(nsIRenderingContext *aRenderingContext,
GetMinimumWidgetSize(aRenderingContext, aFrame, disp->mAppearance,
&size, &canOverride);
// GMWS() returns size in pixels, we need to convert it back to twips
float p2t = presContext->ScaledPixelsToTwips();
nscoord themeWidth = NSIntPixelsToTwips(size.width, p2t);
nscoord themeWidth = presContext->DevPixelsToAppUnits(size.width);
// GMWS() returns a border-box width
themeWidth += offsets.hMargin;

Просмотреть файл

@ -143,12 +143,11 @@ IsVisualCharset(const nsCString& aCharset)
#endif // IBMBIDI
PR_STATIC_CALLBACK(PRBool) destroy_loads(nsHashKey *aKey, void *aData, void* closure)
PR_STATIC_CALLBACK(PLDHashOperator)
destroy_loads(const PRUint32& aKey, nsCOMPtr<nsImageLoader>& aData, void* closure)
{
nsISupports *sup = NS_REINTERPRET_CAST(nsISupports*, aData);
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, sup);
loader->Destroy();
return PR_TRUE;
aData->Destroy();
return PL_DHASH_NEXT;
}
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
@ -163,20 +162,21 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
mPageSize(-1, -1),
mViewportStyleOverflow(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO),
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
// Font sizes default to zero; they will be set in GetFontPreferences
mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
NS_FONT_WEIGHT_NORMAL, 0, 0),
mDefaultFixedFont("monospace", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
NS_FONT_WEIGHT_NORMAL, 0, 0),
mDefaultSerifFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
NS_FONT_WEIGHT_NORMAL, 0, 0),
mDefaultSansSerifFont("sans-serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
NS_FONT_WEIGHT_NORMAL, 0, 0),
mDefaultMonospaceFont("monospace", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
NS_FONT_WEIGHT_NORMAL, 0, 0),
mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
NS_FONT_WEIGHT_NORMAL, 0, 0),
mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
NS_FONT_WEIGHT_NORMAL, 0, 0),
mCanPaginatedScroll(PR_FALSE),
mIsRootPaginatedDocument(PR_FALSE)
{
@ -226,7 +226,7 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
nsPresContext::~nsPresContext()
{
mImageLoaders.Enumerate(destroy_loads);
mImageLoaders.Enumerate(destroy_loads, nsnull);
NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer");
SetShell(nsnull);
@ -326,9 +326,8 @@ nsPresContext::GetFontPreferences()
font.minimum-size.[langGroup] = integer - settable by the user
*/
float p2t = ScaledPixelsToTwips();
mDefaultVariableFont.size = NSFloatPixelsToTwips((float)16, p2t);
mDefaultFixedFont.size = NSFloatPixelsToTwips((float)13, p2t);
mDefaultVariableFont.size = CSSPixelsToAppUnits(16);
mDefaultFixedFont.size = CSSPixelsToAppUnits(13);
const char *langGroup;
mLangGroup->GetUTF8String(&langGroup);
@ -362,10 +361,10 @@ nsPresContext::GetFontPreferences()
PRInt32 size = nsContentUtils::GetIntPref(pref.get());
if (unit == eUnit_px) {
mMinimumFontSize = NSFloatPixelsToTwips((float)size, p2t);
mMinimumFontSize = CSSPixelsToAppUnits(size);
}
else if (unit == eUnit_pt) {
mMinimumFontSize = NSIntPointsToTwips(size);
mMinimumFontSize = this->PointsToAppUnits(size);
}
// get attributes specific to each generic font
@ -429,10 +428,10 @@ nsPresContext::GetFontPreferences()
size = nsContentUtils::GetIntPref(pref.get());
if (size > 0) {
if (unit == eUnit_px) {
font->size = NSFloatPixelsToTwips((float)size, p2t);
font->size = nsPresContext::CSSPixelsToAppUnits(size);
}
else if (unit == eUnit_pt) {
font->size = NSIntPointsToTwips(size);
font->size = this->PointsToAppUnits(size);
}
}
@ -698,6 +697,9 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
mDeviceContext = aDeviceContext;
NS_ADDREF(mDeviceContext);
if (!mImageLoaders.Init())
return NS_ERROR_OUT_OF_MEMORY;
// Get the look and feel service here; default colors will be initialized
// from calling GetUserPreferences() when we get a presshell.
nsresult rv = CallGetService(kLookAndFeelCID, &mLookAndFeel);
@ -750,10 +752,9 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
mInitialized = PR_TRUE;
#endif
float pixelsToTwips = ScaledPixelsToTwips();
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THIN] = NSIntPixelsToTwips(1, pixelsToTwips);
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_MEDIUM] = NSIntPixelsToTwips(3, pixelsToTwips);
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THICK] = NSIntPixelsToTwips(5, pixelsToTwips);
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THIN] = CSSPixelsToAppUnits(1);
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_MEDIUM] = CSSPixelsToAppUnits(3);
mBorderWidthTable[NS_STYLE_BORDER_WIDTH_THICK] = CSSPixelsToAppUnits(5);
return NS_OK;
}
@ -913,13 +914,12 @@ static void SetImgAnimModeOnImgReq(imgIRequest* aImgReq, PRUint16 aMode)
}
// Enumeration call back for HashTable
PR_STATIC_CALLBACK(PRBool) set_animation_mode(nsHashKey *aKey, void *aData, void* closure)
PR_STATIC_CALLBACK(PLDHashOperator)
set_animation_mode(const PRUint32& aKey, nsCOMPtr<nsImageLoader>& aData, void* closure)
{
nsISupports *sup = NS_REINTERPRET_CAST(nsISupports*, aData);
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, sup);
imgIRequest* imgReq = loader->GetRequest();
imgIRequest* imgReq = aData->GetRequest();
SetImgAnimModeOnImgReq(imgReq, (PRUint16)NS_PTR_TO_INT32(closure));
return PR_TRUE;
return PL_DHASH_NEXT;
}
// IMPORTANT: Assumption is that all images for a Presentation
@ -1035,47 +1035,6 @@ nsPresContext::GetDefaultFontExternal(PRUint8 aFontID) const
return GetDefaultFontInternal(aFontID);
}
float
nsPresContext::TwipsToPixelsForFonts() const
{
float app2dev;
#ifdef NS_PRINT_PREVIEW
// If an alternative DC is available we want to use
// it to get the scaling factor for fonts. Usually, the AltDC
// is a printing DC so therefore we need to get the printer's
// scaling values for calculating the font heights
nsCOMPtr<nsIDeviceContext> altDC;
mDeviceContext->GetAltDevice(getter_AddRefs(altDC));
if (altDC) {
app2dev = altDC->AppUnitsToDevUnits();
} else {
app2dev = mDeviceContext->AppUnitsToDevUnits();
}
#else
app2dev = mDeviceContext->AppUnitsToDevUnits();
#endif
return app2dev;
}
float
nsPresContext::ScaledPixelsToTwips() const
{
float scale;
float p2t;
p2t = mDeviceContext->DevUnitsToAppUnits();
if (mDoScaledTwips) {
mDeviceContext->GetCanonicalPixelScale(scale);
scale = p2t * scale;
} else {
scale = p2t;
}
return scale;
}
void
nsPresContext::SetTextZoomExternal(float aZoom)
{
@ -1086,25 +1045,21 @@ imgIRequest*
nsPresContext::LoadImage(imgIRequest* aImage, nsIFrame* aTargetFrame)
{
// look and see if we have a loader for the target frame.
nsVoidKey key(aTargetFrame);
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, mImageLoaders.Get(&key)); // addrefs
nsCOMPtr<nsImageLoader> loader;
mImageLoaders.Get(NS_PTR_TO_INT32(aTargetFrame), getter_AddRefs(loader));
if (!loader) {
loader = new nsImageLoader();
if (!loader)
return nsnull;
NS_ADDREF(loader); // new
loader->Init(aTargetFrame, this);
mImageLoaders.Put(&key, loader);
mImageLoaders.Put(NS_PTR_TO_INT32(aTargetFrame), loader);
}
loader->Load(aImage);
imgIRequest *request = loader->GetRequest();
NS_RELEASE(loader);
return request;
}
@ -1113,14 +1068,13 @@ nsPresContext::LoadImage(imgIRequest* aImage, nsIFrame* aTargetFrame)
void
nsPresContext::StopImagesFor(nsIFrame* aTargetFrame)
{
nsVoidKey key(aTargetFrame);
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, mImageLoaders.Get(&key)); // addrefs
nsCOMPtr<nsImageLoader> loader;
mImageLoaders.Get(NS_PTR_TO_INT32(aTargetFrame), getter_AddRefs(loader));
if (loader) {
loader->Destroy();
NS_RELEASE(loader);
mImageLoaders.Remove(&key);
mImageLoaders.Remove(NS_PTR_TO_INT32(aTargetFrame));
}
}

Просмотреть файл

@ -48,7 +48,6 @@
#include "nsIPresShell.h"
#include "nsRect.h"
#include "nsIDeviceContext.h"
#include "nsHashtable.h"
#include "nsFont.h"
#include "nsIWeakReference.h"
#include "nsITheme.h"
@ -60,6 +59,8 @@
#include "nsPropertyTable.h"
#include "nsGkAtoms.h"
#include "nsIDocument.h"
#include "nsInterfaceHashtable.h"
class nsImageLoader;
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
@ -425,29 +426,15 @@ public:
{ mIsRootPaginatedDocument = aIsRootPaginatedDocument; }
/**
* Conversion from device pixels to twips.
* WARNING: The misuse of this function to convert CSS pixels to twips
* will cause problems during printing
*/
float PixelsToTwips() const { return mDeviceContext->DevUnitsToAppUnits(); }
* Get/set the print scaling level; used by nsPageFrame to scale up
* pages. Set safe to call before reflow, get guaranteed to be set
* properly after reflow.
*/
float TwipsToPixels() const { return mDeviceContext->AppUnitsToDevUnits(); }
float GetPageScale() { return mPageScale; }
void SetPageScale(float aScale) { mPageScale = aScale; }
NS_HIDDEN_(float) TwipsToPixelsForFonts() const;
//XXX this is probably not an ideal name. MMP
/**
* Do CSS pixels to twips conversion taking into account
* differing size of a "pixel" from device to device.
*/
NS_HIDDEN_(float) ScaledPixelsToTwips() const;
/* Convenience method for converting one pixel value to twips */
nscoord IntScaledPixelsToTwips(nscoord aPixels) const
{ return NSIntPixelsToTwips(aPixels, ScaledPixelsToTwips()); }
/* Set whether twip scaling is used */
void SetScalingOfTwips(PRBool aOn) { mDoScaledTwips = aOn; }
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
nsIEventStateManager* EventStateManager() { return mEventManager; }
@ -465,7 +452,47 @@ public:
void SetTextZoom(float aZoom) { SetTextZoomExternal(aZoom); }
#endif
static PRInt32 AppUnitsPerCSSPixel() { return nsIDeviceContext::AppUnitsPerCSSPixel(); }
PRInt32 AppUnitsPerDevPixel() const { return mDeviceContext->AppUnitsPerDevPixel(); }
PRInt32 AppUnitsPerInch() const { return mDeviceContext->AppUnitsPerInch(); }
static nscoord CSSPixelsToAppUnits(PRInt32 aPixels)
{ return NSIntPixelsToAppUnits(aPixels,
nsIDeviceContext::AppUnitsPerCSSPixel()); }
static nscoord CSSPixelsToAppUnits(float aPixels)
{ return NSFloatPixelsToAppUnits(aPixels,
nsIDeviceContext::AppUnitsPerCSSPixel()); }
static PRInt32 AppUnitsToIntCSSPixels(nscoord aAppUnits)
{ return NSAppUnitsToIntPixels(aAppUnits,
nsIDeviceContext::AppUnitsPerCSSPixel()); }
static float AppUnitsToFloatCSSPixels(nscoord aAppUnits)
{ return NSAppUnitsToFloatPixels(aAppUnits,
nsIDeviceContext::AppUnitsPerCSSPixel()); }
nscoord DevPixelsToAppUnits(PRInt32 aPixels) const
{ return NSIntPixelsToAppUnits(aPixels,
mDeviceContext->AppUnitsPerDevPixel()); }
PRInt32 AppUnitsToDevPixels(nscoord aAppUnits) const
{ return NSAppUnitsToIntPixels(aAppUnits,
mDeviceContext->AppUnitsPerDevPixel()); }
nscoord TwipsToAppUnits(PRInt32 aTwips) const
{ return NSToCoordRound(NS_TWIPS_TO_INCHES(aTwips) *
mDeviceContext->AppUnitsPerInch()); }
PRInt32 AppUnitsToTwips(nscoord aTwips) const
{ return NS_INCHES_TO_TWIPS((float)aTwips /
mDeviceContext->AppUnitsPerInch()); }
nscoord PointsToAppUnits(float aPoints) const
{ return NSToCoordRound(aPoints * mDeviceContext->AppUnitsPerInch() /
72.0f); }
float AppUnitsToPoints(nscoord aAppUnits) const
{ return (float)aAppUnits / mDeviceContext->AppUnitsPerInch() * 72.0f; }
/**
* Get the language-specific transform type for the current document.
@ -720,7 +747,7 @@ protected:
nsILinkHandler* mLinkHandler; // [WEAK]
nsIAtom* mLangGroup; // [STRONG]
nsSupportsHashtable mImageLoaders;
nsInterfaceHashtable<nsUint32HashKey, nsImageLoader> mImageLoaders;
nsWeakPtr mContainer;
// Only used in the root prescontext (this->RootPresContext() == this)
@ -747,6 +774,7 @@ protected:
nsRect mVisibleArea;
nsSize mPageSize;
float mPageScale;
nscolor mDefaultColor;
nscolor mBackgroundColor;

Просмотреть файл

@ -5023,7 +5023,7 @@ PresShell::RenderOffscreen(nsRect aRect, PRBool aUntrusted,
return NS_ERROR_FAILURE;
nsRect bounds(nsPoint(0, 0), aRect.Size());
bounds.ScaleRoundOut(mPresContext->TwipsToPixels());
bounds.ScaleRoundOut(1.0f / mPresContext->AppUnitsPerDevPixel());
nsIDrawingSurface* surface;
nsresult rv
@ -7195,8 +7195,9 @@ void ReflowCountMgr::PaintCount(const char * aName,
IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(mIndiFrameCounts, key);
if (counter != nsnull && counter->mName.EqualsASCII(aName)) {
aRenderingContext->PushState();
nsFont font("Times", NS_FONT_STYLE_NORMAL,NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(8));
nsFont font("Times", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0,
nsPresContext::CSSPixelsToAppUnits(11));
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(font);
aRenderingContext->SetFont(fm);

Просмотреть файл

@ -524,9 +524,7 @@ nsComboboxControlFrame::PositionDropdown(nsPresContext* aPresContext,
nscoord screenHeightInPixels = 0;
if (NS_SUCCEEDED(nsFormControlFrame::GetScreenHeight(aPresContext, screenHeightInPixels))) {
// Get the height of the dropdown list in pixels.
float t2p;
t2p = aPresContext->TwipsToPixels();
nscoord absoluteDropDownHeight = NSTwipsToIntPixels(dropdownRect.height, t2p);
nscoord absoluteDropDownHeight = aPresContext->AppUnitsToDevPixels(dropdownRect.height);
// Check to see if the drop-down list will go offscreen
if (NS_SUCCEEDED(rv) && ((aAbsolutePixelRect.y + aAbsolutePixelRect.height + absoluteDropDownHeight) > screenHeightInPixels)) {
@ -638,7 +636,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
// First reflow our dropdown so that we know how tall we should be.
ReflowDropdown(aPresContext, aReflowState);
// Get the width of the vertical scrollbar. That will be the width of the
// dropdown button.
nsIScrollableFrame* scrollable;
@ -1391,8 +1389,7 @@ void nsComboboxControlFrame::PaintFocus(nsIRenderingContext& aRenderingContext,
aRenderingContext.SetLineStyle(nsLineStyle_kSolid);
}
//aRenderingContext.DrawRect(clipRect);
float p2t = GetPresContext()->PixelsToTwips();
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
clipRect.width -= onePixel;
clipRect.height -= onePixel;
aRenderingContext.DrawLine(clipRect.x, clipRect.y,

Просмотреть файл

@ -597,9 +597,8 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
mLegendRect.x = contentRect.width - mLegendRect.width + borderPadding.left;
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
float p2t;
p2t = aPresContext->PixelsToTwips();
mLegendRect.x = NSIntPixelsToTwips((nscoord) NSToIntRound((float)(contentRect.width/2 - mLegendRect.width/2 + borderPadding.left) / p2t),p2t);
// Note: rounding removed; there doesn't seem to be any need
mLegendRect.x = contentRect.width / 2 - mLegendRect.width / 2 + borderPadding.left;
break;
}

Просмотреть файл

@ -231,10 +231,8 @@ nsFormControlFrame::GetScreenHeight(nsPresContext* aPresContext,
context->GetRect ( screen );
else
context->GetClientRect(screen);
float devUnits;
devUnits = context->DevUnitsToAppUnits();
aHeight = NSToIntRound(float(screen.height) / devUnits );
aHeight = aPresContext->AppUnitsToDevPixels(screen.height);
return NS_OK;
}
@ -255,12 +253,6 @@ nsFormControlFrame::GetAbsoluteFramePosition(nsPresContext* aPresContext,
aAbsoluteTwipsRect.x = 0;
aAbsoluteTwipsRect.y = 0;
// Get conversions between twips and pixels
float t2p;
float p2t;
t2p = aPresContext->TwipsToPixels();
p2t = aPresContext->PixelsToTwips();
// Start with frame's offset from it it's containing view
nsIView *view = nsnull;
nsPoint frameOffset;
@ -290,8 +282,8 @@ nsFormControlFrame::GetAbsoluteFramePosition(nsPresContext* aPresContext,
// XXX a twip version of this would be really nice here!
widget->WidgetToScreen(zeroRect, absBounds);
// Convert widget coordinates to twips
aAbsoluteTwipsRect.x += NSIntPixelsToTwips(absBounds.x, p2t);
aAbsoluteTwipsRect.y += NSIntPixelsToTwips(absBounds.y, p2t);
aAbsoluteTwipsRect.x += aPresContext->DevPixelsToAppUnits(absBounds.x);
aAbsoluteTwipsRect.y += aPresContext->DevPixelsToAppUnits(absBounds.y);
break;
}
@ -301,11 +293,10 @@ nsFormControlFrame::GetAbsoluteFramePosition(nsPresContext* aPresContext,
// convert to pixel coordinates
if (NS_SUCCEEDED(rv)) {
aAbsolutePixelRect.x = NSTwipsToIntPixels(aAbsoluteTwipsRect.x, t2p);
aAbsolutePixelRect.y = NSTwipsToIntPixels(aAbsoluteTwipsRect.y, t2p);
aAbsolutePixelRect.width = NSTwipsToIntPixels(aAbsoluteTwipsRect.width, t2p);
aAbsolutePixelRect.height = NSTwipsToIntPixels(aAbsoluteTwipsRect.height, t2p);
aAbsolutePixelRect.x = aPresContext->AppUnitsToDevPixels(aAbsoluteTwipsRect.x);
aAbsolutePixelRect.y = aPresContext->AppUnitsToDevPixels(aAbsoluteTwipsRect.y);
aAbsolutePixelRect.width = aPresContext->AppUnitsToDevPixels(aAbsoluteTwipsRect.width);
aAbsolutePixelRect.height = aPresContext->AppUnitsToDevPixels(aAbsoluteTwipsRect.height);
}
return rv;

Просмотреть файл

@ -365,7 +365,7 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsPoint aPt)
nsILookAndFeel::eColor_WidgetSelectForeground :
nsILookAndFeel::eColor_WidgetSelectBackground, color);
nscoord onePixelInTwips = presContext->IntScaledPixelsToTwips(1);
nscoord onePixelInTwips = nsPresContext::CSSPixelsToAppUnits(1);
nsRect dirty;
nscolor colors[] = {color, color, color, color};
@ -714,9 +714,7 @@ nsListControlFrame::ReflowAsDropdown(nsPresContext* aPresContext,
// We can fix these cases later if they actually happen.
nscoord screenHeightInPixels = 0;
if (NS_SUCCEEDED(nsFormControlFrame::GetScreenHeight(aPresContext, screenHeightInPixels))) {
float p2t;
p2t = aPresContext->PixelsToTwips();
nscoord screenHeight = NSIntPixelsToTwips(screenHeightInPixels, p2t);
nscoord screenHeight = aPresContext->DevPixelsToAppUnits(screenHeightInPixels);
nscoord availDropHgt = (screenHeight / 2) - (heightOfARow*2); // approx half screen minus combo size
availDropHgt -= aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;

Просмотреть файл

@ -1317,11 +1317,10 @@ nsTextControlFrame::CalcIntrinsicSize(nsIRenderingContext* aRenderingContext,
// this if charMaxAdvance != charWidth; if they are equal, this is almost
// certainly a fixed-width font.
if (charWidth != charMaxAdvance) {
float p2t;
p2t = presContext->PixelsToTwips();
nscoord internalPadding = PR_MAX(charMaxAdvance - NSToCoordRound(4 * p2t), 0);
// round to a multiple of p2t
nscoord t = NSToCoordRound(p2t);
nscoord internalPadding = PR_MAX(0, charMaxAdvance -
nsPresContext::CSSPixelsToAppUnits(4));
nscoord t = nsPresContext::CSSPixelsToAppUnits(1);
// Round to a multiple of t
nscoord rest = internalPadding % t;
if (rest < t - rest) {
internalPadding -= rest;

Просмотреть файл

@ -5214,7 +5214,7 @@ nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
// needed when prev. float has procentage width
// (maybe is a table flaw that makes table chose to round up
// but I don't want to change that, too risky)
nscoord twp = aState.mPresContext->IntScaledPixelsToTwips(1);
nscoord twp = nsPresContext::CSSPixelsToAppUnits(1);
availWidth -= availWidth % twp;
}

Просмотреть файл

@ -1462,8 +1462,6 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
const nsStyleFont* myFont = GetStyleFont();
nsCOMPtr<nsIFontMetrics> fm = aCX->GetMetricsFor(myFont->mFont);
nscoord bulletSize;
float p2t;
float t2p;
nsAutoString text;
switch (myList->mListStyleType) {
@ -1475,16 +1473,10 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
case NS_STYLE_LIST_STYLE_DISC:
case NS_STYLE_LIST_STYLE_CIRCLE:
case NS_STYLE_LIST_STYLE_SQUARE:
t2p = aCX->TwipsToPixels();
fm->GetMaxAscent(ascent);
bulletSize = NSTwipsToIntPixels(
(nscoord)NSToIntRound(0.8f * (float(ascent) / 2.0f)), t2p);
if (bulletSize < MIN_BULLET_SIZE) {
bulletSize = MIN_BULLET_SIZE;
}
p2t = aCX->PixelsToTwips();
bulletSize = NSIntPixelsToTwips(bulletSize, p2t);
mPadding.bottom = NSIntPixelsToTwips((nscoord) NSToIntRound((float)ascent / (8.0f * p2t)),p2t);
bulletSize = PR_MAX(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
mPadding.bottom = NSToCoordRound(float(ascent) / 8.0f);
aMetrics.width = mPadding.right + bulletSize;
aMetrics.ascent = aMetrics.height = mPadding.bottom + bulletSize;
break;
@ -1610,11 +1602,10 @@ NS_IMETHODIMP nsBulletFrame::OnStartContainer(imgIRequest *aRequest,
aImage->GetWidth(&w);
aImage->GetHeight(&h);
float p2t;
nsPresContext* presContext = GetPresContext();
p2t = presContext->PixelsToTwips();
nsSize newsize(NSIntPixelsToTwips(w, p2t), NSIntPixelsToTwips(h, p2t));
nsSize newsize(nsPresContext::CSSPixelsToAppUnits(w),
nsPresContext::CSSPixelsToAppUnits(h));
if (mIntrinsicSize != newsize) {
mIntrinsicSize = newsize;

Просмотреть файл

@ -721,11 +721,10 @@ nsIFrame::GetUsedBorder() const
presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
mutable_this, disp->mAppearance,
&result);
float p2t = presContext->ScaledPixelsToTwips();
result.top = NSIntPixelsToTwips(result.top, p2t);
result.right = NSIntPixelsToTwips(result.right, p2t);
result.bottom = NSIntPixelsToTwips(result.bottom, p2t);
result.left = NSIntPixelsToTwips(result.left, p2t);
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;
}
@ -752,11 +751,10 @@ nsIFrame::GetUsedPadding() const
mutable_this,
disp->mAppearance,
&padding)) {
float p2t = presContext->ScaledPixelsToTwips();
padding.top = NSIntPixelsToTwips(padding.top, p2t);
padding.right = NSIntPixelsToTwips(padding.right, p2t);
padding.bottom = NSIntPixelsToTwips(padding.bottom, p2t);
padding.left = NSIntPixelsToTwips(padding.left, p2t);
padding.top = presContext->DevPixelsToAppUnits(padding.top);
padding.right = presContext->DevPixelsToAppUnits(padding.right);
padding.bottom = presContext->DevPixelsToAppUnits(padding.bottom);
padding.left = presContext->DevPixelsToAppUnits(padding.left);
return padding;
}
}
@ -959,7 +957,7 @@ void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder,
nsRect rect(aBuilder->ToReferenceFrame(mFrame), mFrame->GetSize());
rect.IntersectRect(rect, aDirtyRect);
rect.ScaleRoundOut(mFrame->GetPresContext()->TwipsToPixels());
rect.ScaleRoundOut(1.0f / mFrame->GetPresContext()->AppUnitsPerDevPixel());
ctx->Rectangle(gfxRect(rect.x, rect.y, rect.width, rect.height), PR_TRUE);
ctx->Fill();
#endif
@ -3078,19 +3076,18 @@ nsFrame::IntrinsicWidthOffsets(nsIRenderingContext* aRenderingContext)
const nsStyleDisplay *disp = GetStyleDisplay();
if (IsThemed(disp)) {
nsPresContext *presContext = GetPresContext();
float p2t = presContext->ScaledPixelsToTwips();
nsMargin border;
presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
this, disp->mAppearance,
&border);
result.hBorder = NSIntPixelsToTwips(border.LeftRight(), p2t);
result.hBorder = presContext->DevPixelsToAppUnits(border.LeftRight());
nsMargin padding;
if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
this, disp->mAppearance,
&padding)) {
result.hPadding = NSIntPixelsToTwips(padding.LeftRight(), p2t);
result.hPadding = presContext->DevPixelsToAppUnits(padding.LeftRight());
result.hPctPadding = 0;
}
}
@ -3190,10 +3187,8 @@ nsFrame::ComputeSize(nsIRenderingContext *aRenderingContext,
GetMinimumWidgetSize(aRenderingContext, this, disp->mAppearance,
&size, &canOverride);
// GMWS() returns size in pixels, we need to convert it back to twips
float p2t = presContext->ScaledPixelsToTwips();
size.width = NSIntPixelsToTwips(size.width, p2t);
size.height = NSIntPixelsToTwips(size.height, p2t);
size.width = presContext->DevPixelsToAppUnits(size.width);
size.height = presContext->DevPixelsToAppUnits(size.height);
// GMWS() returns border-box; we need content-box
size.width -= aBorder.width + aPadding.width;
@ -3525,7 +3520,7 @@ nsIntRect nsIFrame::GetScreenRect() const
if (widget) {
nsRect ourRect = mRect;
ourRect.MoveTo(toViewOffset + toWidgetOffset);
ourRect.ScaleRoundOut(GetPresContext()->TwipsToPixels());
ourRect.ScaleRoundOut(1.0f / GetPresContext()->AppUnitsPerDevPixel());
// Is it safe to pass the same rect for both args of WidgetToScreen?
// It's not clear, so let's not...
nsIntRect ourPxRect(ourRect.x, ourRect.y, ourRect.width, ourRect.height);
@ -7129,10 +7124,10 @@ void DR_State::DeleteTreeNode(DR_FrameTreeNode& aNode)
static void
CheckPixelError(nscoord aSize,
float aPixelToTwips)
PRInt32 aPixelToTwips)
{
if (NS_UNCONSTRAINEDSIZE != aSize) {
if ((aSize % NSToCoordRound(aPixelToTwips)) > 0) {
if ((aSize % aPixelToTwips) > 0) {
printf("VALUE %d is not a whole pixel \n", aSize);
}
}
@ -7186,7 +7181,7 @@ static void DisplayReflowEnterPrint(nsPresContext* aPresContext,
else
printf("cnt=%d \n", DR_state->mCount);
if (DR_state->mDisplayPixelErrors) {
float p2t = aPresContext->ScaledPixelsToTwips();
PRInt32 p2t = aPresContext->AppUnitsPerDevPixel();
CheckPixelError(aReflowState.availableWidth, p2t);
CheckPixelError(aReflowState.availableHeight, p2t);
CheckPixelError(aReflowState.ComputedWidth(), p2t);
@ -7303,7 +7298,7 @@ void nsFrame::DisplayReflowExit(nsPresContext* aPresContext,
}
printf("\n");
if (DR_state->mDisplayPixelErrors) {
float p2t = aPresContext->ScaledPixelsToTwips();
PRInt32 p2t = aPresContext->AppUnitsPerDevPixel();
CheckPixelError(aMetrics.width, p2t);
CheckPixelError(aMetrics.height, p2t);
}

Просмотреть файл

@ -125,9 +125,6 @@ public:
virtual void Destroy();
virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext);
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
@ -322,13 +319,13 @@ nsSubDocumentFrame::GetIntrinsicWidth()
return 0; // <frame> has no useful intrinsic width
}
if (!mContent->IsNodeOfType(nsINode::eXUL)) {
if (mContent->IsNodeOfType(nsINode::eXUL)) {
return 0; // <xul:iframe> also has no useful intrinsic width
}
// We must be an HTML <iframe>. Default to a width of 300, for IE
// compat (and per CSS2.1 draft).
return NSIntPixelsToTwips(300, GetPresContext()->ScaledPixelsToTwips());
return nsPresContext::CSSPixelsToAppUnits(300);
}
nscoord
@ -342,8 +339,7 @@ nsSubDocumentFrame::GetIntrinsicHeight()
}
// Use 150px, for compatibility with IE, and per CSS2.1 draft.
return NSIntPixelsToTwips(150,
GetPresContext()->ScaledPixelsToTwips());
return nsPresContext::CSSPixelsToAppUnits(150);
}
#ifdef DEBUG
@ -365,25 +361,6 @@ nsSubDocumentFrame::IsFrameOfType(PRUint32 aFlags) const
return !(aFlags & ~(eReplaced | eReplacedContainsBlock));
}
/* virtual */ nscoord
nsSubDocumentFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
{
return nsSubDocumentFrame::GetPrefWidth(aRenderingContext);
}
/* virtual */ nscoord
nsSubDocumentFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
{
// XUL frames don't have a default 300px width
nscoord result;
DISPLAY_PREF_WIDTH(this, result);
if (mContent->IsNodeOfType(nsINode::eXUL))
result = 0;
else
result = NSIntPixelsToTwips(300, GetPresContext()->ScaledPixelsToTwips());
return result;
}
NS_IMETHODIMP
nsSubDocumentFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -441,14 +418,12 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext,
// resize the sub document
if (baseWindow) {
float t2p;
t2p = aPresContext->TwipsToPixels();
PRInt32 x = 0;
PRInt32 y = 0;
baseWindow->GetPositionAndSize(&x, &y, nsnull, nsnull);
PRInt32 cx = NSToCoordRound(innerSize.width * t2p);
PRInt32 cy = NSToCoordRound(innerSize.height * t2p);
PRInt32 cx = aPresContext->AppUnitsToDevPixels(innerSize.width);
PRInt32 cy = aPresContext->AppUnitsToDevPixels(innerSize.height);
baseWindow->SetPositionAndSize(x, y, cx, cy, PR_FALSE);
}
}

Просмотреть файл

@ -221,7 +221,7 @@ nsHTMLFramesetFrame::nsHTMLFramesetFrame(nsStyleContext* aContext)
mParentBorderWidth = -1; // default not set
mParentBorderColor = NO_COLOR; // default not set
mFirstDragPoint.x = mFirstDragPoint.y = 0;
mMinDrag = 0;
mMinDrag = nsPresContext::CSSPixelsToAppUnits(2);
mNonBorderChildCount = 0;
mNonBlankChildCount = 0;
mDragger = nsnull;
@ -557,7 +557,6 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext,
return; // NS_ERROR_OUT_OF_MEMORY
}
float p2t = aPresContext->ScaledPixelsToTwips();
PRInt32 i, j;
// initialize the fixed, percent, relative indices, allocate the fixed sizes and zero the others
@ -565,7 +564,7 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext,
aValues[i] = 0;
switch (aSpecs[i].mUnit) {
case eFramesetUnit_Fixed:
aValues[i] = NSToCoordRound(p2t * aSpecs[i].mValue);
aValues[i] = nsPresContext::CSSPixelsToAppUnits(aSpecs[i].mValue);
fixedTotal += aValues[i];
fixed[numFixed] = i;
numFixed++;
@ -631,8 +630,6 @@ void nsHTMLFramesetFrame::GenerateRowCol(nsPresContext* aPresContext,
nscoord* aValues,
nsString& aNewAttr)
{
float t2p;
t2p = aPresContext->TwipsToPixels();
PRInt32 i;
for (i = 0; i < aNumSpecs; i++) {
@ -641,7 +638,7 @@ void nsHTMLFramesetFrame::GenerateRowCol(nsPresContext* aPresContext,
switch (aSpecs[i].mUnit) {
case eFramesetUnit_Fixed:
aNewAttr.AppendInt(NSToCoordRound(t2p * aValues[i]));
aNewAttr.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(aValues[i]));
break;
case eFramesetUnit_Percent: // XXX Only accurate to 1%, need 1 pixel
case eFramesetUnit_Relative:
@ -664,7 +661,6 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext,
return 0;
}
}
float p2t = aPresContext->ScaledPixelsToTwips();
nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent);
if (content) {
@ -681,7 +677,7 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext,
if (forcing && intVal == 0) {
intVal = DEFAULT_BORDER_WIDTH_PX;
}
return NSIntPixelsToTwips(intVal, p2t);
return nsPresContext::CSSPixelsToAppUnits(intVal);
}
}
@ -690,7 +686,7 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext,
return mParentBorderWidth;
}
return NSIntPixelsToTwips(DEFAULT_BORDER_WIDTH_PX, p2t);
return nsPresContext::CSSPixelsToAppUnits(DEFAULT_BORDER_WIDTH_PX);
}
@ -1461,12 +1457,6 @@ nsHTMLFramesetFrame::StartMouseDrag(nsPresContext* aPresContext,
nsHTMLFramesetBorderFrame* aBorder,
nsGUIEvent* aEvent)
{
if (mMinDrag == 0) {
float p2t;
p2t = aPresContext->PixelsToTwips();
mMinDrag = NSIntPixelsToTwips(2, p2t); // set min drag and min frame size to 2 pixels
}
#if 0
PRInt32 index;
IndexOf(aBorder, index);
@ -1505,10 +1495,9 @@ nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
nsGUIEvent* aEvent)
{
PRInt32 change; // measured positive from left-to-right or top-to-bottom
float p2t = aPresContext->PixelsToTwips();
nsWeakFrame weakFrame(this);
if (mDragger->mVertical) {
change = NSIntPixelsToTwips(aEvent->refPoint.x - mFirstDragPoint.x, p2t);
change = aPresContext->DevPixelsToAppUnits(aEvent->refPoint.x - mFirstDragPoint.x);
if (change > mNextNeighborOrigSize - mMinDrag) {
change = mNextNeighborOrigSize - mMinDrag;
} else if (change <= mMinDrag - mPrevNeighborOrigSize) {
@ -1531,7 +1520,7 @@ nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::cols, newColAttr, PR_TRUE);
}
} else {
change = NSIntPixelsToTwips(aEvent->refPoint.y - mFirstDragPoint.y, p2t);
change = aPresContext->DevPixelsToAppUnits(aEvent->refPoint.y - mFirstDragPoint.y);
if (change > mNextNeighborOrigSize - mMinDrag) {
change = mNextNeighborOrigSize - mMinDrag;
} else if (change <= mMinDrag - mPrevNeighborOrigSize) {
@ -1714,13 +1703,8 @@ void nsHTMLFramesetBorderFrame::PaintBorder(nsIRenderingContext& aRenderingConte
}
}
nsPresContext* presContext = GetPresContext();
float t2p;
t2p = presContext->TwipsToPixels();
nscoord widthInPixels = NSTwipsToIntPixels(mWidth, t2p);
float p2t;
p2t = presContext->PixelsToTwips();
nscoord pixelWidth = NSIntPixelsToTwips(1, p2t);
nscoord widthInPixels = nsPresContext::AppUnitsToIntCSSPixels(mWidth);
nscoord pixelWidth = nsPresContext::CSSPixelsToAppUnits(1);
if (widthInPixels <= 0)
return;

Просмотреть файл

@ -435,7 +435,7 @@ nsHTMLScrollFrame::ReflowScrolledFrame(const ScrollReflowState& aState,
}
// pixel align the content
nsPresContext* presContext = GetPresContext();
nscoord twp = presContext->IntScaledPixelsToTwips(1);
nscoord twp = nsPresContext::CSSPixelsToAppUnits(1);
availWidth -= availWidth % twp;
if (!aFirstPass)
@ -1238,7 +1238,6 @@ nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsContainerFrame* aOuter,
mScrolledFrame(nsnull),
mScrollCornerBox(nsnull),
mOuter(aOuter),
mOnePixel(20),
mRestoreRect(-1, -1, -1, -1),
mLastPos(-1, -1),
mNeverHasVerticalScrollbar(PR_FALSE),
@ -2298,7 +2297,6 @@ nsGfxScrollFrameInner::LayoutScrollbars(nsBoxLayoutState& aState,
"This should have been suppressed");
nsPresContext* presContext = aState.PresContext();
mOnePixel = presContext->IntScaledPixelsToTwips(1);
const nsStyleFont* font = mOuter->GetStyleFont();
const nsFont& f = font->mFont;
nsCOMPtr<nsIFontMetrics> fm = presContext->GetMetricsFor(f);
@ -2351,7 +2349,7 @@ nsGfxScrollFrameInner::LayoutScrollbars(nsBoxLayoutState& aState,
SetScrollbarEnabled(mHScrollbarBox, maxX - minX);
SetCoordAttribute(mHScrollbarBox, nsGkAtoms::maxpos, maxX - minX);
SetCoordAttribute(mHScrollbarBox, nsGkAtoms::pageincrement, nscoord(float(aScrollArea.width)*0.8));
SetCoordAttribute(mHScrollbarBox, nsGkAtoms::increment, 10*mOnePixel);
SetCoordAttribute(mHScrollbarBox, nsGkAtoms::increment, nsPresContext::CSSPixelsToAppUnits(10));
nsRect hRect(aScrollArea);
hRect.height = aContentArea.height - aScrollArea.height;
@ -2454,7 +2452,7 @@ PRBool
nsGfxScrollFrameInner::SetCoordAttribute(nsIBox* aBox, nsIAtom* aAtom, nscoord aSize, PRBool aReflow)
{
// convert to pixels
aSize /= mOnePixel;
aSize = nsPresContext::AppUnitsToIntCSSPixels(aSize);
// only set the attribute if it changed.
@ -2533,7 +2531,7 @@ nsGfxScrollFrameInner::GetCoordAttribute(nsIBox* aBox, nsIAtom* atom, PRInt32 de
PRInt32 error;
// convert it to an integer
defaultValue = value.ToInteger(&error) * mOnePixel;
defaultValue = nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
}
}

Просмотреть файл

@ -178,7 +178,6 @@ public:
nsIFrame* mScrolledFrame;
nsIBox* mScrollCornerBox;
nsContainerFrame* mOuter;
nscoord mOnePixel;
nsRect mRestoreRect;
nsPoint mLastPos;

Просмотреть файл

@ -76,9 +76,7 @@ nsHTMLCanvasFrame::GetCanvasSize()
h = w = 1;
}
float p2t = GetPresContext()->PixelsToTwips();
return nsSize(NSIntPixelsToTwips(w, p2t), NSIntPixelsToTwips(h, p2t));
return nsSize(w, h);
}
/* virtual */ nscoord
@ -86,7 +84,7 @@ nsHTMLCanvasFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
{
// XXX The caller doesn't account for constraints of the height,
// min-height, and max-height properties.
nscoord result = GetCanvasSize().width;
nscoord result = nsPresContext::CSSPixelsToAppUnits(GetCanvasSize().width);
DISPLAY_MIN_WIDTH(this, result);
return result;
}
@ -96,7 +94,7 @@ nsHTMLCanvasFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
{
// XXX The caller doesn't account for constraints of the height,
// min-height, and max-height properties.
nscoord result = GetCanvasSize().width;
nscoord result = nsPresContext::CSSPixelsToAppUnits(GetCanvasSize().width);
DISPLAY_PREF_WIDTH(this, result);
return result;
}
@ -107,7 +105,9 @@ nsHTMLCanvasFrame::ComputeSize(nsIRenderingContext *aRenderingContext,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
PRBool aShrinkWrap)
{
nsSize canvasSize = GetCanvasSize();
nsSize size = GetCanvasSize();
nsSize canvasSize(nsPresContext::CSSPixelsToAppUnits(size.width),
nsPresContext::CSSPixelsToAppUnits(size.height));
return nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
aRenderingContext, this, canvasSize,
@ -183,13 +183,15 @@ nsHTMLCanvasFrame::PaintCanvas(nsIRenderingContext& aRenderingContext,
return;
nsSize canvasSize = GetCanvasSize();
nsSize sizeAppUnits(GetPresContext()->DevPixelsToAppUnits(canvasSize.width),
GetPresContext()->DevPixelsToAppUnits(canvasSize.height));
// XXXvlad clip to aDirtyRect!
if (inner.Size() != canvasSize)
if (inner.Size() != sizeAppUnits)
{
float sx = inner.width / (float) canvasSize.width;
float sy = inner.height / (float) canvasSize.height;
float sx = inner.width / (float) sizeAppUnits.width;
float sy = inner.height / (float) sizeAppUnits.height;
aRenderingContext.PushState();
aRenderingContext.Translate(inner.x, inner.y);

Просмотреть файл

@ -506,10 +506,9 @@ CanvasFrame::PaintFocus(nsIRenderingContext& aRenderingContext, nsPoint aPt)
return;
}
float p2t = GetPresContext()->PixelsToTwips();
// XXX the CSS border for links is specified as 2px, but it
// is only drawn as 1px. Match this here.
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
nsRect borderInside(focusRect.x + onePixel,
focusRect.y + onePixel,

Просмотреть файл

@ -1691,11 +1691,10 @@ nsCSSOffsetState::InitOffsets(nscoord aContainingBlockWidth,
presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
frame, disp->mAppearance,
&mComputedPadding)) {
float p2t = presContext->ScaledPixelsToTwips();
mComputedPadding.top = NSIntPixelsToTwips(mComputedPadding.top, p2t);
mComputedPadding.right = NSIntPixelsToTwips(mComputedPadding.right, p2t);
mComputedPadding.bottom = NSIntPixelsToTwips(mComputedPadding.bottom, p2t);
mComputedPadding.left = NSIntPixelsToTwips(mComputedPadding.left, p2t);
mComputedPadding.top = presContext->DevPixelsToAppUnits(mComputedPadding.top);
mComputedPadding.right = presContext->DevPixelsToAppUnits(mComputedPadding.right);
mComputedPadding.bottom = presContext->DevPixelsToAppUnits(mComputedPadding.bottom);
mComputedPadding.left = presContext->DevPixelsToAppUnits(mComputedPadding.left);
}
else if (aPadding) { // padding is an input arg
mComputedPadding.top = aPadding->top;
@ -1711,15 +1710,14 @@ nsCSSOffsetState::InitOffsets(nscoord aContainingBlockWidth,
presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
frame, disp->mAppearance,
&mComputedBorderPadding);
float p2t = presContext->ScaledPixelsToTwips();
mComputedBorderPadding.top =
NSIntPixelsToTwips(mComputedBorderPadding.top, p2t);
presContext->DevPixelsToAppUnits(mComputedBorderPadding.top);
mComputedBorderPadding.right =
NSIntPixelsToTwips(mComputedBorderPadding.right, p2t);
presContext->DevPixelsToAppUnits(mComputedBorderPadding.right);
mComputedBorderPadding.bottom =
NSIntPixelsToTwips(mComputedBorderPadding.bottom, p2t);
presContext->DevPixelsToAppUnits(mComputedBorderPadding.bottom);
mComputedBorderPadding.left =
NSIntPixelsToTwips(mComputedBorderPadding.left, p2t);
presContext->DevPixelsToAppUnits(mComputedBorderPadding.left);
}
else if (aBorder) { // border is an input arg
mComputedBorderPadding = *aBorder;

Просмотреть файл

@ -315,14 +315,11 @@ nsImageFrame::RecalculateTransform(imgIContainer* aImage)
PRBool intrinsicSizeChanged = PR_FALSE;
if (aImage) {
float p2t;
p2t = GetPresContext()->PixelsToTwips();
nsSize imageSizeInPx;
aImage->GetWidth(&imageSizeInPx.width);
aImage->GetHeight(&imageSizeInPx.height);
nsSize newSize(NSIntPixelsToTwips(imageSizeInPx.width, p2t),
NSIntPixelsToTwips(imageSizeInPx.height, p2t));
nsSize newSize(nsPresContext::CSSPixelsToAppUnits(imageSizeInPx.width),
nsPresContext::CSSPixelsToAppUnits(imageSizeInPx.height));
if (mIntrinsicSize != newSize) {
intrinsicSizeChanged = PR_TRUE;
mIntrinsicSize = newSize;
@ -399,23 +396,21 @@ nsImageFrame::IsPendingLoad(imgIContainer* aContainer) const
nsRect
nsImageFrame::SourceRectToDest(const nsRect& aRect)
{
float p2t = GetPresContext()->PixelsToTwips();
// 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
// between floor(F * (N-1)) and ceil(F * (N+1)), where F is the
// floating-point scaling factor. The same holds true for columns.
// So, we start by computing that bound without the floor and ceiling.
nsRect r(NSIntPixelsToTwips(aRect.x - 1, p2t),
NSIntPixelsToTwips(aRect.y - 1, p2t),
NSIntPixelsToTwips(aRect.width + 2, p2t),
NSIntPixelsToTwips(aRect.height + 2, p2t));
nsRect r(nsPresContext::CSSPixelsToAppUnits(aRect.x - 1),
nsPresContext::CSSPixelsToAppUnits(aRect.y - 1),
nsPresContext::CSSPixelsToAppUnits(aRect.width + 2),
nsPresContext::CSSPixelsToAppUnits(aRect.height + 2));
mTransform.TransformCoord(&r.x, &r.y, &r.width, &r.height);
// Now, round the edges out to the pixel boundary.
int scale = (int) p2t;
int scale = nsPresContext::CSSPixelsToAppUnits(1);
nscoord right = r.x + r.width;
nscoord bottom = r.y + r.height;
@ -691,9 +686,6 @@ nsImageFrame::EnsureIntrinsicSize(nsPresContext* aPresContext)
if (currentRequest) {
currentRequest->GetImage(getter_AddRefs(currentContainer));
}
float p2t;
p2t = aPresContext->PixelsToTwips();
if (currentContainer) {
RecalculateTransform(currentContainer);
@ -705,8 +697,8 @@ nsImageFrame::EnsureIntrinsicSize(nsPresContext* aPresContext)
// XXX: we need this in composer, but it is also good for
// XXX: general quirks mode to always have room for the icon
if (aPresContext->CompatibilityMode() == eCompatibility_NavQuirks) {
mIntrinsicSize.SizeTo(NSIntPixelsToTwips(ICON_SIZE+(2*(ICON_PADDING+ALT_BORDER_WIDTH)), p2t),
NSIntPixelsToTwips(ICON_SIZE+(2*(ICON_PADDING+ALT_BORDER_WIDTH)), p2t));
mIntrinsicSize.SizeTo(nsPresContext::CSSPixelsToAppUnits(ICON_SIZE+(2*(ICON_PADDING+ALT_BORDER_WIDTH))),
nsPresContext::CSSPixelsToAppUnits(ICON_SIZE+(2*(ICON_PADDING+ALT_BORDER_WIDTH))));
}
RecalculateTransform(nsnull);
}
@ -722,17 +714,9 @@ nsImageFrame::ComputeSize(nsIRenderingContext *aRenderingContext,
nsPresContext *presContext = GetPresContext();
EnsureIntrinsicSize(presContext);
// convert from normal twips to scaled twips (printing...)
float t2st = presContext->TwipsToPixels() *
presContext->ScaledPixelsToTwips(); // twips to scaled twips
nscoord intrinsicWidth =
NSToCoordRound(float(mIntrinsicSize.width) * t2st);
nscoord intrinsicHeight =
NSToCoordRound(float(mIntrinsicSize.height) * t2st);
return nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
aRenderingContext, this,
nsSize(intrinsicWidth, intrinsicHeight),
mIntrinsicSize,
aCBSize, aBorder, aPadding);
}
@ -781,10 +765,7 @@ nsImageFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
DISPLAY_MIN_WIDTH(this, result);
nsPresContext *presContext = GetPresContext();
EnsureIntrinsicSize(presContext);
// convert from normal twips to scaled twips (printing...)
float t2st = presContext->TwipsToPixels() *
presContext->ScaledPixelsToTwips();
result = NSToCoordRound(float(mIntrinsicSize.width) * t2st);
result = mIntrinsicSize.width;
return result;
}
@ -798,9 +779,7 @@ nsImageFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
nsPresContext *presContext = GetPresContext();
EnsureIntrinsicSize(presContext);
// convert from normal twips to scaled twips (printing...)
float t2st = presContext->TwipsToPixels() *
presContext->ScaledPixelsToTwips();
result = NSToCoordRound(float(mIntrinsicSize.width) * t2st);
result = mIntrinsicSize.width;
return result;
}
@ -877,7 +856,7 @@ nsImageFrame::Reflow(nsPresContext* aPresContext,
// split an image frame but not an image control frame
if (nsGkAtoms::imageFrame == GetType()) {
// our desired height was greater than 0, so to avoid infinite splitting, use 1 pixel as the min
aMetrics.height = PR_MAX(NSToCoordRound(aPresContext->ScaledPixelsToTwips()), aReflowState.availableHeight);
aMetrics.height = PR_MAX(nsPresContext::CSSPixelsToAppUnits(1), aReflowState.availableHeight);
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
@ -1058,14 +1037,12 @@ nsImageFrame::DisplayAltFeedback(nsIRenderingContext& aRenderingContext,
nsRect inner = GetInnerArea() + aPt;
// Display a recessed one pixel border
nscoord borderEdgeWidth;
float p2t = GetPresContext()->ScaledPixelsToTwips();
borderEdgeWidth = NSIntPixelsToTwips(ALT_BORDER_WIDTH, p2t);
nscoord borderEdgeWidth = nsPresContext::CSSPixelsToAppUnits(ALT_BORDER_WIDTH);
// if inner area is empty, then make it big enough for at least the icon
if (inner.IsEmpty()){
inner.SizeTo(2*(NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING+ALT_BORDER_WIDTH,p2t)),
2*(NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING+ALT_BORDER_WIDTH,p2t)));
inner.SizeTo(2*(nsPresContext::CSSPixelsToAppUnits(ICON_SIZE+ICON_PADDING+ALT_BORDER_WIDTH)),
2*(nsPresContext::CSSPixelsToAppUnits(ICON_SIZE+ICON_PADDING+ALT_BORDER_WIDTH)));
}
// Make sure we have enough room to actually render the border within
@ -1081,8 +1058,8 @@ nsImageFrame::DisplayAltFeedback(nsIRenderingContext& aRenderingContext,
// Adjust the inner rect to account for the one pixel recessed border,
// and a six pixel padding on each edge
inner.Deflate(NSIntPixelsToTwips(ICON_PADDING+ALT_BORDER_WIDTH, p2t),
NSIntPixelsToTwips(ICON_PADDING+ALT_BORDER_WIDTH, p2t));
inner.Deflate(nsPresContext::CSSPixelsToAppUnits(ICON_PADDING+ALT_BORDER_WIDTH),
nsPresContext::CSSPixelsToAppUnits(ICON_PADDING+ALT_BORDER_WIDTH));
if (inner.IsEmpty()) {
return;
}
@ -1096,7 +1073,7 @@ nsImageFrame::DisplayAltFeedback(nsIRenderingContext& aRenderingContext,
// Check if we should display image placeholders
if (dispIcon) {
const nsStyleVisibility* vis = GetStyleVisibility();
PRInt32 size = NSIntPixelsToTwips(ICON_SIZE, p2t);
nscoord size = nsPresContext::CSSPixelsToAppUnits(ICON_SIZE);
PRBool iconUsed = PR_FALSE;
@ -1123,17 +1100,18 @@ nsImageFrame::DisplayAltFeedback(nsIRenderingContext& aRenderingContext,
nscolor oldColor;
nscoord iconXPos = (vis->mDirection == NS_STYLE_DIRECTION_RTL) ?
inner.XMost() - size : inner.x;
nscoord twoPX = nsPresContext::CSSPixelsToAppUnits(2);
aRenderingContext.DrawRect(iconXPos, inner.y,size,size);
aRenderingContext.GetColor(oldColor);
aRenderingContext.SetColor(NS_RGB(0xFF,0,0));
aRenderingContext.FillEllipse(NS_STATIC_CAST(int,size/2) + iconXPos,NS_STATIC_CAST(int,size/2) + inner.y,
NS_STATIC_CAST(int,(size/2)-(2*p2t)),NS_STATIC_CAST(int,(size/2)-(2*p2t)));
aRenderingContext.FillEllipse(size/2 + iconXPos, size/2 + inner.y,
size/2 - twoPX, size/2 - twoPX);
aRenderingContext.SetColor(oldColor);
}
// Reduce the inner rect by the width of the icon, and leave an
// additional ICON_PADDING pixels for padding
PRInt32 iconWidth = NSIntPixelsToTwips(ICON_SIZE + ICON_PADDING, p2t);
PRInt32 iconWidth = nsPresContext::CSSPixelsToAppUnits(ICON_SIZE + ICON_PADDING);
if (vis->mDirection != NS_STYLE_DIRECTION_RTL)
inner.x += iconWidth;
inner.width -= iconWidth;
@ -1490,11 +1468,8 @@ nsImageFrame::TranslateEventCoords(const nsPoint& aPoint,
x -= inner.x;
y -= inner.y;
// Translate the coordinates from twips to pixels
float t2p;
t2p = GetPresContext()->TwipsToPixels();
aResult.x = NSTwipsToIntPixels(x, t2p);
aResult.y = NSTwipsToIntPixels(y, t2p);
aResult.x = nsPresContext::AppUnitsToIntCSSPixels(x);
aResult.y = nsPresContext::AppUnitsToIntCSSPixels(y);
}
PRBool

Просмотреть файл

@ -436,12 +436,10 @@ void RectArea::Draw(nsPresContext* aCX, nsIRenderingContext& aRC)
{
if (mHasFocus) {
if (mNumCoords >= 4) {
float p2t;
p2t = aCX->PixelsToTwips();
nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t);
nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t);
nscoord x2 = NSIntPixelsToTwips(mCoords[2], p2t);
nscoord y2 = NSIntPixelsToTwips(mCoords[3], p2t);
nscoord x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
nscoord y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
nscoord x2 = nsPresContext::CSSPixelsToAppUnits(mCoords[2]);
nscoord y2 = nsPresContext::CSSPixelsToAppUnits(mCoords[3]);
NS_ASSERTION(x1 <= x2 && y1 <= y2,
"Someone screwed up RectArea::ParseCoords");
aRC.DrawLine(x1, y1, x1, y2);
@ -455,12 +453,10 @@ void RectArea::Draw(nsPresContext* aCX, nsIRenderingContext& aRC)
void RectArea::GetRect(nsPresContext* aCX, nsRect& aRect)
{
if (mNumCoords >= 4) {
float p2t;
p2t = aCX->PixelsToTwips();
nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t);
nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t);
nscoord x2 = NSIntPixelsToTwips(mCoords[2], p2t);
nscoord y2 = NSIntPixelsToTwips(mCoords[3], p2t);
nscoord x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
nscoord y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
nscoord x2 = nsPresContext::CSSPixelsToAppUnits(mCoords[2]);
nscoord y2 = nsPresContext::CSSPixelsToAppUnits(mCoords[3]);
NS_ASSERTION(x1 <= x2 && y1 <= y2,
"Someone screwed up RectArea::ParseCoords");
@ -571,20 +567,18 @@ void PolyArea::Draw(nsPresContext* aCX, nsIRenderingContext& aRC)
{
if (mHasFocus) {
if (mNumCoords >= 6) {
float p2t;
p2t = aCX->PixelsToTwips();
nscoord x0 = NSIntPixelsToTwips(mCoords[0], p2t);
nscoord y0 = NSIntPixelsToTwips(mCoords[1], p2t);
nscoord x0 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
nscoord y0 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
nscoord x1, y1;
for (PRInt32 i = 2; i < mNumCoords; i += 2) {
x1 = NSIntPixelsToTwips(mCoords[i], p2t);
y1 = NSIntPixelsToTwips(mCoords[i+1], p2t);
x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[i]);
y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[i+1]);
aRC.DrawLine(x0, y0, x1, y1);
x0 = x1;
y0 = y1;
}
x1 = NSIntPixelsToTwips(mCoords[0], p2t);
y1 = NSIntPixelsToTwips(mCoords[1], p2t);
x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
aRC.DrawLine(x0, y0, x1, y1);
}
}
@ -593,14 +587,12 @@ void PolyArea::Draw(nsPresContext* aCX, nsIRenderingContext& aRC)
void PolyArea::GetRect(nsPresContext* aCX, nsRect& aRect)
{
if (mNumCoords >= 6) {
float p2t;
p2t = aCX->PixelsToTwips();
nscoord x1, x2, y1, y2, xtmp, ytmp;
x1 = x2 = NSIntPixelsToTwips(mCoords[0], p2t);
y1 = y2 = NSIntPixelsToTwips(mCoords[1], p2t);
x1 = x2 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
y1 = y2 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
for (PRInt32 i = 2; i < mNumCoords; i += 2) {
xtmp = NSIntPixelsToTwips(mCoords[i], p2t);
ytmp = NSIntPixelsToTwips(mCoords[i+1], p2t);
xtmp = nsPresContext::CSSPixelsToAppUnits(mCoords[i]);
ytmp = nsPresContext::CSSPixelsToAppUnits(mCoords[i+1]);
x1 = x1 < xtmp ? x1 : xtmp;
y1 = y1 < ytmp ? y1 : ytmp;
x2 = x2 > xtmp ? x2 : xtmp;
@ -683,11 +675,9 @@ void CircleArea::Draw(nsPresContext* aCX, nsIRenderingContext& aRC)
{
if (mHasFocus) {
if (mNumCoords >= 3) {
float p2t;
p2t = aCX->PixelsToTwips();
nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t);
nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t);
nscoord radius = NSIntPixelsToTwips(mCoords[2], p2t);
nscoord x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
nscoord y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
nscoord radius = nsPresContext::CSSPixelsToAppUnits(mCoords[2]);
if (radius < 0) {
return;
}
@ -702,11 +692,9 @@ void CircleArea::Draw(nsPresContext* aCX, nsIRenderingContext& aRC)
void CircleArea::GetRect(nsPresContext* aCX, nsRect& aRect)
{
if (mNumCoords >= 3) {
float p2t;
p2t = aCX->PixelsToTwips();
nscoord x1 = NSIntPixelsToTwips(mCoords[0], p2t);
nscoord y1 = NSIntPixelsToTwips(mCoords[1], p2t);
nscoord radius = NSIntPixelsToTwips(mCoords[2], p2t);
nscoord x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
nscoord y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
nscoord radius = nsPresContext::CSSPixelsToAppUnits(mCoords[2]);
if (radius < 0) {
return;
}

Просмотреть файл

@ -105,6 +105,7 @@
#include "nsContentUtils.h"
#include "nsDisplayList.h"
#include "nsAttrName.h"
#include "nsDataHashtable.h"
// headers for plugin scriptability
#include "nsIScriptGlobalObject.h"
@ -386,7 +387,7 @@ private:
};
#if defined(XP_WIN) || (defined(DO_DIRTY_INTERSECT) && defined(XP_MACOSX))
static void ConvertTwipsToPixels(nsPresContext& aPresContext, nsRect& aTwipsRect, nsRect& aPixelRect);
static void ConvertAppUnitsToPixels(nsPresContext& aPresContext, nsRect& aTwipsRect, nsRect& aPixelRect);
#endif
// Mac specific code to fix up port position and clip during paint
@ -604,8 +605,7 @@ nsObjectFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
if (!IsHidden(PR_FALSE)) {
nsIAtom *atom = mContent->Tag();
if (atom == nsGkAtoms::applet || atom == nsGkAtoms::embed) {
float p2t = GetPresContext()->ScaledPixelsToTwips();
result = NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t);
result = nsPresContext::CSSPixelsToAppUnits(EMBED_DEF_WIDTH);
}
}
@ -638,14 +638,13 @@ nsObjectFrame::GetDesiredSize(nsPresContext* aPresContext,
// for EMBED and APPLET, default to 240x200 for compatibility
nsIAtom *atom = mContent->Tag();
if (atom == nsGkAtoms::applet || atom == nsGkAtoms::embed) {
float p2t = aPresContext->ScaledPixelsToTwips();
if (aMetrics.width == NS_UNCONSTRAINEDSIZE) {
aMetrics.width = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t),
aMetrics.width = PR_MIN(PR_MAX(nsPresContext::CSSPixelsToAppUnits(EMBED_DEF_WIDTH),
aReflowState.mComputedMinWidth),
aReflowState.mComputedMaxWidth);
}
if (aMetrics.height == NS_UNCONSTRAINEDSIZE) {
aMetrics.height = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_HEIGHT, p2t),
aMetrics.height = PR_MIN(PR_MAX(nsPresContext::CSSPixelsToAppUnits(EMBED_DEF_HEIGHT),
aReflowState.mComputedMinHeight),
aReflowState.mComputedMaxHeight);
}
@ -655,8 +654,8 @@ nsObjectFrame::GetDesiredSize(nsPresContext* aPresContext,
// exceed the maximum size of X coordinates. See bug #225357 for
// more information. In theory Gtk2 can handle large coordinates,
// but underlying plugins can't.
aMetrics.height = PR_MIN(NSIntPixelsToTwips(PR_INT16_MAX, p2t), aMetrics.height);
aMetrics.width = PR_MIN(NSIntPixelsToTwips(PR_INT16_MAX, p2t), aMetrics.width);
aMetrics.height = PR_MIN(aPresContext->DevPixelsToAppUnits(PR_INT16_MAX), aMetrics.height);
aMetrics.width = PR_MIN(aPresContext->DevPixelsToAppUnits(PR_INT16_MAX), aMetrics.width);
#endif
}
@ -765,8 +764,6 @@ nsObjectFrame::FixupWindow(const nsSize& aSize)
{
nsPresContext* presContext = GetPresContext();
float t2p = presContext->TwipsToPixels();
if (!mInstanceOwner)
return;
@ -778,10 +775,10 @@ nsObjectFrame::FixupWindow(const nsSize& aSize)
nsPoint origin;
nsIView *parentWithView;
GetOffsetFromView(origin, &parentWithView);
window->x = NSTwipsToIntPixels(origin.x, t2p);
window->y = NSTwipsToIntPixels(origin.y, t2p);
window->width = NSTwipsToIntPixels(aSize.width, t2p);
window->height = NSTwipsToIntPixels(aSize.height, t2p);
window->x = presContext->AppUnitsToDevPixels(origin.x);
window->y = presContext->AppUnitsToDevPixels(origin.y);
window->width = presContext->AppUnitsToDevPixels(aSize.width);
window->height = presContext->AppUnitsToDevPixels(aSize.height);
// on the Mac we need to set the clipRect to { 0, 0, 0, 0 } for now. This will keep
// us from drawing on screen until the widget is properly positioned, which will not
@ -792,8 +789,8 @@ nsObjectFrame::FixupWindow(const nsSize& aSize)
window->clipRect.bottom = 0;
window->clipRect.right = 0;
#else
window->clipRect.bottom = NSTwipsToIntPixels(aSize.height, t2p);
window->clipRect.right = NSTwipsToIntPixels(aSize.width, t2p);
window->clipRect.bottom = presContext->AppUnitsToDevPixels(aSize.height);
window->clipRect.right = presContext->AppUnitsToDevPixels(aSize.width);
#endif
}
@ -860,10 +857,8 @@ nsPoint nsObjectFrame::GetWindowOriginInPixels(PRBool aWindowless)
}
}
float t2p;
t2p = GetPresContext()->TwipsToPixels();
origin.x = NSTwipsToIntPixels(origin.x, t2p);
origin.y = NSTwipsToIntPixels(origin.y, t2p);
origin.x = GetPresContext()->AppUnitsToDevPixels(origin.x);
origin.y = GetPresContext()->AppUnitsToDevPixels(origin.y);
return origin;
}
@ -1027,15 +1022,13 @@ nsObjectFrame::PrintPlugin(nsIRenderingContext& aRenderingContext,
aRenderingContext.GetCurrentTransform(rcTransform);
nsPoint origin;
rcTransform->GetTranslationCoord(&origin.x, &origin.y);
// Get the conversion factor between pixels and twips
float t2p = presContext->TwipsToPixels();
// set it all up
// XXX is windowless different?
window.x = origin.x;
window.y = origin.y;
window.width = NSToCoordRound(mRect.width * t2p);
window.height= NSToCoordRound(mRect.height * t2p);
window.width = presContext->AppUnitsToDevPixels(mRect.width);
window.height= presContext->AppUnitsToDevPixels(mRect.height);
window.clipRect.bottom = 0; window.clipRect.top = 0;
window.clipRect.left = 0; window.clipRect.right = 0;
@ -1855,13 +1848,12 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
nsIView* view = mOwner->GetView();
if (view) {
float ptot;
ptot = mOwner->GetPresContext()->PixelsToTwips();
nsPresContext* presContext = mOwner->GetPresContext();
nsRect rect((int)(ptot * invalidRect->left),
(int)(ptot * invalidRect->top),
(int)(ptot * (invalidRect->right - invalidRect->left)),
(int)(ptot * (invalidRect->bottom - invalidRect->top)));
nsRect rect(presContext->DevPixelsToAppUnits(invalidRect->left),
presContext->DevPixelsToAppUnits(invalidRect->top),
presContext->DevPixelsToAppUnits(invalidRect->right - invalidRect->left),
presContext->DevPixelsToAppUnits(invalidRect->bottom - invalidRect->top));
//set flags to not do a synchronous update, force update does the redraw
view->GetViewManager()->UpdateView(view, rect, NS_VMREFRESH_NO_SYNC);
@ -2080,7 +2072,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentBase(const char* *result)
return rv;
}
static nsHashtable *gCharsetMap = nsnull;
static nsDataHashtable<nsDepCharHashKey, const char *> * gCharsetMap;
typedef struct {
char mozName[16];
char javaName[12];
@ -2144,7 +2136,7 @@ static const moz2javaCharset charsets[] =
{"Shift_JIS", "SJIS"},
{"TIS-620", "TIS620"}
};
NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
{
NS_ENSURE_ARG_POINTER(result);
@ -2158,7 +2150,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
if (NS_FAILED(rv))
return rv;
const nsACString &charset = doc->GetDocumentCharacterSet();
const nsCString &charset = doc->GetDocumentCharacterSet();
if (charset.IsEmpty())
return NS_OK;
@ -2171,19 +2163,19 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
*result = ToNewCString(charset);
} else {
if (!gCharsetMap) {
gCharsetMap = new nsHashtable(sizeof(charsets)/sizeof(moz2javaCharset));
if (!gCharsetMap)
const int NUM_CHARSETS = sizeof(charsets) / sizeof(moz2javaCharset);
gCharsetMap = new nsDataHashtable<nsDepCharHashKey, const char*>();
if (!gCharsetMap || !gCharsetMap->Init(NUM_CHARSETS))
return NS_ERROR_OUT_OF_MEMORY;
for (PRUint16 i = 0; i < sizeof(charsets)/sizeof(moz2javaCharset); i++) {
nsCStringKey key(charsets[i].mozName);
gCharsetMap->Put(&key, (void *)(charsets[i].javaName));
for (PRUint16 i = 0; i < NUM_CHARSETS; i++) {
gCharsetMap->Put(charsets[i].mozName, charsets[i].javaName);
}
}
nsCStringKey mozKey(charset);
// if found mapping, return it; otherwise return original charset
char *mapping = (char *)gCharsetMap->Get(&mozKey);
*result = mapping ? PL_strdup(mapping) : ToNewCString(charset);
const char *mapping;
*result = gCharsetMap->Get(charset.get(), &mapping) ? PL_strdup(mapping) :
ToNewCString(charset);
}
return (*result) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
@ -3146,7 +3138,7 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, PRUint32 ndc)
// Convert to absolute pixel values for the dirty rect
nsRect absDirtyRectInPixels;
ConvertTwipsToPixels(*mOwner->GetPresContext(), absDirtyRect,
ConvertAppUnitsToPixels(*mOwner->GetPresContext(), absDirtyRect,
absDirtyRectInPixels);
#endif
@ -3174,8 +3166,8 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, PRUint32 ndc)
GetWindow(window);
nsRect relDirtyRect = nsRect(aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
nsRect relDirtyRectInPixels;
ConvertTwipsToPixels(*mOwner->GetPresContext(), relDirtyRect,
relDirtyRectInPixels);
ConvertAppUnitsToPixels(*mOwner->GetPresContext(), relDirtyRect,
relDirtyRectInPixels);
// we got dirty rectangle in relative window coordinates, but we
// need it in absolute units and in the (left, top, right, bottom) form
@ -3360,9 +3352,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
(void *)&windowless);
// always create widgets in Twips, not pixels
float p2t = mOwner->GetPresContext()->ScaledPixelsToTwips();
rv = mOwner->CreateWidget(NSIntPixelsToTwips(mPluginWindow->width, p2t),
NSIntPixelsToTwips(mPluginWindow->height, p2t),
nsPresContext* context = mOwner->GetPresContext();
rv = mOwner->CreateWidget(context->DevPixelsToAppUnits(mPluginWindow->width),
context->DevPixelsToAppUnits(mPluginWindow->height),
windowless);
if (NS_OK == rv) {
view = mOwner->GetView();
@ -3414,14 +3406,12 @@ void nsPluginInstanceOwner::SetPluginHost(nsIPluginHost* aHost)
#if defined(XP_WIN) || (defined(DO_DIRTY_INTERSECT) && defined(XP_MACOSX))
// convert frame coordinates from twips to pixels
static void ConvertTwipsToPixels(nsPresContext& aPresContext, nsRect& aTwipsRect, nsRect& aPixelRect)
static void ConvertAppUnitsToPixels(nsPresContext& aPresContext, nsRect& aTwipsRect, nsRect& aPixelRect)
{
float t2p;
t2p = aPresContext.TwipsToPixels();
aPixelRect.x = NSTwipsToIntPixels(aTwipsRect.x, t2p);
aPixelRect.y = NSTwipsToIntPixels(aTwipsRect.y, t2p);
aPixelRect.width = NSTwipsToIntPixels(aTwipsRect.width, t2p);
aPixelRect.height = NSTwipsToIntPixels(aTwipsRect.height, t2p);
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

Просмотреть файл

@ -56,6 +56,7 @@
#endif
#include "nsIFontMetrics.h"
#include "nsIPrintSettings.h"
#include "nsRegion.h"
#include "prlog.h"
#ifdef PR_LOGGING
@ -133,8 +134,11 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsPresContext* aPresContext,
}
nsSize maxSize(mPD->mReflowSize.width - mPD->mReflowMargin.LeftRight(),
avHeight);
float scale = aPresContext->GetPageScale();
maxSize.width = NSToCoordCeil(maxSize.width / scale);
maxSize.height = NSToCoordCeil(maxSize.height / scale);
// Get the number of Twips per pixel from the PresContext
nscoord onePixelInTwips = aPresContext->IntScaledPixelsToTwips(1);
nscoord onePixelInTwips = nsPresContext::CSSPixelsToAppUnits(1);
// insurance against infinite reflow, when reflowing less than a pixel
// XXX Shouldn't we do something more friendly when invalid margins
// are set?
@ -415,10 +419,10 @@ static void PaintPrintPreviewBackground(nsIFrame* aFrame, nsIRenderingContext* a
NS_STATIC_CAST(nsPageFrame*, aFrame)->PaintPrintPreviewBackground(*aCtx, aPt);
}
static void PaintPageBackground(nsIFrame* aFrame, nsIRenderingContext* aCtx,
const nsRect& aDirtyRect, nsPoint aPt)
static void PaintPageContent(nsIFrame* aFrame, nsIRenderingContext* aCtx,
const nsRect& aDirtyRect, nsPoint aPt)
{
NS_STATIC_CAST(nsPageFrame*, aFrame)->DrawBackground(*aCtx, aDirtyRect, aPt);
NS_STATIC_CAST(nsPageFrame*, aFrame)->PaintPageContent(*aCtx, aDirtyRect, aPt);
}
static void PaintHeaderFooter(nsIFrame* aFrame, nsIRenderingContext* aCtx,
@ -434,20 +438,16 @@ nsPageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists)
{
nsDisplayListCollection set;
nsresult rv;
if (GetPresContext()->IsScreen()) {
nsresult rv = set.BorderBackground()->AppendNewToTop(new (aBuilder)
rv = set.BorderBackground()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(this, ::PaintPrintPreviewBackground, "PrintPreviewBackground"));
NS_ENSURE_SUCCESS(rv, rv);
}
nsresult rv = set.BorderBackground()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(this, ::PaintPageBackground, "PageBackground"));
NS_ENSURE_SUCCESS(rv, rv);
// REVIEW: There was a "aRenderingContext.SetColor(NS_RGB(255,255,255));"
// here which was overridden on every code path, so I removed it.
rv = nsContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, set);
rv = set.BorderBackground()->AppendNewToTop(new (aBuilder)
nsDisplayGeneric(this, ::PaintPageContent, "PageContent"));
NS_ENSURE_SUCCESS(rv, rv);
if (GetPresContext()->IsRootPaginatedDocument()) {
@ -554,22 +554,32 @@ nsPageFrame::PaintHeaderFooter(nsIRenderingContext& aRenderingContext,
//------------------------------------------------------------------------------
void
nsPageFrame::DrawBackground(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt)
{
nsSimplePageSequenceFrame* seqFrame = NS_STATIC_CAST(nsSimplePageSequenceFrame*, mParent);
if (seqFrame != nsnull) {
nsIFrame* pageContentFrame = mFrames.FirstChild();
NS_ASSERTION(pageContentFrame, "Must always be there.");
nsPageFrame::PaintPageContent(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt) {
nsIFrame* pageContentFrame = mFrames.FirstChild();
nsRect rect = aDirtyRect;
float scale = GetPresContext()->GetPageScale();
aRenderingContext.PushState();
// aPt translates to coords relative to this, then margins translate to
// pageContentFrame's coords
nsPoint framePos = aPt + pageContentFrame->GetOffsetTo(this);
aRenderingContext.Translate(framePos.x, framePos.y);
rect -= framePos;
aRenderingContext.Scale(scale, scale);
rect.ScaleRoundOut(1.0f / scale);
const nsStyleBorder* border = GetStyleBorder();
const nsStylePadding* padding = GetStylePadding();
const nsStyleBorder* border = GetStyleBorder();
const nsStylePadding* padding = GetStylePadding();
nsRect backgroundRect = nsRect(nsPoint(0, 0), pageContentFrame->GetSize());
nsCSSRendering::PaintBackground(GetPresContext(), aRenderingContext, this,
rect, backgroundRect, *border, *padding,
PR_TRUE);
nsCSSRendering::PaintBackground(GetPresContext(), aRenderingContext, this,
aDirtyRect, pageContentFrame->GetRect() + aPt, *border, *padding,
PR_TRUE);
}
nsresult rv = nsLayoutUtils::PaintFrame(&aRenderingContext, pageContentFrame,
nsRegion(rect), NS_RGBA(0,0,0,0));
aRenderingContext.PopState();
}
void
@ -606,7 +616,7 @@ nsPageBreakFrame::~nsPageBreakFrame()
nscoord
nsPageBreakFrame::GetIntrinsicWidth()
{
return GetPresContext()->IntScaledPixelsToTwips(1);
return nsPresContext::CSSPixelsToAppUnits(1);
}
nsresult
@ -624,7 +634,7 @@ nsPageBreakFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.height = aReflowState.availableHeight;
// round the height down to the nearest pixel
aDesiredSize.height -=
aDesiredSize.height % GetPresContext()->IntScaledPixelsToTwips(1);
aDesiredSize.height % nsPresContext::CSSPixelsToAppUnits(1);
// Note: not using NS_FRAME_FIRST_REFLOW here, since it's not clear whether
// DidReflow will always get called before the next Reflow() call.

Просмотреть файл

@ -83,10 +83,10 @@ public:
nsPoint aPt);
void PaintHeaderFooter(nsIRenderingContext& aRenderingContext,
nsPoint aPt);
void DrawBackground(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt);
void PaintPageContent(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt);
protected:
nsPageFrame(nsStyleContext* aContext);
virtual ~nsPageFrame();

Просмотреть файл

@ -164,15 +164,13 @@ static void
PaintDebugPlaceholder(nsIFrame* aFrame, nsIRenderingContext* aCtx,
const nsRect& aDirtyRect, nsPoint aPt)
{
float p2t;
p2t = aFrame->GetPresContext()->PixelsToTwips();
aCtx->SetColor(NS_RGB(0, 255, 255));
nscoord x = NSIntPixelsToTwips(-5, p2t);
nscoord x = nsPresContext::CSSPixelsToAppUnits(-5);
aCtx->FillRect(aPt.x + x, aPt.y,
NSIntPixelsToTwips(13, p2t), NSIntPixelsToTwips(3, p2t));
nscoord y = NSIntPixelsToTwips(-10, p2t);
nsPresContext::CSSPixelsToAppUnits(13), nsPresContext::CSSPixelsToAppUnits(3));
nscoord y = nsPresContext::CSSPixelsToAppUnits(-10);
aCtx->FillRect(aPt.x, aPt.y + y,
NSIntPixelsToTwips(3, p2t), NSIntPixelsToTwips(10, p2t));
nsPresContext::CSSPixelsToAppUnits(3), nsPresContext::CSSPixelsToAppUnits(10));
}
#endif // DEBUG

Просмотреть файл

@ -122,7 +122,7 @@ nsSimplePageSequenceFrame::nsSimplePageSequenceFrame(nsStyleContext* aContext) :
// XXX Unsafe to assume successful allocation
mPageData = new nsSharedPageData();
mPageData->mHeadFootFont = new nsFont(*GetPresContext()->GetDefaultFont(kGenericFont_serif));
mPageData->mHeadFootFont->size = NSIntPointsToTwips(10);
mPageData->mHeadFootFont->size = GetPresContext()->PointsToAppUnits(10);
nsresult rv;
mPageData->mPrintOptions = do_GetService(sPrintOptionsContractID, &rv);
@ -214,13 +214,8 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
return NS_OK;
}
// Turn on the scaling of twips so any of the scrollbars
// in the UI no longer get scaled
PRBool isPrintPreview =
aPresContext->Type() == nsPresContext::eContext_PrintPreview;
if (isPrintPreview) {
aPresContext->SetScalingOfTwips(PR_TRUE);
}
// See if we can get a Print Settings from the Context
if (!mPageData->mPrintSettings &&
@ -230,7 +225,12 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
// now get out margins
if (mPageData->mPrintSettings) {
mPageData->mPrintSettings->GetMarginInTwips(mMargin);
nsMargin marginTwips;
mPageData->mPrintSettings->GetMarginInTwips(marginTwips);
mMargin = nsMargin(aPresContext->TwipsToAppUnits(marginTwips.left),
aPresContext->TwipsToAppUnits(marginTwips.top),
aPresContext->TwipsToAppUnits(marginTwips.right),
aPresContext->TwipsToAppUnits(marginTwips.bottom));
PRInt16 printType;
mPageData->mPrintSettings->GetPrintRange(&printType);
mPrintRangeType = printType;
@ -265,7 +265,7 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
nsSize shadowSize(0,0);
if (aPresContext->IsScreen()) {
extraMargin.SizeTo(extraGap, extraGap, extraGap, extraGap);
nscoord fourPixels = aPresContext->IntScaledPixelsToTwips(4);
nscoord fourPixels = nsPresContext::CSSPixelsToAppUnits(4);
shadowSize.SizeTo(fourPixels, fourPixels);
}
@ -381,12 +381,6 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
mSize.width = aDesiredSize.width;
mSize.height = aDesiredSize.height;
// Turn off the scaling of twips so any of the scrollbars
// in the document get scaled
if (isPrintPreview) {
aPresContext->SetScalingOfTwips(PR_FALSE);
}
NS_FRAME_TRACE_REFLOW_OUT("nsSimplePageSequeceFrame::Reflow", aStatus);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK;
@ -484,7 +478,6 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext,
aPrintSettings->GetStartPageRange(&mFromPageNum);
aPrintSettings->GetEndPageRange(&mToPageNum);
aPrintSettings->GetMarginInTwips(mMargin);
mDoingPageRange = nsIPrintSettings::kRangeSpecifiedPageRange == mPrintRangeType ||
nsIPrintSettings::kRangeSelection == mPrintRangeType;

Просмотреть файл

@ -6207,7 +6207,7 @@ nsTextFrame::Reflow(nsPresContext* aPresContext,
// For now we add 1 pixel to the width of the invalidated rect.
// This fixes cases where the twips to pixel roundoff causes the invalidated
// rect's width to be one pixel short.
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
maxFrameWidth = PR_MAX(maxFrameWidth, mRect.width) + onePixel;
maxFrameHeight = PR_MAX(maxFrameHeight, mRect.height);

Просмотреть файл

@ -167,10 +167,6 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement)
if (!window) return NS_OK;
nsCOMPtr<nsIPresShell> presShell = inLayoutUtils::GetPresShellFor(window);
if (!presShell) return NS_OK;
nsPresContext *presContext = presShell->GetPresContext();
float p2t = presContext->PixelsToTwips();
PRBool isFirstFrame = PR_TRUE;
nsCOMPtr<nsIRenderingContext> rcontext;
@ -192,7 +188,7 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement)
frame = frame->GetNextContinuation();
PRBool isLastFrame = (frame == nsnull);
DrawOutline(rect.x, rect.y, rect.width, rect.height, p2t, rcontext,
DrawOutline(rect.x, rect.y, rect.width, rect.height, rcontext,
isFirstFrame, isLastFrame);
isFirstFrame = PR_FALSE;
}
@ -231,27 +227,27 @@ inFlasher::ScrollElementIntoView(nsIDOMElement *aElement)
void
inFlasher::DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aP2T, nsIRenderingContext* aRenderContext,
nsIRenderingContext* aRenderContext,
PRBool aDrawBegin, PRBool aDrawEnd)
{
aRenderContext->SetColor(mColor);
DrawLine(aX, aY, aWidth, DIR_HORIZONTAL, BOUND_OUTER, aP2T, aRenderContext);
DrawLine(aX, aY, aWidth, DIR_HORIZONTAL, BOUND_OUTER, aRenderContext);
if (aDrawBegin) {
DrawLine(aX, aY, aHeight, DIR_VERTICAL, BOUND_OUTER, aP2T, aRenderContext);
DrawLine(aX, aY, aHeight, DIR_VERTICAL, BOUND_OUTER, aRenderContext);
}
DrawLine(aX, aY+aHeight, aWidth, DIR_HORIZONTAL, BOUND_INNER, aP2T, aRenderContext);
DrawLine(aX, aY+aHeight, aWidth, DIR_HORIZONTAL, BOUND_INNER, aRenderContext);
if (aDrawEnd) {
DrawLine(aX+aWidth, aY, aHeight, DIR_VERTICAL, BOUND_INNER, aP2T, aRenderContext);
DrawLine(aX+aWidth, aY, aHeight, DIR_VERTICAL, BOUND_INNER, aRenderContext);
}
}
void
inFlasher::DrawLine(nscoord aX, nscoord aY, nscoord aLength,
PRBool aDir, PRBool aBounds, float aP2T,
PRBool aDir, PRBool aBounds,
nsIRenderingContext* aRenderContext)
{
nscoord thickTwips = NSIntPixelsToTwips(mThickness, aP2T);
nscoord thickTwips = nsPresContext::CSSPixelsToAppUnits(mThickness);
if (aDir) { // horizontal
aRenderContext->FillRect(aX, aY+(aBounds?0:-thickTwips), aLength, thickTwips);
} else { // vertical

Просмотреть файл

@ -63,10 +63,10 @@ public:
protected:
void DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aP2T, nsIRenderingContext* aRenderContext,
nsIRenderingContext* aRenderContext,
PRBool aDrawBegin, PRBool aDrawEnd);
void DrawLine(nscoord aX, nscoord aY, nscoord aLength,
PRBool aDir, PRBool aBounds, float aP2T,
PRBool aDir, PRBool aBounds,
nsIRenderingContext* aRenderContext);
nsCOMPtr<nsIInspectorCSSUtils> mCSSUtils;

Просмотреть файл

@ -1461,11 +1461,11 @@ nsMathMLChar::SetData(nsPresContext* aPresContext,
// plain TeX settings (TeXbook p.152)
#define NS_MATHML_DELIMITER_FACTOR 0.901f
#define NS_MATHML_DELIMITER_SHORTFALL NSFloatPointsToTwips(5.0f)
#define NS_MATHML_DELIMITER_FACTOR 0.901f
#define NS_MATHML_DELIMITER_SHORTFALL_POINTS 5.0f
static PRBool
IsSizeOK(nscoord a, nscoord b, PRUint32 aHint)
IsSizeOK(nsPresContext* aPresContext, nscoord a, nscoord b, PRUint32 aHint)
{
// Normal: True if 'a' is around +/-10% of the target 'b' (10% is
// 1-DelimiterFactor). This often gives a chance to the base size to
@ -1480,7 +1480,7 @@ IsSizeOK(nscoord a, nscoord b, PRUint32 aHint)
PRBool isNearer = PR_FALSE;
if (aHint & (NS_STRETCH_NEARER | NS_STRETCH_LARGEOP)) {
float c = PR_MAX(float(b) * NS_MATHML_DELIMITER_FACTOR,
float(b) - NS_MATHML_DELIMITER_SHORTFALL);
float(b) - aPresContext->PointsToAppUnits(NS_MATHML_DELIMITER_SHORTFALL_POINTS));
isNearer = PRBool(float(PR_ABS(b - a)) <= (float(b) - c));
}
// Smaller: Mainly for transitory use, to compare two candidate
@ -1517,7 +1517,8 @@ IsSizeBetter(nscoord a, nscoord olda, nscoord b, PRUint32 aHint)
// overlap between the parts. This is important to cater for fonts
// with long glues.
static nscoord
ComputeSizeFromParts(nsGlyphCode* aGlyphs,
ComputeSizeFromParts(nsPresContext* aPresContext,
nsGlyphCode* aGlyphs,
nscoord* aSizes,
nscoord aTargetSize,
PRUint32 aHint)
@ -1538,7 +1539,7 @@ ComputeSizeFromParts(nsGlyphCode* aGlyphs,
// if we can afford more room, the default is to fill-up the target area
return aTargetSize;
}
if (IsSizeOK(computedSize, aTargetSize, aHint)) {
if (IsSizeOK(aPresContext, computedSize, aTargetSize, aHint)) {
// settle with the size, and let Paint() do the rest
return computedSize;
}
@ -1632,7 +1633,7 @@ nsMathMLChar::Stretch(nsPresContext* aPresContext,
// if we are not a largeop in display mode, return if size fits
if ((targetSize <= 0) ||
(!largeop && ((isVertical && charSize >= targetSize) ||
IsSizeOK(charSize, targetSize, aStretchHint)))) {
IsSizeOK(aPresContext, charSize, targetSize, aStretchHint)))) {
// ensure that the char later behaves like a normal char
// (will be reset back to its intrinsic value in case of dynamic updates)
mDirection = NS_STRETCH_DIRECTION_UNSUPPORTED;
@ -1699,7 +1700,7 @@ nsMathMLChar::Stretch(nsPresContext* aPresContext,
? bm.ascent + bm.descent
: bm.rightBearing - bm.leftBearing;
// always break when largeopOnly is set
if (largeopOnly || IsSizeOK(charSize, targetSize, aStretchHint)) {
if (largeopOnly || IsSizeOK(aPresContext, charSize, targetSize, aStretchHint)) {
#ifdef NOISY_SEARCH
printf(" size:%d OK!\n", size-1);
#endif
@ -1817,7 +1818,7 @@ nsMathMLChar::Stretch(nsPresContext* aPresContext,
// Build by parts if we have successfully computed the
// bounding metrics of all parts.
computedSize = ComputeSizeFromParts(chdata, sizedata, targetSize, aStretchHint);
computedSize = ComputeSizeFromParts(aPresContext, chdata, sizedata, targetSize, aStretchHint);
#ifdef NOISY_SEARCH
printf(" Font %s %s!\n",
NS_LossyConvertUTF16toASCII(fontName).get(),
@ -2245,7 +2246,7 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
nsRect clipRect;
nscoord dx, dy;
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
// get metrics data to be re-used later
PRInt32 i;
@ -2439,7 +2440,7 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
nsRect clipRect;
nscoord dx, dy;
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
// get metrics data to be re-used later
PRInt32 i;

Просмотреть файл

@ -626,7 +626,7 @@ nsMathMLContainerFrame::PropagateScriptStyleFor(nsIFrame* aFrame,
}
else {
// By default scriptminsize=8pt and scriptsizemultiplier=0.71
nscoord scriptminsize = NSIntPointsToTwips(NS_MATHML_SCRIPTMINSIZE);
nscoord scriptminsize = aFrame->GetPresContext()->PointsToAppUnits(NS_MATHML_SCRIPTMINSIZE);
float scriptsizemultiplier = NS_MATHML_SCRIPTSIZEMULTIPLIER;
#if 0
// XXX Bug 44201

Просмотреть файл

@ -459,14 +459,13 @@ nsMathMLFrame::CalcLength(nsPresContext* aPresContext,
NS_ASSERTION(aCSSValue.IsLengthUnit(), "not a length unit");
if (aCSSValue.IsFixedLengthUnit()) {
return aCSSValue.GetLengthTwips();
return aPresContext->TwipsToAppUnits(aCSSValue.GetLengthTwips());
}
nsCSSUnit unit = aCSSValue.GetUnit();
if (eCSSUnit_Pixel == unit) {
return NSFloatPixelsToTwips(aCSSValue.GetFloatValue(),
aPresContext->ScaledPixelsToTwips());
return nsPresContext::CSSPixelsToAppUnits(aCSSValue.GetFloatValue());
}
else if (eCSSUnit_EM == unit) {
const nsStyleFont* font = aStyleContext->GetStyleFont();

Просмотреть файл

@ -289,7 +289,7 @@ nsMathMLmfracFrame::Place(nsIRenderingContext& aRenderingContext,
// Get shifts
nsPresContext* presContext = GetPresContext();
nscoord onePixel = presContext->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aRenderingContext.SetFont(GetStyleFont()->mFont, nsnull);
nsCOMPtr<nsIFontMetrics> fm;

Просмотреть файл

@ -170,8 +170,8 @@ nsMathMLmmultiscriptsFrame::Place(nsIRenderingContext& aRenderingContext,
// scriptspace from TeX for extra spacing after sup/subscript (0.5pt in plain TeX)
// forced to be at least 1 pixel here
nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1);
nscoord scriptSpace = PR_MAX(NSFloatPointsToTwips(0.5f), onePixel);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
nscoord scriptSpace = PR_MAX(GetPresContext()->PointsToAppUnits(0.5f), onePixel);
/////////////////////////////////////
// first the shift for the subscript

Просмотреть файл

@ -450,7 +450,7 @@ nsMathMLmoFrame::ProcessOperatorData()
// little extra tuning to round lspace & rspace to at least a pixel so that
// operators don't look as if they are colliding with their operands
if (leftSpace || rightSpace) {
nscoord onePixel = presContext->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
if (leftSpace && leftSpace < onePixel)
leftSpace = onePixel;
if (rightSpace && rightSpace < onePixel)

Просмотреть файл

@ -260,7 +260,7 @@ nsMathMLmoverFrame::Place(nsIRenderingContext& aRenderingContext,
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
this);
this, 0, GetPresContext()->PointsToAppUnits(0.5f));
}
////////////////////////////////////
@ -281,7 +281,7 @@ nsMathMLmoverFrame::Place(nsIRenderingContext& aRenderingContext,
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(overFrame, overSize, bmOver);
nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
////////////////////
// Place Children

Просмотреть файл

@ -261,7 +261,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
// the thickness of the overline
ruleThickness = bmSqr.ascent;
// make sure that the rule appears on on screen
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
if (ruleThickness < onePixel) {
ruleThickness = onePixel;
}

Просмотреть файл

@ -230,7 +230,7 @@ nsMathMLmsqrtFrame::Reflow(nsPresContext* aPresContext,
// the thickness of the overline
ruleThickness = bmSqr.ascent;
// make sure that the rule appears on the screen
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
if (ruleThickness < onePixel) {
ruleThickness = onePixel;
}

Просмотреть файл

@ -87,7 +87,7 @@ nsMathMLmsubFrame::Place (nsIRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize)
{
// extra spacing after sup/subscript
nscoord scriptSpace = NSFloatPointsToTwips(0.5f); // 0.5pt as in plain TeX
nscoord scriptSpace = GetPresContext()->PointsToAppUnits(0.5f); // 0.5pt as in plain TeX
// check if the subscriptshift attribute is there
nscoord subScriptShift = 0;
@ -127,7 +127,7 @@ nsMathMLmsubFrame::PlaceSubScript (nsPresContext* aPresContext,
if (!mathMLFrame) return NS_ERROR_INVALID_ARG;
// force the scriptSpace to be atleast 1 pixel
aScriptSpace = PR_MAX(aPresContext->IntScaledPixelsToTwips(1), aScriptSpace);
aScriptSpace = PR_MAX(nsPresContext::CSSPixelsToAppUnits(1), aScriptSpace);
////////////////////////////////////
// Get the children's desired sizes

Просмотреть файл

@ -65,8 +65,8 @@ public:
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsIFrame* aForFrame,
nscoord aUserSubScriptShift = 0,
nscoord aScriptSpace = NSFloatPointsToTwips(0.5f));
nscoord aUserSubScriptShift,
nscoord aScriptSpace);
protected:
nsMathMLmsubFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}

Просмотреть файл

@ -144,7 +144,7 @@ nsMathMLmsubsupFrame::PlaceSubSupScript(nsPresContext* aPresContext,
if (!mathMLFrame) return NS_ERROR_INVALID_ARG;
// force the scriptSpace to be atleast 1 pixel
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aScriptSpace = PR_MAX(onePixel, aScriptSpace);
////////////////////////////////////

Просмотреть файл

@ -65,9 +65,9 @@ public:
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsIFrame* aForFrame,
nscoord aUserSubScriptShift = 0,
nscoord aUserSupScriptShift = 0,
nscoord aScriptSpace = NSFloatPointsToTwips(0.5f));
nscoord aUserSubScriptShift,
nscoord aUserSupScriptShift,
nscoord aScriptSpace);
protected:
nsMathMLmsubsupFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}

Просмотреть файл

@ -87,7 +87,7 @@ nsMathMLmsupFrame::Place(nsIRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize)
{
// extra spacing after sup/subscript
nscoord scriptSpace = NSFloatPointsToTwips(0.5f); // 0.5pt as in plain TeX
nscoord scriptSpace = GetPresContext()->PointsToAppUnits(0.5f); // 0.5pt as in plain TeX
// check if the superscriptshift attribute is there
nsAutoString value;
@ -127,7 +127,7 @@ nsMathMLmsupFrame::PlaceSuperScript(nsPresContext* aPresContext,
if (!mathMLFrame) return NS_ERROR_INVALID_ARG;
// force the scriptSpace to be at least 1 pixel
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aScriptSpace = PR_MAX(onePixel, aScriptSpace);
////////////////////////////////////

Просмотреть файл

@ -65,8 +65,8 @@ public:
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
nsIFrame* aForFrame,
nscoord aUserSupScriptShift = 0,
nscoord aScriptSpace = NSFloatPointsToTwips(0.5f));
nscoord aUserSupScriptShift,
nscoord aScriptSpace);
protected:
nsMathMLmsupFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}

Просмотреть файл

@ -257,7 +257,7 @@ nsMathMLmunderFrame::Place(nsIRenderingContext& aRenderingContext,
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
this);
this, 0, GetPresContext()->PointsToAppUnits(0.5f));
}
////////////////////////////////////
@ -278,7 +278,7 @@ nsMathMLmunderFrame::Place(nsIRenderingContext& aRenderingContext,
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(underFrame, underSize, bmUnder);
nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
////////////////////
// Place Children

Просмотреть файл

@ -294,7 +294,7 @@ nsMathMLmunderoverFrame::Place(nsIRenderingContext& aRenderingContext,
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
this);
this, 0, 0, GetPresContext()->PointsToAppUnits(0.5f));
}
////////////////////////////////////
@ -320,7 +320,7 @@ nsMathMLmunderoverFrame::Place(nsIRenderingContext& aRenderingContext,
GetReflowAndBoundingMetricsFor(underFrame, underSize, bmUnder);
GetReflowAndBoundingMetricsFor(overFrame, overSize, bmOver);
nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
////////////////////
// Place Children

Просмотреть файл

@ -644,15 +644,6 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
rv = mDeviceContext->GetDeviceContextFor(devspec,
*getter_AddRefs(mPrt->mPrintDC));
if (NS_SUCCEEDED(rv)) {
// Get the Original PixelScale incase we need to start changing it
mPrt->mPrintDC->GetCanonicalPixelScale(mPrt->mOrigDCScale);
// Shrink to Fit over rides and scaling values
if (!mPrt->mShrinkToFit) {
double scaling;
mPrt->mPrintSettings->GetScaling(&scaling);
mPrt->mPrintDC->SetCanonicalPixelScale(float(scaling)*mPrt->mOrigDCScale);
}
if(webContainer) {
// Always check and set the print settings first and then fall back
// onto the PrintService if there isn't a PrintSettings
@ -809,15 +800,6 @@ nsPrintEngine::PrintPreview(nsIPrintSettings* aPrintSettings,
nsCOMPtr<nsIPrintingPromptService> pps(do_QueryInterface(aWebProgressListener));
mPrt->mProgressDialogIsShown = pps != nsnull;
// Check to see if we need to transfer any of our old values
// over to the new PrintData object
if (mOldPrtPreview) {
mPrt->mOrigDCScale = mOldPrtPreview->mOrigDCScale;
} else {
// Get the Original PixelScale in case we need to start changing it
mDeviceContext->GetCanonicalPixelScale(mPrt->mOrigDCScale);
}
// You have to have both a PrintOptions and a PrintSetting to call
// CheckForPrinters.
// The user can pass in a null PrintSettings, but you can only
@ -946,14 +928,6 @@ nsPrintEngine::PrintPreview(nsIPrintSettings* aPrintSettings,
rv = mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(ppDC));
if (NS_SUCCEEDED(rv)) {
mDeviceContext->SetAltDevice(ppDC);
if (mPrt->mPrintSettings != nsnull) {
// Shrink to Fit over rides and scaling values
if (!mPrt->mShrinkToFit) {
double scaling;
mPrt->mPrintSettings->GetScaling(&scaling);
mDeviceContext->SetCanonicalPixelScale(float(scaling)*mPrt->mOrigDCScale);
}
}
}
}
}
@ -2024,7 +1998,11 @@ nsPrintEngine::ReflowDocList(nsPrintObject* aPO, PRBool aSetPixelScale)
} else {
ratio = aPO->mShrinkRatio - 0.005f; // round down
}
mPrt->mPrintDC->SetCanonicalPixelScale(ratio*mPrt->mOrigDCScale);
aPO->mZoomRatio = ratio;
} else if (!mPrt->mShrinkToFit) {
double scaling;
mPrt->mPrintSettings->GetScaling(&scaling);
aPO->mZoomRatio = float(scaling);
}
nsresult rv;
@ -2184,6 +2162,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
aPO->mPresContext->SetPageSize(adjSize);
aPO->mPresContext->SetIsRootPaginatedDocument(documentIsTopLevel);
aPO->mPresContext->SetPageScale(aPO->mZoomRatio);
rv = aPO->mPresShell->InitialReflow(adjSize.width, adjSize.height);
@ -3321,11 +3300,6 @@ nsPrintEngine::FinishPrintPreview()
mPrtPreview = mPrt;
mPrt = nsnull;
// Turning off the scaling of twips so any of the UI scrollbars
// will not get scaled
mPrtPreview->mPrintObject->mPresContext->SetScalingOfTwips(PR_FALSE);
mDeviceContext->SetCanonicalPixelScale(mPrtPreview->mOrigDCScale);
#endif // NS_PRINT_PREVIEW
return NS_OK;

Просмотреть файл

@ -46,7 +46,7 @@ nsPrintObject::nsPrintObject() :
mFrameType(eFrame), mContent(nsnull), mParent(nsnull),
mHasBeenPrinted(PR_FALSE), mDontPrint(PR_TRUE), mPrintAsIs(PR_FALSE),
mSharedPresShell(PR_FALSE), mInvisible(PR_FALSE),
mShrinkRatio(1.0)
mShrinkRatio(1.0), mZoomRatio(1.0)
{
}

Просмотреть файл

@ -88,6 +88,7 @@ public:
PRPackedBool mInvisible; // Indicates PO is set to not visible by CSS
float mShrinkRatio;
float mZoomRatio;
private:
nsPrintObject& operator=(const nsPrintObject& aOther); // not implemented

Просмотреть файл

@ -66,7 +66,6 @@
#include "nsContentUtils.h"
#include "nsStyleConsts.h"
#include "nsDOMError.h"
#include "nsIEnumerator.h"
#define IMPL_STYLE_RULE_INHERIT(_class, super) \
NS_IMETHODIMP _class::GetStyleSheet(nsIStyleSheet*& aSheet) const { return super::GetStyleSheet(aSheet); } \
@ -732,7 +731,8 @@ nsCSSGroupRule::GetStyleRuleAt(PRInt32 aIndex, nsICSSRule*& aRule) const
NS_IMETHODIMP
nsCSSGroupRule::EnumerateRulesForwards(RuleEnumFunc aFunc, void * aData) const
{
return NS_CONST_CAST(nsCSSGroupRule*, this)->mRules.EnumerateForwards(aFunc, aData) ? NS_OK : NS_ENUMERATOR_FALSE;
NS_CONST_CAST(nsCSSGroupRule*, this)->mRules.EnumerateForwards(aFunc, aData);
return NS_OK;
}
/*

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше