Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit e04892b

Browse files
Regression(r255359): imported/mozilla/svg/svg-integration/clipPath-html-06.xhtml is failing consistently on windows
https://bugs.webkit.org/show_bug.cgi?id=206991 <rdar://problem/59030252> Reviewed by Antoine Quint. The previous approach may have still allowed RenderStyles computed with non-current FontCascade in matched properties caches (because some non-font properties were resolved based on obsolete font information). This patch takes a more robust approach by simply preventing caching of styles with non-current font. * dom/Document.h: (WebCore::Document::fontSelector const): * platform/graphics/FontCascade.cpp: (WebCore::FontCascade::isCurrent const): * platform/graphics/FontCascade.h: * style/MatchedDeclarationsCache.cpp: (WebCore::Style::MatchedDeclarationsCache::isCacheable): * style/StyleBuilderState.cpp: (WebCore::Style::BuilderState::updateFont): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@255490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent c338818 commit e04892b

File tree

6 files changed

+46
-4
lines changed

6 files changed

+46
-4
lines changed

Source/WebCore/ChangeLog

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
2020-01-31 Antti Koivisto <[email protected]>
2+
3+
Regression(r255359): imported/mozilla/svg/svg-integration/clipPath-html-06.xhtml is failing consistently on windows
4+
https://bugs.webkit.org/show_bug.cgi?id=206991
5+
<rdar://problem/59030252>
6+
7+
Reviewed by Antoine Quint.
8+
9+
The previous approach may have still allowed RenderStyles computed with non-current FontCascade in
10+
matched properties caches (because some non-font properties were resolved based on obsolete font information).
11+
12+
This patch takes a more robust approach by simply preventing caching of styles with non-current font.
13+
14+
* dom/Document.h:
15+
(WebCore::Document::fontSelector const):
16+
* platform/graphics/FontCascade.cpp:
17+
(WebCore::FontCascade::isCurrent const):
18+
* platform/graphics/FontCascade.h:
19+
* style/MatchedDeclarationsCache.cpp:
20+
(WebCore::Style::MatchedDeclarationsCache::isCacheable):
21+
* style/StyleBuilderState.cpp:
22+
(WebCore::Style::BuilderState::updateFont):
23+
124
2020-01-30 Antoine Quint <[email protected]>
225

326
[Web Animations] DocumentTimeline shouldn't suspend itself if hiddenPageCSSAnimationSuspensionEnabled is disabled

Source/WebCore/dom/Document.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ class Document
541541
Style::Resolver& userAgentShadowTreeStyleResolver();
542542

543543
CSSFontSelector& fontSelector() { return m_fontSelector; }
544+
const CSSFontSelector& fontSelector() const { return m_fontSelector; }
544545

545546
WEBCORE_EXPORT bool haveStylesheetsLoaded() const;
546547
bool isIgnoringPendingStylesheets() const { return m_ignorePendingStylesheets; }

Source/WebCore/platform/graphics/FontCascade.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ static Ref<FontCascadeFonts> retrieveOrAddCachedFonts(const FontCascadeDescripti
265265
return glyphs;
266266
}
267267

268+
bool FontCascade::isCurrent(const FontSelector& fontSelector) const
269+
{
270+
if (!m_fonts)
271+
return false;
272+
if (m_fonts->generation() != FontCache::singleton().generation())
273+
return false;
274+
if (m_fonts->fontSelectorVersion() != fontSelector.version())
275+
return false;
276+
277+
return true;
278+
}
279+
268280
void FontCascade::update(RefPtr<FontSelector>&& fontSelector) const
269281
{
270282
m_fonts = retrieveOrAddCachedFonts(m_fontDescription, WTFMove(fontSelector));

Source/WebCore/platform/graphics/FontCascade.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class FontCascade : public CanMakeWeakPtr<FontCascade> {
104104
int pixelSize() const { return fontDescription().computedPixelSize(); }
105105
float size() const { return fontDescription().computedSize(); }
106106

107+
bool isCurrent(const FontSelector&) const;
107108
WEBCORE_EXPORT void update(RefPtr<FontSelector>&& = nullptr) const;
108109

109110
enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontNotReady };

Source/WebCore/style/MatchedDeclarationsCache.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "config.h"
3131
#include "MatchedDeclarationsCache.h"
3232

33+
#include "CSSFontSelector.h"
3334
#include <wtf/text/StringHash.h>
3435

3536
namespace WebCore {
@@ -61,6 +62,14 @@ bool MatchedDeclarationsCache::isCacheable(const Element& element, const RenderS
6162
if (style.hasExplicitlyInheritedProperties())
6263
return false;
6364

65+
// Getting computed style after a font environment change but before full style resolution may involve styles with non-current fonts.
66+
// Avoid caching them.
67+
auto& fontSelector = element.document().fontSelector();
68+
if (!style.fontCascade().isCurrent(fontSelector))
69+
return false;
70+
if (!parentStyle.fontCascade().isCurrent(fontSelector))
71+
return false;
72+
6473
return true;
6574
}
6675

Source/WebCore/style/StyleBuilderState.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,6 @@ void BuilderState::updateFont()
346346
auto* fonts = m_style.fontCascade().fonts();
347347
if (!fonts)
348348
return true;
349-
if (fonts->generation() != FontCache::singleton().generation())
350-
return true;
351-
if (fonts->fontSelectorVersion() != fontSelector.version())
352-
return true;
353349
return false;
354350
};
355351

0 commit comments

Comments
 (0)