Changeset 290054 in webkit
- Timestamp:
- Feb 17, 2022, 12:41:01 PM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r290053 r290054 1 2022-02-17 Aditya Keerthi <akeerthi@apple.com> 2 3 [macOS] Light appearance text fields are invisible in Increased Contrast mode 4 https://bugs.webkit.org/show_bug.cgi?id=236753 5 rdar://89093315 6 7 Reviewed by Wenson Hsieh. 8 9 In Big Sur, the artwork for many form controls, including text fields, was 10 changed at the system level. When painting native text fields, WebKit has 11 long used the "borders only" option to support painting custom background 12 colors. System-level changes in Big Sur broke the behavior of light appearance 13 "borders only" text fields in Increased Contrast mode. 14 15 Until the artwork is updated at the system-level, work around the issue 16 in WebKit by painting our own borders for text fields under the necessary 17 conditions. 18 19 No new tests, as tests that change system preferences are often unreliable, 20 and we do not have existing hooks to toggle Increased Contrast mode. 21 22 * rendering/RenderThemeMac.h: 23 * rendering/RenderThemeMac.mm: 24 (WebCore::RenderThemeMac::shouldPaintCustomTextField const): 25 (WebCore::RenderThemeMac::paintTextField): 26 1 27 2022-02-17 Commit Queue <commit-queue@webkit.org> 2 28 -
trunk/Source/WebCore/rendering/RenderThemeMac.h
r290053 r290054 166 166 String fileListNameForWidth(const FileList*, const FontCascade&, int width, bool multipleFilesAllowed) const final; 167 167 168 bool shouldPaintCustomTextField(const RenderObject&) const; 169 168 170 Color systemColor(CSSValueID, OptionSet<StyleColorOptions>) const final; 169 171 -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r290053 r290054 1096 1096 #endif 1097 1097 1098 bool RenderThemeMac::shouldPaintCustomTextField(const RenderObject& renderer) const 1099 { 1100 // <rdar://problem/88948646> Prevent AppKit from painting text fields in the light appearance 1101 // with increased contrast, as the border is not painted, rendering the control invisible. 1102 #if HAVE(LARGE_CONTROL_SIZE) 1103 return Theme::singleton().userPrefersContrast() && !renderer.useDarkAppearance(); 1104 #else 1105 UNUSED_PARAM(renderer); 1106 return false; 1107 #endif 1108 } 1109 1098 1110 bool RenderThemeMac::paintTextField(const RenderObject& o, const PaintInfo& paintInfo, const FloatRect& r) 1099 1111 { 1100 LocalCurrentGraphicsContext localContext(paintInfo.context()); 1101 1102 // <rdar://problem/22896977> We adjust the paint rect here to account for how AppKit draws the text 1103 // field cell slightly smaller than the rect we pass to drawWithFrame. 1104 FloatRect adjustedPaintRect(r); 1105 AffineTransform transform = paintInfo.context().getCTM(); 1106 if (transform.xScale() > 1 || transform.yScale() > 1) { 1107 adjustedPaintRect.inflateX(1 / transform.xScale()); 1108 adjustedPaintRect.inflateY(2 / transform.yScale()); 1109 adjustedPaintRect.move(0, -1 / transform.yScale()); 1110 } 1111 NSTextFieldCell *textField = this->textField(); 1112 1113 GraphicsContextStateSaver stateSaver(paintInfo.context()); 1114 1115 [textField setEnabled:(isEnabled(o) && !isReadOnlyControl(o))]; 1116 [textField drawWithFrame:NSRect(adjustedPaintRect) inView:documentViewFor(o)]; 1117 1118 [textField setControlView:nil]; 1112 FloatRect paintRect(r); 1113 auto& context = paintInfo.context(); 1114 1115 LocalCurrentGraphicsContext localContext(context); 1116 GraphicsContextStateSaver stateSaver(context); 1117 1118 auto enabled = isEnabled(o) && !isReadOnlyControl(o); 1119 1120 if (shouldPaintCustomTextField(o)) { 1121 constexpr int strokeThickness = 1; 1122 1123 FloatRect strokeRect(paintRect); 1124 strokeRect.inflate(-strokeThickness / 2.0f); 1125 1126 context.setStrokeColor(enabled ? Color::black : Color::darkGray); 1127 context.setStrokeStyle(SolidStroke); 1128 context.strokeRect(strokeRect, strokeThickness); 1129 } else { 1130 // <rdar://problem/22896977> We adjust the paint rect here to account for how AppKit draws the text 1131 // field cell slightly smaller than the rect we pass to drawWithFrame. 1132 AffineTransform transform = context.getCTM(); 1133 if (transform.xScale() > 1 || transform.yScale() > 1) { 1134 paintRect.inflateX(1 / transform.xScale()); 1135 paintRect.inflateY(2 / transform.yScale()); 1136 paintRect.move(0, -1 / transform.yScale()); 1137 } 1138 1139 NSTextFieldCell *textField = this->textField(); 1140 [textField setEnabled:enabled]; 1141 [textField drawWithFrame:NSRect(paintRect) inView:documentViewFor(o)]; 1142 [textField setControlView:nil]; 1143 } 1119 1144 1120 1145 #if ENABLE(DATALIST_ELEMENT) … … 1124 1149 const auto& input = downcast<HTMLInputElement>(*(o.generatingNode())); 1125 1150 if (input.list()) 1126 paintListButtonForInput(o, paintInfo.context(), adjustedPaintRect);1151 paintListButtonForInput(o, context, paintRect); 1127 1152 #endif 1128 1153
Note:
See TracChangeset
for help on using the changeset viewer.