Title: [269540] trunk/Source/WebKit
- Revision
- 269540
- Author
- [email protected]
- Date
- 2020-11-06 13:59:21 -0800 (Fri, 06 Nov 2020)
Log Message
[macOS] Align left edge of presented calendar with left edge of date inputs
https://bugs.webkit.org/show_bug.cgi?id=218668
Reviewed by Tim Horton.
When a date input is activated, a calendar is presented by adding an
NSWindow containing an NSDatePicker to the screen. The frame of the
window is set to ensure proper alignment with the date input. However,
since the window's hasShadow is set to true, AppKit draws a thin border
and shadow around the window's contentView. This results in left border
of the window being drawn further out than the left border of the input
itself. If the hasShadow property is set to false, the issue is no longer
observed, and the calendar aligns with the input. However, this is not an
acceptable solution, since we lose the border and the shadow.
To ensure alignment between the border of the calendar view and the border
of the date input, we can inset the edges of the view. Note that the inset
is not applied along the y-axis, to avoid a gap between the bottom of the
date input and the top of the calendar view.
* UIProcess/mac/WebDateTimePickerMac.mm:
(-[WKDateTimePickerBackdropView drawRect:]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (269539 => 269540)
--- trunk/Source/WebKit/ChangeLog 2020-11-06 21:58:43 UTC (rev 269539)
+++ trunk/Source/WebKit/ChangeLog 2020-11-06 21:59:21 UTC (rev 269540)
@@ -1,3 +1,28 @@
+2020-11-06 Aditya Keerthi <[email protected]>
+
+ [macOS] Align left edge of presented calendar with left edge of date inputs
+ https://bugs.webkit.org/show_bug.cgi?id=218668
+
+ Reviewed by Tim Horton.
+
+ When a date input is activated, a calendar is presented by adding an
+ NSWindow containing an NSDatePicker to the screen. The frame of the
+ window is set to ensure proper alignment with the date input. However,
+ since the window's hasShadow is set to true, AppKit draws a thin border
+ and shadow around the window's contentView. This results in left border
+ of the window being drawn further out than the left border of the input
+ itself. If the hasShadow property is set to false, the issue is no longer
+ observed, and the calendar aligns with the input. However, this is not an
+ acceptable solution, since we lose the border and the shadow.
+
+ To ensure alignment between the border of the calendar view and the border
+ of the date input, we can inset the edges of the view. Note that the inset
+ is not applied along the y-axis, to avoid a gap between the bottom of the
+ date input and the top of the calendar view.
+
+ * UIProcess/mac/WebDateTimePickerMac.mm:
+ (-[WKDateTimePickerBackdropView drawRect:]):
+
2020-11-06 Alex Christensen <[email protected]>
Fix build with different unified source arrangement.
Modified: trunk/Source/WebKit/UIProcess/mac/WebDateTimePickerMac.mm (269539 => 269540)
--- trunk/Source/WebKit/UIProcess/mac/WebDateTimePickerMac.mm 2020-11-06 21:58:43 UTC (rev 269539)
+++ trunk/Source/WebKit/UIProcess/mac/WebDateTimePickerMac.mm 2020-11-06 21:59:21 UTC (rev 269540)
@@ -34,6 +34,7 @@
constexpr CGFloat kCalendarWidth = 139;
constexpr CGFloat kCalendarHeight = 148;
constexpr CGFloat kCalendarCornerRadius = 10;
+constexpr CGFloat kWindowBorderSize = 0.5;
constexpr NSString * kDateFormatString = @"yyyy-MM-dd";
constexpr NSString * kDateTimeFormatString = @"yyyy-MM-dd'T'HH:mm";
constexpr NSString * kDateTimeWithSecondsFormatString = @"yyyy-MM-dd'T'HH:mm:ss";
@@ -152,11 +153,11 @@
[[NSColor controlBackgroundColor] setFill];
- NSRect frame = self.frame;
- NSPoint topLeft = NSMakePoint(NSMinX(frame), NSMaxY(frame));
- NSPoint topRight = NSMakePoint(NSMaxX(frame), NSMaxY(frame));
- NSPoint bottomRight = NSMakePoint(NSMaxX(frame), NSMinY(frame));
- NSPoint bottomLeft = NSMakePoint(NSMinX(frame), NSMinY(frame));
+ NSRect rect = NSInsetRect(self.frame, kWindowBorderSize, 0);
+ NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect));
+ NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect));
+ NSPoint bottomRight = NSMakePoint(NSMaxX(rect), NSMinY(rect));
+ NSPoint bottomLeft = NSMakePoint(NSMinX(rect), NSMinY(rect));
NSBezierPath *path = [NSBezierPath bezierPath];
[path moveToPoint:topLeft];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes