Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for a
media
attribute on `<meta name="theme-color" cont…
…ent="...">` https://bugs.webkit.org/show_bug.cgi?id=224389 <rdar://problem/74991621> Reviewed by Ryosuke Niwa. Source/WebCore: Tests: WKWebViewThemeColor.MetaElementValidNameAndColorAndMedia WKWebViewThemeColor.MetaElementInvalidName WKWebViewThemeColor.MetaElementInvalidColor WKWebViewThemeColor.MetaElementInvalidMedia WKWebViewThemeColor.MetaElementMultipleValid WKWebViewThemeColor.MetaElementValidSubframe WKWebViewThemeColor.KVO * html/HTMLMetaElement.idl: * html/HTMLMetaElement.h: * html/HTMLMetaElement.cpp: (WebCore::parseMedia): Added. (WebCore::mediaMatches): Added. (WebCore::HTMLMetaElement::mediaAttributeMatches): Added. (WebCore::HTMLMetaElement::contentColor): Added. (WebCore::HTMLMetaElement::attributeChanged): (WebCore::HTMLMetaElement::parseAttribute): (WebCore::HTMLMetaElement::removedFromAncestor): (WebCore::HTMLMetaElement::process): Add support for a reflected `media` attribute. Cache the most recently parsed `media` (which becomes a `Ref<MediaQuerySet>`) and `content` (which can become a `Color`) to avoid doing repeated work when determining the active theme color after media state changes. Notify the `Document` whenever the `name` or `content` or `media` attribute changes if the new or old value will be or would have been related to calculating the theme color. * dom/Document.h: (WebCore::Document::themeColor const): Deleted. * dom/Document.cpp: (WebCore::Document::themeColor): Added. (WebCore::Document::metaElementThemeColorChanged): Added. (WebCore::Document::determineActiveThemeColorMetaElement): Added. (WebCore::Document::themeColorChanged): (WebCore::Document::updateElementsAffectedByMediaQueries): (WebCore::Document::processMetaElementThemeColor): Deleted. Make calculating the theme color into a two stage process: 1. find all `<meta name="theme-color">` that have a valid CSS color `content` in tree order 2. return the `HTMLMetaElement::contentColor` of the first item from step 1 that `HTMLMetaElement::mediaAttributeMatches` This is done so that `Document::updateElementsAffectedByMediaQueries` doesn't have to repeat step 1 each time it's run (which can be often) and instead only needs to iterate a (likely very small) list in step 2. The actions/situations listed above would clear the cached data from both steps, meaning that the next `Document::themeColor` will do a full recalculation. Notify the UIProcess of a change in theme color if the result of step 2 is different from a previously cached result (if set). Tools: * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewThemeColor.mm: (TEST.WKWebViewThemeColor.MetaElementValidNameAndColor): Added. (TEST.WKWebViewThemeColor.MetaElementValidNameAndColorAndMedia): Added. (TEST.WKWebViewThemeColor.MetaElementInvalidName): Added. (TEST.WKWebViewThemeColor.MetaElementInvalidColor): Added. (TEST.WKWebViewThemeColor.MetaElementInvalidMedia): Added. (TEST.WKWebViewThemeColor.MetaElementMultipleValid): Added. (TEST.WKWebViewThemeColor.MetaElementValidSubframe): Added. (-[WKWebViewThemeColorObserver observeValueForKeyPath:ofObject:change:context:]): (TEST.WKWebViewThemeColor.KVO): (TEST.WKWebViewThemeColor.MetaElementOnLoad): Deleted. (TEST.WKWebViewThemeColor.MetaElementMultipleTags): Deleted. Canonical link: https://commits.webkit.org/237537@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277270 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
8 changed files
with
329 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.