+2015-06-22 Tim Horton <timothy_horton@apple.com>
+
+ [TextIndicator] Text shifts one pixel to the left when I force click to bring up Lookup in Mail messages
+ https://bugs.webkit.org/show_bug.cgi?id=146214
+ <rdar://problem/20782970>
+
+ Reviewed by Dean Jackson.
+
+ * page/mac/TextIndicatorWindow.mm:
+ (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]):
+ (WebCore::TextIndicatorWindow::setTextIndicator):
+ (-[WebTextIndicatorView initWithFrame:textIndicator:margin:]): Deleted.
+ When the WebView is at a nonintegral position, we can end up needing a TextIndicator
+ with a nonintegral position. We need to round the window position, so we need to apply
+ the fractional part to the indicator layers inside, not to the window.
+
2015-06-22 Myles C. Maxfield <mmaxfield@apple.com>
[iOS] Arabic text styled with Georgia is rendered as boxes
BOOL _fadingOut;
}
-- (instancetype)initWithFrame:(NSRect)frame textIndicator:(PassRefPtr<TextIndicator>)textIndicator margin:(NSSize)margin;
+- (instancetype)initWithFrame:(NSRect)frame textIndicator:(PassRefPtr<TextIndicator>)textIndicator margin:(NSSize)margin offset:(NSPoint)offset;
- (void)present;
- (void)hideWithCompletionHandler:(void(^)(void))completionHandler;
@synthesize fadingOut = _fadingOut;
-- (instancetype)initWithFrame:(NSRect)frame textIndicator:(PassRefPtr<TextIndicator>)textIndicator margin:(NSSize)margin
+- (instancetype)initWithFrame:(NSRect)frame textIndicator:(PassRefPtr<TextIndicator>)textIndicator margin:(NSSize)margin offset:(NSPoint)offset
{
if (!(self = [super initWithFrame:frame]))
return nil;
RetainPtr<CGColorRef> gradientLightColor = [NSColor colorWithDeviceRed:.949 green:.937 blue:0 alpha:1].CGColor;
for (const auto& textRect : _textIndicator->textRectsInBoundingRectCoordinates()) {
- FloatRect bounceLayerRect = textRect;
+ FloatRect offsetTextRect = textRect;
+ offsetTextRect.move(offset.x, offset.y);
+
+ FloatRect bounceLayerRect = offsetTextRect;
bounceLayerRect.move(_margin.width, _margin.height);
bounceLayerRect.inflateX(horizontalBorder);
bounceLayerRect.inflateY(verticalBorder);
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]);
+ NSRect windowContentRect = [NSWindow contentRectForFrameRect:NSRectFromCGRect(contentRect) styleMask:NSBorderlessWindowMask];
+ NSRect integralWindowContentRect = NSIntegralRect(windowContentRect);
+ NSPoint fractionalTextOffset = NSMakePoint(windowContentRect.origin.x - integralWindowContentRect.origin.x, windowContentRect.origin.y - integralWindowContentRect.origin.y);
+ m_textIndicatorWindow = adoptNS([[NSWindow alloc] initWithContentRect:integralWindowContentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
[m_textIndicatorWindow setBackgroundColor:[NSColor clearColor]];
[m_textIndicatorWindow setOpaque:NO];
[m_textIndicatorWindow setIgnoresMouseEvents:YES];
- m_textIndicatorView = adoptNS([[WebTextIndicatorView alloc] initWithFrame:NSMakeRect(0, 0, [m_textIndicatorWindow frame].size.width, [m_textIndicatorWindow frame].size.height) textIndicator:m_textIndicator margin:NSMakeSize(horizontalMargin, verticalMargin)]);
+ m_textIndicatorView = adoptNS([[WebTextIndicatorView alloc] initWithFrame:NSMakeRect(0, 0, [m_textIndicatorWindow frame].size.width, [m_textIndicatorWindow frame].size.height) textIndicator:m_textIndicator margin:NSMakeSize(horizontalMargin, verticalMargin) offset:fractionalTextOffset]);
[m_textIndicatorWindow setContentView:m_textIndicatorView.get()];
[[m_targetView window] addChildWindow:m_textIndicatorWindow.get() ordered:NSWindowAbove];