Bug 248594

Summary: [MQ4] Replace the last uses of legacy media query code
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: CSSAssignee: Antti Koivisto <koivisto>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, changseok, darin, eric.carlson, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, japhet, jer.noble, macpherson, menard, philipj, sergio, webkit-bug-importer, youssefdevelops, y_soliman
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 180234, 248619    
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
none
Patch for landing
koivisto: commit-queue+
Patch
none
Patch for landing none

Description Antti Koivisto 2022-12-01 03:23:52 PST
In preloader etc.
Comment 1 Radar WebKit Bug Importer 2022-12-01 03:25:06 PST
<rdar://problem/102853711>
Comment 2 Antti Koivisto 2022-12-01 08:28:00 PST
Created attachment 463831 [details]
Patch
Comment 3 Antti Koivisto 2022-12-01 08:48:37 PST
Created attachment 463832 [details]
Patch
Comment 4 Darin Adler 2022-12-01 08:54:39 PST
Comment on attachment 463832 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=463832&action=review

What a great moment!

> Source/WebCore/style/StyleScope.cpp:702
>  
> +

Extra blank line here.

> Source/WebKitLegacy/mac/DOM/DOM.mm:710
>      HTMLLinkElement& link = *static_cast<HTMLLinkElement*>(core(self));
> -
> -    auto& media = link.attributeWithoutSynchronization(HTMLNames::mediaAttr);
> -    if (media.isEmpty())
> -        return true;
> -
> -    Document& document = link.document();
> -    auto mediaQuerySet = MediaQuerySet::create(media, MediaQueryParserContext(document));
> -    return LegacyMediaQueryEvaluator { "screen"_s, document, document.renderView() ? &document.renderView()->style() : nullptr }.evaluate(mediaQuerySet.get());
> +    return link.mediaAttributeMatches();

I think we should just one-line this:

    return static_cast<HTMLLinkElement*>(core(self))->mediaAttributeMatches();

Also wondering why we need static_cast here, maybe it should be downcast, or maybe we need to overload core so we don’t need a typecast. But since this is legacy WebKit, I guess we can just leave it as-is.
Comment 5 Antti Koivisto 2022-12-01 09:20:54 PST
Created attachment 463833 [details]
Patch for landing
Comment 6 Antti Koivisto 2022-12-01 09:30:20 PST
Created attachment 463834 [details]
Patch
Comment 7 Antti Koivisto 2022-12-01 09:49:46 PST
Created attachment 463836 [details]
Patch for landing
Comment 8 EWS 2022-12-01 12:54:23 PST
Committed 257252@main (be64fdb44bd3): <https://commits.webkit.org/257252@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 463836 [details].