Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Delay system font shorthand resolution until after parsing
https://bugs.webkit.org/show_bug.cgi?id=241454 Reviewed by Antti Koivisto. This is the fifth piece of https://bugs.webkit.org/show_bug.cgi?id=237817, and is the main crux of the fix to that bug. When content says something like "font: caption" or "font: -apple-system-body" we have to map that to CSS properties like font-size and font-weight, so inheritance works properly across different elements. On iOS, system settings can affect this mapping. Before this patch, we were performing this mapping inside the parser, which is wrong because we'll never re-parse things in response to a change in the environment. So, if the page is live, and then the user changes a setting in system preferences, we won't re-parse, which means the page won't update to accomodate the new setting the user changed. This patch changes the parser to not do this mapping, but instead just to emit CSSValues which directly and simply represent the value that was present in the CSS source itself. So, if the content says "font: caption" we'll create CSSPrimitiveValues which just hold "caption" and use that for all the longhands of the font property. Then, we do the mapping when the values are applied, inside StyleBuilder. StyleBuilder is re-run in response to environment changes, so this piece is necessary for system settings to immediately take effect without a reload of the page. This change is web-exposed, because the contents of CSSValues are exposed to webpages via inspecting the CSSStyleSheet in JavaScript. So, the change is a little scary, but I think it's the only way to have the right thing happen with system settings. This patch also deletes the now-unused system font shorthand cache, which was reimplemented in 10cdfcb. This patch isn't sufficient to make system settings fully work - there are some follow-up patches which are still necessary on top of this: 1. Have font creation code actually interrogate system settings, and react accordingly, to create fonts with the appropriate size/weight 2. Make sure the right things get invalidated, so we don't get erroneous cache hits when system settings change 3. Make sure the right events are being delivered to the right places, and triggering the right invalidation, in response to system settings being changed. * LayoutTests/fast/text/font-shorthand-resolution-expected.txt: Added. * LayoutTests/fast/text/font-shorthand-resolution.html: Added. * Source/WebCore/css/CSSProperties.json: * Source/WebCore/css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::consumeSystemFont): (WebCore::CSSPropertyParser::parseShorthand): * Source/WebCore/css/parser/CSSPropertyParserHelpers.h: (WebCore::CSSPropertyParserHelpers::isSystemFontShorthand): (WebCore::CSSPropertyParserHelpers::lowerFontShorthand): * Source/WebCore/platform/graphics/SystemFontDatabase.h: * Source/WebCore/rendering/RenderTheme.h: * Source/WebCore/rendering/RenderThemeCocoa.h: * Source/WebCore/rendering/RenderThemeCocoa.mm: (WebCore::RenderThemeCocoa::systemFont const): Deleted. * Source/WebCore/rendering/RenderThemeGtk.cpp: (WebCore::RenderThemeGtk::systemFont const): Deleted. * Source/WebCore/rendering/RenderThemePlayStation.cpp: (WebCore::RenderThemePlayStation::systemFont const): Deleted. * Source/WebCore/rendering/RenderThemeWin.cpp: (WebCore::RenderThemeWin::systemFont const): Deleted. * Source/WebCore/style/StyleBuilderConverter.h: (WebCore::Style::BuilderConverter::convertFontWeight): (WebCore::Style::BuilderConverter::convertFontVariantCaps): (WebCore::Style::BuilderConverter::convertLineHeight): * Source/WebCore/style/StyleBuilderCustom.h: (WebCore::Style::BuilderCustom::applyValueFontFamily): (WebCore::Style::BuilderCustom::applyValueFontStyle): (WebCore::Style::BuilderCustom::applyValueFontSize): * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::contentSizeCategoryDidChange): * Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::accessibilityPreferencesDidChange): Canonical link: https://commits.webkit.org/251481@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295476 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
24 changed files
with
238 additions
and
302 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
PASS style.getPropertyValue('font-family') is not 'UICTFontTextStyleBody' | ||
PASS isNaN(parseInt(style.getPropertyValue('font-size'))) is true | ||
PASS style.getPropertyValue('font-style') is not 'normal' | ||
PASS isNaN(parseInt(style.getPropertyValue('font-weight'))) is true | ||
PASS style.getPropertyValue('font-variant-caps') is not 'normal' | ||
PASS style.getPropertyValue('line-height') is not 'normal' | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test.js"></script> | ||
<style id="style"> | ||
foo { | ||
font: -apple-system-body; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<script> | ||
let style = document.getElementById("style").sheet.cssRules[0].style; | ||
shouldNotBe("style.getPropertyValue('font-family')", "'UICTFontTextStyleBody'"); | ||
shouldBeTrue("isNaN(parseInt(style.getPropertyValue('font-size')))"); | ||
shouldNotBe("style.getPropertyValue('font-style')", "'normal'"); | ||
shouldBeTrue("isNaN(parseInt(style.getPropertyValue('font-weight')))"); | ||
shouldNotBe("style.getPropertyValue('font-variant-caps')", "'normal'"); | ||
shouldNotBe("style.getPropertyValue('line-height')", "'normal'"); | ||
</script> | ||
</body> | ||
</html> |
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
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.