WebKit Bugzilla
Attachment 346249 Details for
Bug 188124
: [iOS] WKColorPicker's selection indicator doesn't always cover the selected swatch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188124-20180731202612.patch (text/plain), 8.27 KB, created by
Aditya Keerthi
on 2018-07-31 20:26:13 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Aditya Keerthi
Created:
2018-07-31 20:26:13 PDT
Size:
8.27 KB
patch
obsolete
>Subversion Revision: 234440 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index bd1d97fc333c8d0e52f987711855f12eb731bc6a..3064e913827f07835f7e7cbabdec6ef382a97084 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,31 @@ >+2018-07-31 Aditya Keerthi <akeerthi@apple.com> >+ >+ [iOS] WKColorPicker's selection indicator doesn't always cover the selected swatch >+ https://bugs.webkit.org/show_bug.cgi?id=188124 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ - On iPhone, the size of an individual color swatch can change on rotation. In >+ this case, we should resize the selection indicator along with the swatch. Added >+ a new delegate method to WKColorMatrixViewDelegate to notify the color picker if >+ the matrix was redrawn. We then resize the selection indicator to match the >+ selected swatch's size. >+ >+ - On iPad, the selection indicator should have rounded corners if it's at the >+ corner of the color picker. Otherwise, part of the indicator will be hidden by >+ the popover. The selected swatch's position is checked before drawing the >+ indicator. If it's at one of the four corners of the picker, the appropriate mask >+ is applied to the color selection indicator's border. >+ >+ * UIProcess/ios/forms/WKFormColorPicker.h: >+ * UIProcess/ios/forms/WKFormColorPicker.mm: >+ (-[WKColorMatrixView layoutSubviews]): >+ (-[WKColorPicker initWithView:]): >+ (-[WKColorPicker drawSelectionIndicatorForColorButton:]): >+ (-[WKColorPicker colorMatrixViewDidLayoutSubviews:]): >+ (-[WKColorPicker colorMatrixView:didTapColorButton:]): >+ (-[WKColorPicker didPanColors:]): >+ > 2018-07-31 John Wilander <wilander@apple.com> > > Resource Load Statistics: Remove partitioned cookies for reduced complexity, lower memory footprint, and ability to support more platforms >diff --git a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.h b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.h >index 8dca9a45e84018d4242dccb2b069141f50d38d24..b6f4bd2a14f38e43cd79a2e3c2b1ccddde7129a0 100644 >--- a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.h >+++ b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.h >@@ -34,6 +34,7 @@ OBJC_CLASS WKContentView; > > @protocol WKColorMatrixViewDelegate > - (void)colorMatrixView:(WKColorMatrixView *)matrixView didTapColorButton:(WKColorButton *)colorButton; >+- (void)colorMatrixViewDidLayoutSubviews:(WKColorMatrixView *)matrixView; > @end > > @interface WKColorPicker : NSObject<WKFormControl, WKColorMatrixViewDelegate> >diff --git a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm >index b65b14ffe083a113a23e6a571d0e59d48bb45735..7b712b0826e311cb8bfb29c969a86caf4288dee5 100644 >--- a/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm >+++ b/Source/WebKit/UIProcess/ios/forms/WKFormColorPicker.mm >@@ -41,7 +41,8 @@ SOFT_LINK_PRIVATE_FRAMEWORK(PencilKit) > SOFT_LINK_CLASS(PencilKit, PKColorMatrixView) > > static const CGFloat additionalKeyboardAffordance = 80; >-static const CGFloat colorSelectionIndicatorBorderWidth = 2; >+static const CGFloat colorSelectionIndicatorBorderWidth = 4; >+static const CGFloat colorSelectionIndicatorCornerRadius = 13; > static const CGFloat pickerWidthForPopover = 280; > static const CGFloat topColorMatrixPadding = 8; > >@@ -132,6 +133,8 @@ using namespace WebKit; > button.frame = CGRectMake(col * buttonWidth, row * buttonHeight, buttonWidth, buttonHeight); > } > } >+ >+ [self.delegate colorMatrixViewDidLayoutSubviews:self]; > } > > - (void)colorButtonTapped:(WKColorButton *)colorButton >@@ -148,8 +151,11 @@ using namespace WebKit; > RetainPtr<UIView> _colorPicker; > > RetainPtr<UIView> _colorSelectionIndicator; >+ RetainPtr<CAShapeLayer> _colorSelectionIndicatorBorder; >+ > RetainPtr<WKColorMatrixView> _topColorMatrix; > RetainPtr<WKColorMatrixView> _mainColorMatrix; >+ WeakObjCPtr<WKColorButton> _selectedColorButton; > > RetainPtr<UIPanGestureRecognizer> _colorPanGR; > } >@@ -190,16 +196,53 @@ using namespace WebKit; > [_colorPicker addSubview:_topColorMatrix.get()]; > > _colorSelectionIndicator = adoptNS([[UIView alloc] initWithFrame:CGRectZero]); >- [[_colorSelectionIndicator layer] setBorderColor:[[UIColor whiteColor] CGColor]]; >- [[_colorSelectionIndicator layer] setBorderWidth:colorSelectionIndicatorBorderWidth]; >+ [_colorSelectionIndicator setClipsToBounds:YES]; > [_colorPicker addSubview:_colorSelectionIndicator.get()]; > >+ _colorSelectionIndicatorBorder = adoptNS([[CAShapeLayer alloc] init]); >+ [_colorSelectionIndicatorBorder setLineWidth:colorSelectionIndicatorBorderWidth]; >+ [_colorSelectionIndicatorBorder setStrokeColor:[UIColor whiteColor].CGColor]; >+ [_colorSelectionIndicatorBorder setFillColor:[UIColor clearColor].CGColor]; >+ [[_colorSelectionIndicator layer] addSublayer:_colorSelectionIndicatorBorder.get()]; >+ > _colorPanGR = adoptNS([[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPanColors:)]); > [_colorPicker addGestureRecognizer:_colorPanGR.get()]; > > return self; > } > >+- (void)drawSelectionIndicatorForColorButton:(WKColorButton *)colorButton >+{ >+ _selectedColorButton = colorButton; >+ >+ CGRect frame = [_colorPicker convertRect:colorButton.bounds fromView:colorButton]; >+ [_colorSelectionIndicator setFrame:frame]; >+ >+ UIRectCorner roundCorner = 0; >+ if (currentUserInterfaceIdiomIsPad()) { >+ CGRect colorPickerBounds = [_colorPicker bounds]; >+ >+ bool minXEqual = std::abs(CGRectGetMinX(frame) - CGRectGetMinX(colorPickerBounds)) < FLT_EPSILON; >+ bool minYEqual = std::abs(CGRectGetMinY(frame) - CGRectGetMinY(colorPickerBounds)) < FLT_EPSILON; >+ bool maxXEqual = std::abs(CGRectGetMaxX(frame) - CGRectGetMaxX(colorPickerBounds)) < FLT_EPSILON; >+ bool maxYEqual = std::abs(CGRectGetMaxY(frame) - CGRectGetMaxY(colorPickerBounds)) < FLT_EPSILON; >+ >+ // On iPad, round one corner of the indicator if it's at the corner of the picker, to match the popover. >+ if (minXEqual && minYEqual) >+ roundCorner = UIRectCornerTopLeft; >+ else if (maxXEqual && minYEqual) >+ roundCorner = UIRectCornerTopRight; >+ else if (minXEqual && maxYEqual) >+ roundCorner = UIRectCornerBottomLeft; >+ else if (maxXEqual && maxYEqual) >+ roundCorner = UIRectCornerBottomRight; >+ } >+ >+ UIBezierPath *cornerMaskPath = [UIBezierPath bezierPathWithRoundedRect:colorButton.bounds byRoundingCorners:roundCorner cornerRadii:CGSizeMake(colorSelectionIndicatorCornerRadius, colorSelectionIndicatorCornerRadius)]; >+ [_colorSelectionIndicatorBorder setFrame:colorButton.bounds]; >+ [_colorSelectionIndicatorBorder setPath:cornerMaskPath.CGPath]; >+} >+ > - (void)setControlValueFromUIColor:(UIColor *)uiColor > { > WebCore::Color color(uiColor.CGColor); >@@ -223,9 +266,18 @@ using namespace WebKit; > > #pragma mark WKColorMatrixViewDelegate > >+- (void)colorMatrixViewDidLayoutSubviews:(WKColorMatrixView *)matrixView >+{ >+ if ([_selectedColorButton superview] == matrixView) >+ [self drawSelectionIndicatorForColorButton:_selectedColorButton.get().get()]; >+} >+ > - (void)colorMatrixView:(WKColorMatrixView *)matrixView didTapColorButton:(WKColorButton *)colorButton > { >- [_colorSelectionIndicator setFrame:[_colorPicker convertRect:colorButton.bounds fromView:colorButton]]; >+ if (_selectedColorButton.get().get() == colorButton) >+ return; >+ >+ [self drawSelectionIndicatorForColorButton:colorButton]; > [self setControlValueFromUIColor:colorButton.color]; > } > >@@ -236,8 +288,12 @@ using namespace WebKit; > CGPoint location = [gestureRecognizer locationInView:gestureRecognizer.view]; > UIView *view = [gestureRecognizer.view hitTest:location withEvent:nil]; > if ([view isKindOfClass:[WKColorButton class]]) { >- [_colorSelectionIndicator setFrame:[_colorPicker convertRect:[view bounds] fromView:view]]; >- [self setControlValueFromUIColor:[(WKColorButton *)view color]]; >+ WKColorButton *colorButton = (WKColorButton *)view; >+ if (_selectedColorButton.get().get() == colorButton) >+ return; >+ >+ [self drawSelectionIndicatorForColorButton:colorButton]; >+ [self setControlValueFromUIColor:colorButton.color]; > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188124
:
345957
|
345996
|
346223
|
346234
|
346236
| 346249