REGRESSION (r177656): Text in find-in-page yellow bouncy rectangle is not crisp
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jan 2015 23:57:17 +0000 (23:57 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jan 2015 23:57:17 +0000 (23:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140373
<rdar://problem/19447156>

Reviewed by Simon Fraser.

* page/mac/TextIndicatorWindow.mm:
(WebCore::TextIndicatorWindow::setTextIndicator):
Expand the window margin to the nearest integer.
The window was already being pixel-snapped, but then we'd translate by
the non-integral margin when building up the layer tree.
It's OK to do this on 2x because it's fine to have the margin be bigger
than needed.

* platform/spi/cg/CoreGraphicsSPI.h:
Add a CGCeiling to match CGFloor.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178304 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/mac/TextIndicatorWindow.mm
Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h

index a385e4d2f15a286e45392ae736ad392e0e46dde9..68c0d96745e9419dc12358eb0f0b80aa5f49707c 100644 (file)
@@ -1,3 +1,22 @@
+2015-01-12  Timothy Horton  <timothy_horton@apple.com>
+
+        REGRESSION (r177656): Text in find-in-page yellow bouncy rectangle is not crisp
+        https://bugs.webkit.org/show_bug.cgi?id=140373
+        <rdar://problem/19447156>
+
+        Reviewed by Simon Fraser.
+
+        * page/mac/TextIndicatorWindow.mm:
+        (WebCore::TextIndicatorWindow::setTextIndicator):
+        Expand the window margin to the nearest integer.
+        The window was already being pixel-snapped, but then we'd translate by
+        the non-integral margin when building up the layer tree.
+        It's OK to do this on 2x because it's fine to have the margin be bigger
+        than needed.
+
+        * platform/spi/cg/CoreGraphicsSPI.h:
+        Add a CGCeiling to match CGFloor.
+
 2015-01-12  Andreas Kling  <akling@apple.com>
 
         Guard web thread stuff with USE(WEB_THREAD) instead of PLATFORM(IOS).
index be3bf664f009ac7591a2e79b9fb2c364e7192e9e..7910494dc45181227dcd8f7563be4af391109aa6 100644 (file)
@@ -28,6 +28,7 @@
 
 #if PLATFORM(MAC)
 
+#import "CoreGraphicsSPI.h"
 #import "GraphicsContext.h"
 #import "QuartzCoreSPI.h"
 #import "TextIndicator.h"
@@ -389,6 +390,9 @@ void TextIndicatorWindow::setTextIndicator(PassRefPtr<TextIndicator> textIndicat
         verticalMargin = std::max(verticalMargin, textBoundingRectInScreenCoordinates.size.height * (midBounceScale - 1) + verticalMargin);
     }
 
+    horizontalMargin = CGCeiling(horizontalMargin);
+    verticalMargin = CGCeiling(verticalMargin);
+
     CGRect contentRect = CGRectInset(textBoundingRectInScreenCoordinates, -horizontalMargin, -verticalMargin);
     NSRect windowContentRect = [NSWindow contentRectForFrameRect:NSIntegralRect(NSRectFromCGRect(contentRect)) styleMask:NSBorderlessWindowMask];
     m_textIndicatorWindow = adoptNS([[NSWindow alloc] initWithContentRect:windowContentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
index 006b2fbd43b9d456a202298735c122700a6c1597..d7d246d82f94812921c65de2aa60968502dfad55 100644 (file)
@@ -97,10 +97,12 @@ typedef struct CGSRegionObject* CGRegionRef;
 #ifdef CGFLOAT_IS_DOUBLE
 #define CGRound(value) round((value))
 #define CGFloor(value) floor((value))
+#define CGCeiling(value) ceil((value))
 #define CGFAbs(value) fabs((value))
 #else
 #define CGRound(value) roundf((value))
 #define CGFloor(value) floorf((value))
+#define CGCeiling(value) ceilf((value))
 #define CGFAbs(value) fabsf((value))
 #endif