Changeset 270886 in webkit
- Timestamp:
- Dec 16, 2020 4:55:09 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r270885 r270886 1 2020-12-16 Antti Koivisto <antti@apple.com> 2 3 Remove simpleUserAgentStyleSheet (to fix flaky fast/lists/001.html and fast/lists/001-vertical.html) 4 https://bugs.webkit.org/show_bug.cgi?id=218995 5 <rdar://problem/71452387> 6 7 Reviewed by Antoine Quint. 8 9 * platform/mac-wk2/TestExpectations: 10 1 11 2020-12-16 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r270823 r270886 1317 1317 webkit.org/b/219322 fast/layoutformattingcontext/table-simple-border-collapse.html [ ImageOnlyFailure ] 1318 1318 webkit.org/b/219322 fast/layoutformattingcontext/table-simple-border-collapse2.html [ ImageOnlyFailure ] 1319 1320 webkit.org/b/218995 fast/lists/001.html [ Skip ]1321 webkit.org/b/218995 fast/lists/001-vertical.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r270883 r270886 1 2020-12-16 Antti Koivisto <antti@apple.com> 2 3 Remove simpleUserAgentStyleSheet (to fix flaky fast/lists/001.html and fast/lists/001-vertical.html) 4 https://bugs.webkit.org/show_bug.cgi?id=218995 5 <rdar://problem/71452387> 6 7 Reviewed by Antoine Quint. 8 9 The simpleUserAgentStyleSheet optimization allows WebKit to load a very simple version of the user agent 10 stylesheet as long as the document is very simple too (mostly just <div>/<span>). It was implemented 11 to support certain non-web use cases a long time ago when the cost of simply parsing the main stylesheet was 12 significant. 13 14 It can cause problems like seen here when it is not fully in-sync with the real stylesheet. The ways it may be out 15 of sync can be pretty obscure. 16 17 The optimization hasn't been useful for a while now. Let's just remove it instead of continuing fix problems caused by it. 18 19 * page/ProcessWarming.cpp: 20 (WebCore::ProcessWarming::prewarmGlobally): 21 * style/ElementRuleCollector.cpp: 22 (WebCore::Style::ElementRuleCollector::matchUARules): 23 * style/InspectorCSSOMWrappers.cpp: 24 (WebCore::Style::InspectorCSSOMWrappers::collectDocumentWrappers): 25 * style/StyleResolver.cpp: 26 (WebCore::Style::Resolver::Resolver): 27 * style/UserAgentStyle.cpp: 28 (WebCore::Style::UserAgentStyle::initDefaultStyleSheet): 29 (WebCore::Style::UserAgentStyle::ensureDefaultStyleSheetsForElement): 30 (WebCore::Style::elementCanUseSimpleDefaultStyle): Deleted. 31 (WebCore::Style::UserAgentStyle::initDefaultStyle): Deleted. 32 (WebCore::Style::UserAgentStyle::loadFullDefaultStyle): Deleted. 33 (WebCore::Style::UserAgentStyle::loadSimpleDefaultStyle): Deleted. 34 * style/UserAgentStyle.h: 35 1 36 2020-12-16 Youenn Fablet <youenn@apple.com> 2 37 -
trunk/Source/WebCore/page/ProcessWarming.cpp
r265418 r270886 73 73 74 74 // Prewarms user agent stylesheet. 75 Style::UserAgentStyle:: loadFullDefaultStyle();75 Style::UserAgentStyle::initDefaultStyleSheet(); 76 76 77 77 // Prewarms JS VM. -
trunk/Source/WebCore/style/ElementRuleCollector.cpp
r269415 r270886 386 386 { 387 387 // First we match rules from the user agent sheet. 388 if (UserAgentStyle::simpleDefaultStyleSheet)389 m_result.isCacheable = false;390 388 auto* userAgentStyleSheet = m_isPrintStyle 391 389 ? UserAgentStyle::defaultPrintStyle : UserAgentStyle::defaultStyle; -
trunk/Source/WebCore/style/InspectorCSSOMWrappers.cpp
r269999 r270886 105 105 { 106 106 if (m_styleRuleToCSSOMWrapperMap.isEmpty()) { 107 collectFromStyleSheetContents(UserAgentStyle::simpleDefaultStyleSheet);108 107 collectFromStyleSheetContents(UserAgentStyle::defaultStyleSheet); 109 108 collectFromStyleSheetContents(UserAgentStyle::quirksStyleSheet); -
trunk/Source/WebCore/style/StyleResolver.cpp
r267497 r270886 90 90 , m_matchAuthorAndUserStyles(m_document.settings().authorAndUserStylesEnabled()) 91 91 { 92 Element* root = m_document.documentElement(); 93 94 UserAgentStyle::initDefaultStyle(root); 92 UserAgentStyle::initDefaultStyleSheet(); 95 93 96 94 // construct document root element default style. this is needed … … 106 104 m_mediaQueryEvaluator = MediaQueryEvaluator { }; 107 105 108 if ( root) {109 m_rootDefaultStyle = styleForElement(* root, m_document.renderStyle(), nullptr, RuleMatchingBehavior::MatchOnlyUserAgentRules).renderStyle;106 if (auto* documentElement = m_document.documentElement()) { 107 m_rootDefaultStyle = styleForElement(*documentElement, m_document.renderStyle(), nullptr, RuleMatchingBehavior::MatchOnlyUserAgentRules).renderStyle; 110 108 // Turn off assertion against font lookups during style resolver initialization. We may need root style font for media queries. 111 109 m_document.fontSelector().incrementIsComputingRootStyleFont(); -
trunk/Source/WebCore/style/UserAgentStyle.cpp
r270678 r270886 68 68 unsigned UserAgentStyle::defaultStyleVersion; 69 69 70 StyleSheetContents* UserAgentStyle::simpleDefaultStyleSheet;71 70 StyleSheetContents* UserAgentStyle::defaultStyleSheet; 72 71 StyleSheetContents* UserAgentStyle::quirksStyleSheet; … … 89 88 #endif 90 89 91 #if PLATFORM(IOS_FAMILY)92 #define DEFAULT_OUTLINE_WIDTH "3px"93 #else94 #define DEFAULT_OUTLINE_WIDTH "5px"95 #endif96 97 #if HAVE(OS_DARK_MODE_SUPPORT)98 #define CSS_DARK_MODE_ADDITION "html{color:text}"99 #else100 #define CSS_DARK_MODE_ADDITION ""101 #endif102 103 // FIXME: It would be nice to use some mechanism that guarantees this is in sync with the real UA stylesheet.104 static const char simpleUserAgentStyleSheet[] = "html,body,div{display:block}" CSS_DARK_MODE_ADDITION "head{display:none}body{margin:8px}div:focus,span:focus,a:focus{outline:auto " DEFAULT_OUTLINE_WIDTH " -webkit-focus-ring-color}a:any-link{color:-webkit-link;text-decoration:underline}a:any-link:active{color:-webkit-activelink}";105 106 static inline bool elementCanUseSimpleDefaultStyle(const Element& element)107 {108 return is<HTMLHtmlElement>(element) || is<HTMLHeadElement>(element)109 || is<HTMLBodyElement>(element) || is<HTMLDivElement>(element)110 || is<HTMLSpanElement>(element) || is<HTMLBRElement>(element)111 || is<HTMLAnchorElement>(element);112 }113 114 90 static const MediaQueryEvaluator& screenEval() 115 91 { … … 134 110 { 135 111 return parseUASheet(String(characters, size)); 136 }137 138 void UserAgentStyle::initDefaultStyle(const Element* root)139 {140 if (!defaultStyle) {141 if (!root || elementCanUseSimpleDefaultStyle(*root))142 loadSimpleDefaultStyle();143 else144 loadFullDefaultStyle();145 }146 112 } 147 113 … … 168 134 } 169 135 170 void UserAgentStyle:: loadFullDefaultStyle()171 { 172 if (defaultStyle && !simpleDefaultStyleSheet)136 void UserAgentStyle::initDefaultStyleSheet() 137 { 138 if (defaultStyle) 173 139 return; 174 175 if (simpleDefaultStyleSheet) {176 ASSERT(defaultStyle);177 ASSERT(defaultPrintStyle == defaultStyle);178 defaultStyle->deref();179 simpleDefaultStyleSheet->deref();180 simpleDefaultStyleSheet = nullptr;181 } else {182 ASSERT(!defaultStyle);183 defaultQuirksStyle = &RuleSet::create().leakRef();184 }185 140 186 141 defaultStyle = &RuleSet::create().leakRef(); 187 142 defaultPrintStyle = &RuleSet::create().leakRef(); 143 defaultQuirksStyle = &RuleSet::create().leakRef(); 188 144 mediaQueryStyleSheet = &StyleSheetContents::create(CSSParserContext(UASheetMode)).leakRef(); 189 145 … … 197 153 quirksStyleSheet = parseUASheet(quirksRules); 198 154 defaultQuirksStyle->addRulesFromSheet(*quirksStyleSheet, screenEval()); 199 } 200 201 void UserAgentStyle::loadSimpleDefaultStyle() 202 { 203 ASSERT(!defaultStyle); 204 ASSERT(!simpleDefaultStyleSheet); 205 206 defaultStyle = &RuleSet::create().leakRef(); 207 // There are no media-specific rules in the simple default style. 208 defaultPrintStyle = defaultStyle; 209 defaultQuirksStyle = &RuleSet::create().leakRef(); 210 211 simpleDefaultStyleSheet = parseUASheet(simpleUserAgentStyleSheet, strlen(simpleUserAgentStyleSheet)); 212 defaultStyle->addRulesFromSheet(*simpleDefaultStyleSheet, screenEval()); 155 213 156 ++defaultStyleVersion; 214 // No need to initialize quirks sheet yet as there are no quirk rules for elements allowed in simple default style.215 157 } 216 158 217 159 void UserAgentStyle::ensureDefaultStyleSheetsForElement(const Element& element) 218 160 { 219 if (simpleDefaultStyleSheet && !elementCanUseSimpleDefaultStyle(element)) {220 loadFullDefaultStyle();221 ++defaultStyleVersion;222 }223 224 161 if (is<HTMLElement>(element)) { 225 162 if (is<HTMLObjectElement>(element) || is<HTMLEmbedElement>(element)) { -
trunk/Source/WebCore/style/UserAgentStyle.h
r269999 r270886 39 39 static unsigned defaultStyleVersion; 40 40 41 static StyleSheetContents* simpleDefaultStyleSheet;42 41 static StyleSheetContents* defaultStyleSheet; 43 42 static StyleSheetContents* quirksStyleSheet; … … 61 60 static StyleSheetContents* mediaQueryStyleSheet; 62 61 63 static void initDefaultStyle (const Element*);62 static void initDefaultStyleSheet(); 64 63 static void ensureDefaultStyleSheetsForElement(const Element&); 65 static void loadFullDefaultStyle();66 64 67 65 private: 68 static void loadSimpleDefaultStyle();69 66 static void addToDefaultStyle(StyleSheetContents&); 70 67 };
Note: See TracChangeset
for help on using the changeset viewer.