Changeset 267131 in webkit


Ignore:
Timestamp:
Sep 15, 2020 8:10:30 PM (4 years ago)
Author:
Aditya Keerthi
Message:

[macOS] Date pickers should respect the document's color scheme
https://bugs.webkit.org/show_bug.cgi?id=216514
<rdar://problem/68889548>

Reviewed by Tim Horton.

Source/WebCore:

Added the useDarkAppearance property to DateTimeChooserParameters, which
is based on Document::useDarkAppearance and the associated element's
computed style.

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::setupDateTimeChooserParameters):

  • platform/DateTimeChooserParameters.h:

(WebCore::DateTimeChooserParameters::encode const):
(WebCore::DateTimeChooserParameters::decode):

Source/WebKit:

Use the appearance property of NSWindow to ensure the appearance of the
contained NSDatePicker matches the value encoded in DateTimeChooserParameters.

  • UIProcess/mac/WebDateTimePickerMac.mm:

(-[WKDateTimePicker initWithParams:inView:]):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267126 r267131  
     12020-09-15  Aditya Keerthi  <akeerthi@apple.com>
     2
     3        [macOS] Date pickers should respect the document's color scheme
     4        https://bugs.webkit.org/show_bug.cgi?id=216514
     5        <rdar://problem/68889548>
     6
     7        Reviewed by Tim Horton.
     8
     9        Added the useDarkAppearance property to DateTimeChooserParameters, which
     10        is based on Document::useDarkAppearance and the associated element's
     11        computed style.
     12
     13        * html/HTMLInputElement.cpp:
     14        (WebCore::HTMLInputElement::setupDateTimeChooserParameters):
     15        * platform/DateTimeChooserParameters.h:
     16        (WebCore::DateTimeChooserParameters::encode const):
     17        (WebCore::DateTimeChooserParameters::decode):
     18
    1192020-09-15  Yusuke Suzuki  <ysuzuki@apple.com>
    220
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r266114 r267131  
    21372137        parameters.anchorRectInRootView = IntRect();
    21382138    parameters.currentValue = value();
    2139     parameters.isAnchorElementRTL = computedStyle()->direction() == TextDirection::RTL;
     2139
     2140    auto* computedStyle = this->computedStyle();
     2141    parameters.isAnchorElementRTL = computedStyle->direction() == TextDirection::RTL;
     2142    parameters.useDarkAppearance = document().useDarkAppearance(computedStyle);
    21402143
    21412144#if ENABLE(DATALIST_ELEMENT)
  • trunk/Source/WebCore/platform/DateTimeChooserParameters.h

    r266063 r267131  
    5050    bool required;
    5151    bool isAnchorElementRTL;
     52    bool useDarkAppearance;
    5253
    5354    template<class Encoder> void encode(Encoder&) const;
     
    7172    encoder << required;
    7273    encoder << isAnchorElementRTL;
     74    encoder << useDarkAppearance;
    7375}
    7476
     
    128130        return WTF::nullopt;
    129131
    130     return {{ WTFMove(type), anchorRectInRootView, WTFMove(locale), WTFMove(currentValue), WTFMove(suggestionValues), WTFMove(localizedSuggestionValues), WTFMove(suggestionLabels), minimum, maximum, step, stepBase, required, isAnchorElementRTL }};
     132    bool useDarkAppearance;
     133    if (!decoder.decode(useDarkAppearance))
     134        return WTF::nullopt;
     135
     136    return {{ WTFMove(type), anchorRectInRootView, WTFMove(locale), WTFMove(currentValue), WTFMove(suggestionValues), WTFMove(localizedSuggestionValues), WTFMove(suggestionLabels), minimum, maximum, step, stepBase, required, isAnchorElementRTL, useDarkAppearance }};
    131137}
    132138
  • trunk/Source/WebKit/ChangeLog

    r267123 r267131  
     12020-09-15  Aditya Keerthi  <akeerthi@apple.com>
     2
     3        [macOS] Date pickers should respect the document's color scheme
     4        https://bugs.webkit.org/show_bug.cgi?id=216514
     5        <rdar://problem/68889548>
     6
     7        Reviewed by Tim Horton.
     8
     9        Use the appearance property of NSWindow to ensure the appearance of the
     10        contained NSDatePicker matches the value encoded in DateTimeChooserParameters.
     11
     12        * UIProcess/mac/WebDateTimePickerMac.mm:
     13        (-[WKDateTimePicker initWithParams:inView:]):
     14
    1152020-09-15  Alex Christensen  <achristensen@webkit.org>
    216
  • trunk/Source/WebKit/UIProcess/mac/WebDateTimePickerMac.mm

    r267085 r267131  
    249249    [_datePicker setMinDate:[NSDate dateWithTimeIntervalSince1970:_params.minimum / 1000.0]];
    250250    [_datePicker setMaxDate:[NSDate dateWithTimeIntervalSince1970:_params.maximum / 1000.0]];
     251
     252    [_enclosingWindow setAppearance:[NSAppearance appearanceNamed:_params.useDarkAppearance ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]];
    251253}
    252254
Note: See TracChangeset for help on using the changeset viewer.