Commit 6f9abbc0 authored by ggaren's avatar ggaren
Browse files

Reviewed by Anders.

        
        Factored common scaling code into a helper function.

        * platform/mac/ScreenMac.mm:
        (WebCore::scale):
        (WebCore::scaleScreenRectToPageCoordinates):
        (WebCore::scalePageRectToScreenCoordinates):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@17104 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3e6b89cc
2006-10-17 Geoffrey Garen <ggaren@apple.com>
Reviewed by Anders.
Factored common scaling code into a helper function.
* platform/mac/ScreenMac.mm:
(WebCore::scale):
(WebCore::scaleScreenRectToPageCoordinates):
(WebCore::scalePageRectToScreenCoordinates):
2006-10-17 Steve Falkenburg <sfalken@apple.com>
 
Build fixes
......@@ -40,6 +40,14 @@ static NSScreen* screen(const Page* page)
return [NSScreen mainScreen];
}
static inline FloatRect scale(const FloatRect& rect, const NSSize& scaleSize)
{
float scaleX = scaleSize.width;
float scaleY = scaleSize.height;
return FloatRect(rect.x() * scaleX, rect.y() * scaleY, rect.width() * scaleX, rect.height() * scaleY);
}
NSRect flipScreenRect(NSRect rect)
{
rect.origin.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - NSMaxY(rect);
......@@ -55,19 +63,13 @@ NSPoint flipScreenPoint(NSPoint point)
FloatRect scaleScreenRectToPageCoordinates(const FloatRect& rect, const Page* page)
{
NSSize scaleSize = [[page->bridge() outerView] convertSize:NSMakeSize(1.0, 1.0) fromView:nil];
float scaleX = scaleSize.width;
float scaleY = scaleSize.height;
return FloatRect(rect.x() * scaleX, rect.y() * scaleY, rect.width() * scaleX, rect.height() * scaleY);
return scale(rect, scaleSize);
}
FloatRect scalePageRectToScreenCoordinates(const FloatRect& rect, const Page* page)
{
NSSize scaleSize = [[page->bridge() outerView] convertSize:NSMakeSize(1.0, 1.0) toView:nil];
float scaleX = scaleSize.width;
float scaleY = scaleSize.height;
return FloatRect(rect.x() * scaleX, rect.y() * scaleY, rect.width() * scaleX, rect.height() * scaleY);
return scale(rect, scaleSize);
}
int screenDepth(const Page* page)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment