Hang CSSFontSelector off Document instead of StyleResolver.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2015 18:44:22 +0000 (18:44 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jan 2015 18:44:22 +0000 (18:44 +0000)
<https://webkit.org/b/140820>

Reviewed by Antti Koivisto.

Move the CSSFontSelector from StyleResolver to Document. This is the first
step towards making the CSSFontSelector be able to survive full style recalc.

Clearing a Document's StyleResolver will still nuke the CSSFontSelector,
though that is done in Document::clearStyleResolver() now.

* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::CSSFontSelector):
* css/CSSFontSelector.h:

    Modernize CSSFontSelector construction a bit by having create() return
    a Ref and the constructor take a Document& instead of a Document*.
    Also made the constructor explicit.

(WebCore::StyleResolver::~StyleResolver):
* dom/Document.cpp:
(WebCore::Document::clearStyleResolver):

    Nuke the current CSSFontSelector in clearStyleResolver() instead of
    in ~StyleResolver. It's a minor change, but shows the way forward.
    Added a FIXME about how CSSFontSelector should eventually survive
    this operation.

(WebCore::Document::fontSelector):
* css/FontLoader.cpp:
(WebCore::FontLoader::loadFont):
(WebCore::FontLoader::checkFont):
(WebCore::FontLoader::resolveFontStyle):
* css/RuleSet.cpp:
(WebCore::RuleSet::addChildRules):
* css/StyleResolver.h:
(WebCore::StyleResolver::fontSelector): Deleted.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::appendAuthorStyleSheets):
(WebCore::StyleResolver::styleForElement):
(WebCore::StyleResolver::defaultStyleForElement):
(WebCore::StyleResolver::updateFont):
* dom/Document.h:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setFont):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::updateFromElement):
(WebCore::RenderListBox::paintItemForeground):
* rendering/RenderMenuList.cpp:
(RenderMenuList::fontSelector):
* rendering/RenderSearchField.cpp:
(WebCore::RenderSearchField::fontSelector):
* rendering/TextAutoSizing.cpp:
(WebCore::TextAutoSizingValue::adjustNodeSizes):
(WebCore::TextAutoSizingValue::reset):
* rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::computeNewScaledFontForStyle):
* style/StyleResolveForDocument.cpp:
(WebCore::Style::resolveForDocument):
* style/StyleResolveTree.cpp:
(WebCore::Style::resolveTree):

    Move CSSFontSelector ownership from StyleResolver to Document.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179012 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/CSSFontSelector.h
Source/WebCore/css/FontLoader.cpp
Source/WebCore/css/RuleSet.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/rendering/RenderListBox.cpp
Source/WebCore/rendering/RenderMenuList.cpp
Source/WebCore/rendering/RenderSearchField.cpp
Source/WebCore/rendering/RenderThemeSafari.cpp
Source/WebCore/rendering/TextAutoSizing.cpp
Source/WebCore/rendering/svg/RenderSVGInlineText.cpp
Source/WebCore/style/StyleResolveForDocument.cpp
Source/WebCore/style/StyleResolveTree.cpp

index e0c4226..8339294 100644 (file)
@@ -1,3 +1,70 @@
+2015-01-23  Andreas Kling  <akling@apple.com>
+
+        Hang CSSFontSelector off Document instead of StyleResolver.
+        <https://webkit.org/b/140820>
+
+        Reviewed by Antti Koivisto.
+
+        Move the CSSFontSelector from StyleResolver to Document. This is the first
+        step towards making the CSSFontSelector be able to survive full style recalc.
+
+        Clearing a Document's StyleResolver will still nuke the CSSFontSelector,
+        though that is done in Document::clearStyleResolver() now.
+
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::CSSFontSelector):
+        * css/CSSFontSelector.h:
+
+            Modernize CSSFontSelector construction a bit by having create() return
+            a Ref and the constructor take a Document& instead of a Document*.
+            Also made the constructor explicit.
+
+        (WebCore::StyleResolver::~StyleResolver):
+        * dom/Document.cpp:
+        (WebCore::Document::clearStyleResolver):
+
+            Nuke the current CSSFontSelector in clearStyleResolver() instead of
+            in ~StyleResolver. It's a minor change, but shows the way forward.
+            Added a FIXME about how CSSFontSelector should eventually survive
+            this operation.
+
+        (WebCore::Document::fontSelector):
+        * css/FontLoader.cpp:
+        (WebCore::FontLoader::loadFont):
+        (WebCore::FontLoader::checkFont):
+        (WebCore::FontLoader::resolveFontStyle):
+        * css/RuleSet.cpp:
+        (WebCore::RuleSet::addChildRules):
+        * css/StyleResolver.h:
+        (WebCore::StyleResolver::fontSelector): Deleted.
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::StyleResolver):
+        (WebCore::StyleResolver::appendAuthorStyleSheets):
+        (WebCore::StyleResolver::styleForElement):
+        (WebCore::StyleResolver::defaultStyleForElement):
+        (WebCore::StyleResolver::updateFont):
+        * dom/Document.h:
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::setFont):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::updateFromElement):
+        (WebCore::RenderListBox::paintItemForeground):
+        * rendering/RenderMenuList.cpp:
+        (RenderMenuList::fontSelector):
+        * rendering/RenderSearchField.cpp:
+        (WebCore::RenderSearchField::fontSelector):
+        * rendering/TextAutoSizing.cpp:
+        (WebCore::TextAutoSizingValue::adjustNodeSizes):
+        (WebCore::TextAutoSizingValue::reset):
+        * rendering/svg/RenderSVGInlineText.cpp:
+        (WebCore::RenderSVGInlineText::computeNewScaledFontForStyle):
+        * style/StyleResolveForDocument.cpp:
+        (WebCore::Style::resolveForDocument):
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::resolveTree):
+
+            Move CSSFontSelector ownership from StyleResolver to Document.
+
 2015-01-23  Jer Noble  <jer.noble@apple.com>
 
         Layout Test http/tests/media/track-in-band-hls-metadata.html is flaky
index 7bd4dad..d21b8a1 100644 (file)
@@ -58,12 +58,11 @@ namespace WebCore {
 
 static unsigned fontSelectorId;
 
-CSSFontSelector::CSSFontSelector(Document* document)
-    : m_document(document)
+CSSFontSelector::CSSFontSelector(Document& document)
+    : m_document(&document)
     , m_beginLoadingTimer(*this, &CSSFontSelector::beginLoadTimerFired)
     , m_uniqueId(++fontSelectorId)
     , m_version(0)
-    
 {
     // FIXME: An old comment used to say there was no need to hold a reference to m_document
     // because "we are guaranteed to be destroyed before the document". But there does not
index d84d112..7563ab3 100644 (file)
@@ -49,9 +49,9 @@ class StyleRuleFontFace;
 
 class CSSFontSelector final : public FontSelector {
 public:
-    static PassRefPtr<CSSFontSelector> create(Document* document)
+    static Ref<CSSFontSelector> create(Document& document)
     {
-        return adoptRef(new CSSFontSelector(document));
+        return adoptRef(*new CSSFontSelector(document));
     }
     virtual ~CSSFontSelector();
     
@@ -82,7 +82,7 @@ public:
     void beginLoadingFontSoon(CachedFont*);
 
 private:
-    CSSFontSelector(Document*);
+    explicit CSSFontSelector(Document&);
 
     void dispatchInvalidationCallbacks();
 
index f009924..f45f302 100644 (file)
@@ -252,7 +252,7 @@ void FontLoader::loadFont(const Dictionary& params)
     m_numLoadingFromJS += callback->familyCount();
 
     for (unsigned i = 0; i < font.familyCount(); i++) {
-        CSSSegmentedFontFace* face = m_document->ensureStyleResolver().fontSelector()->getFontFace(font.fontDescription(), font.familyAt(i));
+        CSSSegmentedFontFace* face = m_document->fontSelector().getFontFace(font.fontDescription(), font.familyAt(i));
         if (!face) {
             if (callback)
                 callback->notifyError();
@@ -269,7 +269,7 @@ bool FontLoader::checkFont(const String& fontString, const String&)
     if (!resolveFontStyle(fontString, font))
         return false;
     for (unsigned i = 0; i < font.familyCount(); i++) {
-        CSSSegmentedFontFace* face = m_document->ensureStyleResolver().fontSelector()->getFontFace(font.fontDescription(), font.familyAt(i));
+        CSSSegmentedFontFace* face = m_document->fontSelector().getFontFace(font.fontDescription(), font.familyAt(i));
         if (!face || !face->checkFont())
             return false;
     }
@@ -320,7 +320,7 @@ bool FontLoader::resolveFontStyle(const String& fontString, FontCascade& font)
     applyPropertyToCurrentStyle(styleResolver, CSSPropertyLineHeight, parsedStyle);
 
     font = style->fontCascade();
-    font.update(styleResolver.fontSelector());
+    font.update(&m_document->fontSelector());
     return true;
 }
 
index be73c21..12612c0 100644 (file)
@@ -330,7 +330,7 @@ void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase>>& rules, const Me
                 addChildRules(mediaRule.childRules(), medium, resolver, hasDocumentSecurityOrigin, addRuleFlags);
         } else if (is<StyleRuleFontFace>(*rule) && resolver) {
             // Add this font face to our set.
-            resolver->fontSelector()->addFontFaceRule(downcast<StyleRuleFontFace>(rule.get()));
+            resolver->document().fontSelector().addFontFaceRule(downcast<StyleRuleFontFace>(rule.get()));
             resolver->invalidateMatchedPropertiesCache();
         } else if (is<StyleRuleKeyframes>(*rule) && resolver)
             resolver->addKeyframeStyle(downcast<StyleRuleKeyframes>(rule.get()));
index 00dbb5f..2a84e17 100644 (file)
@@ -257,7 +257,6 @@ StyleResolver::StyleResolver(Document& document, bool matchAuthorAndUserStyles)
     , m_matchedPropertiesCacheSweepTimer(*this, &StyleResolver::sweepMatchedPropertiesCache)
     , m_document(document)
     , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles)
-    , m_fontSelector(CSSFontSelector::create(&m_document))
 #if ENABLE(CSS_DEVICE_ADAPTATION)
     , m_viewportStyleResolver(ViewportStyleResolver::create(&document))
 #endif
@@ -295,7 +294,7 @@ StyleResolver::StyleResolver(Document& document, bool matchAuthorAndUserStyles)
         const HashSet<SVGFontFaceElement*>& svgFontFaceElements = m_document.svgExtensions()->svgFontFaceElements();
         HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.end();
         for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElements.begin(); it != end; ++it)
-            fontSelector()->addFontFaceRule((*it)->fontFaceRule());
+            m_document.fontSelector().addFontFaceRule((*it)->fontFaceRule());
     }
 #endif
 
@@ -306,7 +305,7 @@ void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP
 {
     m_ruleSets.appendAuthorStyleSheets(firstNew, styleSheets, m_medium.get(), m_inspectorCSSOMWrappers, this);
     if (auto renderView = document().renderView())
-        renderView->style().fontCascade().update(fontSelector());
+        renderView->style().fontCascade().update(&document().fontSelector());
 
 #if ENABLE(CSS_DEVICE_ADAPTATION)
     viewportStyleResolver()->resolve();
@@ -344,8 +343,6 @@ void StyleResolver::addKeyframeStyle(PassRefPtr<StyleRuleKeyframes> rule)
 
 StyleResolver::~StyleResolver()
 {
-    m_fontSelector->clearDocument();
-
 #if ENABLE(CSS_DEVICE_ADAPTATION)
     m_viewportStyleResolver->clearDocument();
 #endif
@@ -748,7 +745,7 @@ Ref<RenderStyle> StyleResolver::styleForElement(Element* element, RenderStyle* d
         if (!s_styleNotYetAvailable) {
             s_styleNotYetAvailable = &RenderStyle::create().leakRef();
             s_styleNotYetAvailable->setDisplay(NONE);
-            s_styleNotYetAvailable->fontCascade().update(m_fontSelector);
+            s_styleNotYetAvailable->fontCascade().update(&document().fontSelector());
         }
         element->document().setHasNodesWithPlaceholderStyle();
         return *s_styleNotYetAvailable;
@@ -1031,7 +1028,7 @@ Ref<RenderStyle> StyleResolver::defaultStyleForElement()
     // Make sure our fonts are initialized if we don't inherit them from our parent style.
     if (Settings* settings = documentSettings()) {
         initializeFontStyle(settings);
-        m_state.style()->fontCascade().update(fontSelector());
+        m_state.style()->fontCascade().update(&document().fontSelector());
     } else
         m_state.style()->fontCascade().update(nullptr);
 
@@ -1484,7 +1481,7 @@ void StyleResolver::updateFont()
     checkForGenericFamilyChange(style, m_state.parentStyle());
     checkForZoomChange(style, m_state.parentStyle());
     checkForOrientationChange(style);
-    style->fontCascade().update(m_fontSelector);
+    style->fontCascade().update(&document().fontSelector());
     if (m_state.fontSizeHasViewportUnits())
         style->setHasViewportUnits(true);
     m_state.setFontDirty(false);
index 9af165a..7a116c4 100644 (file)
@@ -50,7 +50,6 @@
 namespace WebCore {
 
 class CSSCursorImageValue;
-class CSSFontSelector;
 class CSSFontFace;
 class CSSFontFaceRule;
 class CSSFontValue;
@@ -219,7 +218,6 @@ public:
     bool hasSelectorForClass(const AtomicString&) const;
     bool hasSelectorForAttribute(const Element&, const AtomicString&) const;
 
-    CSSFontSelector* fontSelector() const { return m_fontSelector.get(); }
 #if ENABLE(CSS_DEVICE_ADAPTATION)
     ViewportStyleResolver* viewportStyleResolver() { return m_viewportStyleResolver.get(); }
 #endif
@@ -521,7 +519,6 @@ private:
 
     bool m_matchAuthorAndUserStyles;
 
-    RefPtr<CSSFontSelector> m_fontSelector;
     Vector<std::unique_ptr<MediaQueryResult>> m_viewportDependentMediaQueryResults;
 
 #if ENABLE(CSS_DEVICE_ADAPTATION)
index 865c191..649a260 100644 (file)
@@ -33,6 +33,7 @@
 #include "Attr.h"
 #include "AudioProducer.h"
 #include "CDATASection.h"
+#include "CSSFontSelector.h"
 #include "CSSStyleDeclaration.h"
 #include "CSSStyleSheet.h"
 #include "CachedCSSStyleSheet.h"
@@ -1941,9 +1942,22 @@ void Document::createStyleResolver()
     m_styleSheetCollection.combineCSSFeatureFlags();
 }
 
+CSSFontSelector& Document::fontSelector()
+{
+    if (!m_fontSelector)
+        m_fontSelector = CSSFontSelector::create(*this);
+    return *m_fontSelector;
+}
+
 void Document::clearStyleResolver()
 {
     m_styleResolver = nullptr;
+
+    // FIXME: It would be better if the FontSelector could survive this operation.
+    if (m_fontSelector) {
+        m_fontSelector->clearDocument();
+        m_fontSelector = nullptr;
+    }
 }
 
 void Document::createRenderTree()
index f1b7d3f..decc601 100644 (file)
@@ -69,6 +69,7 @@ class AXObjectCache;
 class Attr;
 class AudioProducer;
 class CDATASection;
+class CSSFontSelector;
 class CSSStyleDeclaration;
 class CSSStyleSheet;
 class CachedCSSStyleSheet;
@@ -544,6 +545,8 @@ public:
         return *m_styleResolver;
     }
 
+    CSSFontSelector& fontSelector();
+
     void notifyRemovePendingSheetIfNeeded();
 
     bool haveStylesheetsLoaded() const;
@@ -1691,6 +1694,8 @@ private:
     Document* m_templateDocumentHost; // Manually managed weakref (backpointer from m_templateDocument).
 #endif
 
+    RefPtr<CSSFontSelector> m_fontSelector;
+
 #if ENABLE(FONT_LOAD_EVENTS)
     RefPtr<FontLoader> m_fontloader;
 #endif
index 5c45210..09db316 100755 (executable)
@@ -2093,7 +2093,10 @@ void CanvasRenderingContext2D::setFont(const String& newFont)
     // Map the <canvas> font into the text style. If the font uses keywords like larger/smaller, these will work
     // relative to the canvas.
     RefPtr<RenderStyle> newStyle = RenderStyle::create();
-    canvas()->document().updateStyleIfNeeded();
+
+    Document& document = canvas()->document();
+    document.updateStyleIfNeeded();
+
     if (RenderStyle* computedStyle = canvas()->computedStyle())
         newStyle->setFontDescription(computedStyle->fontDescription());
     else {
@@ -2123,9 +2126,9 @@ void CanvasRenderingContext2D::setFont(const String& newFont)
     styleResolver.applyPropertyToCurrentStyle(CSSPropertyLineHeight, parsedStyle->getPropertyCSSValue(CSSPropertyLineHeight).get());
 
     modifiableState().m_font = newStyle->fontCascade();
-    modifiableState().m_font.update(styleResolver.fontSelector());
+    modifiableState().m_font.update(&document.fontSelector());
     modifiableState().m_realizedFont = true;
-    styleResolver.fontSelector()->registerForInvalidationCallbacks(&modifiableState());
+    document.fontSelector().registerForInvalidationCallbacks(&modifiableState());
 }
 
 String CanvasRenderingContext2D::textAlign() const
index 1f57b08..c03dbc0 100644 (file)
@@ -120,7 +120,7 @@ void RenderListBox::updateFromElement()
                 FontDescription d = itemFont.fontDescription();
                 d.setWeight(d.bolderWeight());
                 itemFont = FontCascade(d, itemFont.letterSpacing(), itemFont.wordSpacing());
-                itemFont.update(document().ensureStyleResolver().fontSelector());
+                itemFont.update(&document().fontSelector());
             }
 
             if (!text.isEmpty()) {
@@ -408,7 +408,7 @@ void RenderListBox::paintItemForeground(PaintInfo& paintInfo, const LayoutPoint&
         FontDescription d = itemFont.fontDescription();
         d.setWeight(d.bolderWeight());
         itemFont = FontCascade(d, itemFont.letterSpacing(), itemFont.wordSpacing());
-        itemFont.update(document().ensureStyleResolver().fontSelector());
+        itemFont.update(&document().fontSelector());
     }
 
     // Draw the item text
index 22bf3d2..20af7c5 100644 (file)
@@ -662,7 +662,7 @@ void RenderMenuList::setTextFromItem(unsigned listIndex)
 
 FontSelector* RenderMenuList::fontSelector() const
 {
-    return document().ensureStyleResolver().fontSelector();
+    return &document().fontSelector();
 }
 
 }
index 004a259..302b994 100644 (file)
@@ -339,7 +339,7 @@ void RenderSearchField::setTextFromItem(unsigned listIndex)
 
 FontSelector* RenderSearchField::fontSelector() const
 {
-    return document().ensureStyleResolver().fontSelector();
+    return &document().fontSelector();
 }
 
 HostWindow* RenderSearchField::hostWindow() const
index 942849d..10e4347 100644 (file)
@@ -401,7 +401,7 @@ void RenderThemeSafari::setFontFromControlSize(StyleResolver& styleResolver, Ren
     style.setLineHeight(RenderStyle::initialLineHeight());
 
     if (style.setFontDescription(fontDescription))
-        style.fontCascade().update(styleResolver.fontSelector());
+        style.fontCascade().update(&styleResolver.document().fontSelector());
 }
 
 NSControlSize RenderThemeSafari::controlSizeForSystemFont(RenderStyle& style) const
index 3869f33..220eb8d 100644 (file)
@@ -164,7 +164,7 @@ bool TextAutoSizingValue::adjustNodeSizes()
             FontDescription fontDescription = style->fontDescription();
             fontDescription.setComputedSize(averageSize);
             style->setFontDescription(fontDescription);
-            style->fontCascade().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+            style->fontCascade().update(&autoSizingNode->document().fontSelector());
             text->parent()->setStyle(style.releaseNonNull());
             
             RenderElement* parentRenderer = text->parent();
@@ -176,7 +176,7 @@ bool TextAutoSizingValue::adjustNodeSizes()
             if (listMarkerRenderer->isListMarker()) {
                 RefPtr<RenderStyle> style = cloneRenderStyleWithState(listMarkerRenderer->style());
                 style->setFontDescription(fontDescription);
-                style->fontCascade().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+                style->fontCascade().update(&autoSizingNode->document().fontSelector());
                 downcast<RenderListMarker>(*listMarkerRenderer).setStyle(style.releaseNonNull());
             }
             
@@ -196,7 +196,7 @@ bool TextAutoSizingValue::adjustNodeSizes()
                 newParentStyle->setLineHeight(Length(lineHeight, Fixed));
                 newParentStyle->setSpecifiedLineHeight(lineHeightLength);
                 newParentStyle->setFontDescription(fontDescription);
-                newParentStyle->fontCascade().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+                newParentStyle->fontCascade().update(&autoSizingNode->document().fontSelector());
                 parentRenderer->setStyle(newParentStyle.releaseNonNull());
             }
         }
@@ -220,7 +220,7 @@ void TextAutoSizingValue::reset()
             fontDescription.setComputedSize(originalSize);
             RefPtr<RenderStyle> style = cloneRenderStyleWithState(text->style());
             style->setFontDescription(fontDescription);
-            style->fontCascade().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+            style->fontCascade().update(&autoSizingNode->document().fontSelector());
             text->parent()->setStyle(style.releaseNonNull());
         }
         // Reset the line height of the parent.
@@ -237,7 +237,7 @@ void TextAutoSizingValue::reset()
             RefPtr<RenderStyle> newParentStyle = cloneRenderStyleWithState(parentStyle);
             newParentStyle->setLineHeight(originalLineHeight);
             newParentStyle->setFontDescription(fontDescription);
-            newParentStyle->fontCascade().update(autoSizingNode->document().ensureStyleResolver().fontSelector());
+            newParentStyle->fontCascade().update(&autoSizingNode->document().fontSelector());
             parentRenderer->setStyle(newParentStyle.releaseNonNull());
         }
     }
index 99eb711..472bb2b 100644 (file)
@@ -241,7 +241,7 @@ void RenderSVGInlineText::computeNewScaledFontForStyle(const RenderObject& rende
     fontDescription.setComputedSize(Style::computedFontSizeFromSpecifiedSizeForSVGInlineText(fontDescription.computedSize(), fontDescription.isAbsoluteSize(), scalingFactor, renderer.document()));
 
     scaledFont = FontCascade(fontDescription, 0, 0);
-    scaledFont.update(renderer.document().ensureStyleResolver().fontSelector());
+    scaledFont.update(&renderer.document().fontSelector());
 }
 
 }
index af68188..973feb4 100644 (file)
@@ -115,8 +115,7 @@ Ref<RenderStyle> resolveForDocument(const Document& document)
 
     documentStyle.get().setFontDescription(fontDescription);
 
-    CSSFontSelector* fontSelector = document.styleResolverIfExists() ? document.styleResolverIfExists()->fontSelector() : nullptr;
-    documentStyle.get().fontCascade().update(fontSelector);
+    documentStyle.get().fontCascade().update(&const_cast<Document&>(document).fontSelector());
 
     return documentStyle;
 }
index 24cb5e8..649cfc6 100644 (file)
@@ -976,9 +976,8 @@ void resolveTree(Document& document, Change change)
         // Inserting the pictograph font at the end of the font fallback list is done by the
         // font selector, so set a font selector if needed.
         if (Settings* settings = document.settings()) {
-            StyleResolver* styleResolver = document.styleResolverIfExists();
-            if (settings->fontFallbackPrefersPictographs() && styleResolver)
-                documentStyle.get().fontCascade().update(styleResolver->fontSelector());
+            if (settings->fontFallbackPrefersPictographs())
+                documentStyle.get().fontCascade().update(&document.fontSelector());
         }
 
         Style::Change documentChange = determineChange(documentStyle.get(), document.renderView()->style());