Title: [219145] trunk
Revision
219145
Author
an...@apple.com
Date
2017-07-05 12:53:55 -0700 (Wed, 05 Jul 2017)

Log Message

Low memory notification shouldn't cause style recalc
https://bugs.webkit.org/show_bug.cgi?id=173574
<rdar://problem/32616997>

Reviewed by Andreas Kling.

Source/WebCore:

Patch mostly by Myles.

When we receive a low memory warning, we clear the style resolver. Previously, we were using
this as an opportunity to also purge the CSSFontSelector. However, purging the font selector
is wasteful, since the exact same set of CSSFontFace objects will be recreated as soon as the
CSSFontSelector is recreated. It's also harmful because this purge operation causes fonts to
be removed from the document's working set, and therefore triggers a relayout. Instead, this
call should be softened to only delete any transitory caches the CSSFontSelector owns.

We can simply delay the rebuild of the CSSFontSelector to
StyleResolver::appendAuthorStyleSheets(), when it's really needed. This way, we can sidestep
this whole problem.

There's also an added benefit: Now, buildStarted() doesn't have to be idempotent, so we can
enforce a stricter calling sequence with ASSERT()s.

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

    Add a separate function to clear font selector caches.

(WebCore::CSSFontSelector::buildStarted):
(WebCore::CSSFontSelector::buildCompleted):
(WebCore::CSSFontSelector::addFontFaceRule):
(WebCore::CSSFontSelector::fontModified):

    No need to invalidate while building.

(WebCore::CSSFontSelector::fontRangesForFamily):
* css/CSSFontSelector.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::addCurrentSVGFontFaceRules):

    Factor into a function from the constructor.

(WebCore::StyleResolver::appendAuthorStyleSheets):

    Font selector build is now started and finished by StyleScope.

* css/StyleResolver.h:
* dom/Document.cpp:
(WebCore::Document::resolveStyle):

    Call FrameView::styleDidChange() to update any custom scrollbars.
    This bug was hidden by spurious style recalcs, tested by fast/css/scrollbar-dynamic-style-change.html

(WebCore::Document::userAgentShadowTreeStyleResolver):
(WebCore::Document::didClearStyleResolver):

    Don't start the font selector rebuild after clearing the resolver. It would cause style recalc trashing.
    Instead the build starts when the new resolver is constructed.

* page/MemoryRelease.cpp:
(WebCore::releaseCriticalMemory):

    Release font selector caches.

* style/StyleScope.cpp:
(WebCore::Style::Scope::resolver):

LayoutTests:

* platform/mac/printing/width-overflow-expected.txt:

    1px width change that doesn't affect what is being tested.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219144 => 219145)


--- trunk/LayoutTests/ChangeLog	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/LayoutTests/ChangeLog	2017-07-05 19:53:55 UTC (rev 219145)
@@ -1,3 +1,15 @@
+2017-07-05  Antti Koivisto  <an...@apple.com>
+
+        Low memory notification shouldn't cause style recalc
+        https://bugs.webkit.org/show_bug.cgi?id=173574
+        <rdar://problem/32616997>
+
+        Reviewed by Andreas Kling.
+
+        * platform/mac/printing/width-overflow-expected.txt:
+
+            1px width change that doesn't affect what is being tested.
+
 2017-07-05  Jonathan Bedard  <jbed...@apple.com>
 
         Move internal iOS 11 TestExpectations to OpenSource

Modified: trunk/LayoutTests/platform/mac/printing/width-overflow-expected.txt (219144 => 219145)


--- trunk/LayoutTests/platform/mac/printing/width-overflow-expected.txt	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/LayoutTests/platform/mac/printing/width-overflow-expected.txt	2017-07-05 19:53:55 UTC (rev 219145)
@@ -8,11 +8,11 @@
           text run at (0,0) width 765: "To run this test manually, print this page. If the right side of any lines is printed without being truncated, the test passes."
       RenderBlock {DIV} at (0,34) size 1300x2218
         RenderBlock {P} at (0,0) size 1300x72
-          RenderText {#text} at (0,0) size 1289x72
-            text run at (0,0) width 1289: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
-            text run at (0,18) width 1289: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
-            text run at (0,36) width 1289: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
-            text run at (0,54) width 526: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
+          RenderText {#text} at (0,0) size 1288x72
+            text run at (0,0) width 1288: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
+            text run at (0,18) width 1288: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
+            text run at (0,36) width 1288: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
+            text run at (0,54) width 525: "A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A"
         RenderBlock {P} at (0,88) size 1300x72
           RenderText {#text} at (0,0) size 1288x72
             text run at (0,0) width 1288: "B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B"
@@ -96,9 +96,9 @@
             text run at (0,36) width 1288: "O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O"
             text run at (0,54) width 790: "O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O"
         RenderBlock {P} at (0,1284) size 1300x54
-          RenderText {#text} at (0,0) size 1290x54
-            text run at (0,0) width 1290: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
-            text run at (0,18) width 1290: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
+          RenderText {#text} at (0,0) size 1289x54
+            text run at (0,0) width 1289: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
+            text run at (0,18) width 1289: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
             text run at (0,36) width 1105: "P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P"
         RenderBlock {P} at (0,1354) size 1300x72
           RenderText {#text} at (0,0) size 1288x72
@@ -122,7 +122,7 @@
             text run at (0,0) width 1292: "T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T"
             text run at (0,18) width 1292: "T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T"
             text run at (0,36) width 1292: "T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T"
-            text run at (0,54) width 159: "T T T T T T T T T T T T"
+            text run at (0,54) width 158: "T T T T T T T T T T T T"
         RenderBlock {P} at (0,1688) size 1300x72
           RenderText {#text} at (0,0) size 1288x72
             text run at (0,0) width 1288: "U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U U"
@@ -153,7 +153,7 @@
             text run at (0,0) width 1299: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
             text run at (0,18) width 1299: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
             text run at (0,36) width 1299: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
-            text run at (0,54) width 581: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
+            text run at (0,54) width 580: "Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y"
         RenderBlock {P} at (0,2146) size 1300x72
           RenderText {#text} at (0,0) size 1291x72
             text run at (0,0) width 1291: "Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z"

Modified: trunk/Source/WebCore/ChangeLog (219144 => 219145)


--- trunk/Source/WebCore/ChangeLog	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/ChangeLog	2017-07-05 19:53:55 UTC (rev 219145)
@@ -1,3 +1,75 @@
+2017-07-05  Antti Koivisto  <an...@apple.com>
+
+        Low memory notification shouldn't cause style recalc
+        https://bugs.webkit.org/show_bug.cgi?id=173574
+        <rdar://problem/32616997>
+
+        Reviewed by Andreas Kling.
+
+        Patch mostly by Myles.
+
+        When we receive a low memory warning, we clear the style resolver. Previously, we were using
+        this as an opportunity to also purge the CSSFontSelector. However, purging the font selector
+        is wasteful, since the exact same set of CSSFontFace objects will be recreated as soon as the
+        CSSFontSelector is recreated. It's also harmful because this purge operation causes fonts to
+        be removed from the document's working set, and therefore triggers a relayout. Instead, this
+        call should be softened to only delete any transitory caches the CSSFontSelector owns.
+
+        We can simply delay the rebuild of the CSSFontSelector to
+        StyleResolver::appendAuthorStyleSheets(), when it's really needed. This way, we can sidestep
+        this whole problem.
+
+        There's also an added benefit: Now, buildStarted() doesn't have to be idempotent, so we can
+        enforce a stricter calling sequence with ASSERT()s.
+
+        * css/CSSFontFaceSet.cpp:
+        (WebCore::CSSFontFaceSet::emptyCaches):
+        * css/CSSFontFaceSet.h:
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::emptyCaches):
+
+            Add a separate function to clear font selector caches.
+
+        (WebCore::CSSFontSelector::buildStarted):
+        (WebCore::CSSFontSelector::buildCompleted):
+        (WebCore::CSSFontSelector::addFontFaceRule):
+        (WebCore::CSSFontSelector::fontModified):
+
+            No need to invalidate while building.
+
+        (WebCore::CSSFontSelector::fontRangesForFamily):
+        * css/CSSFontSelector.h:
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::StyleResolver):
+        (WebCore::StyleResolver::addCurrentSVGFontFaceRules):
+
+            Factor into a function from the constructor.
+
+        (WebCore::StyleResolver::appendAuthorStyleSheets):
+
+            Font selector build is now started and finished by StyleScope.
+
+        * css/StyleResolver.h:
+        * dom/Document.cpp:
+        (WebCore::Document::resolveStyle):
+
+            Call FrameView::styleDidChange() to update any custom scrollbars.
+            This bug was hidden by spurious style recalcs, tested by fast/css/scrollbar-dynamic-style-change.html
+
+        (WebCore::Document::userAgentShadowTreeStyleResolver):
+        (WebCore::Document::didClearStyleResolver):
+
+            Don't start the font selector rebuild after clearing the resolver. It would cause style recalc trashing.
+            Instead the build starts when the new resolver is constructed.
+
+        * page/MemoryRelease.cpp:
+        (WebCore::releaseCriticalMemory):
+
+            Release font selector caches.
+
+        * style/StyleScope.cpp:
+        (WebCore::Style::Scope::resolver):
+
 2017-07-05  Brent Fulgham  <bfulg...@apple.com>
 
         [WK2] Prevent ResourceLoadStatistics from triggering a cascade of read/write events

Modified: trunk/Source/WebCore/css/CSSFontFaceSet.cpp (219144 => 219145)


--- trunk/Source/WebCore/css/CSSFontFaceSet.cpp	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/css/CSSFontFaceSet.cpp	2017-07-05 19:53:55 UTC (rev 219145)
@@ -268,6 +268,11 @@
         remove(item.get());
 }
 
+void CSSFontFaceSet::emptyCaches()
+{
+    m_cache.clear();
+}
+
 void CSSFontFaceSet::clear()
 {
     for (auto& face : m_faces)

Modified: trunk/Source/WebCore/css/CSSFontFaceSet.h (219144 => 219145)


--- trunk/Source/WebCore/css/CSSFontFaceSet.h	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/css/CSSFontFaceSet.h	2017-07-05 19:53:55 UTC (rev 219145)
@@ -60,6 +60,7 @@
     void add(CSSFontFace&);
     void remove(const CSSFontFace&);
     void purge();
+    void emptyCaches();
     void clear();
     CSSFontFace& operator[](size_t i);
 

Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (219144 => 219145)


--- trunk/Source/WebCore/css/CSSFontSelector.cpp	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp	2017-07-05 19:53:55 UTC (rev 219145)
@@ -51,6 +51,7 @@
 #include "StyleRule.h"
 #include "WebKitFontFamilyNames.h"
 #include <wtf/Ref.h>
+#include <wtf/SetForScope.h>
 #include <wtf/text/AtomicString.h>
 
 namespace WebCore {
@@ -91,15 +92,20 @@
     return !m_cssFontFaceSet->faceCount();
 }
 
+void CSSFontSelector::emptyCaches()
+{
+    m_cssFontFaceSet->emptyCaches();
+}
+
 void CSSFontSelector::buildStarted()
 {
     m_buildIsUnderway = true;
-    m_stagingArea.clear();
     m_cssFontFaceSet->purge();
     ++m_version;
 
-    m_cssConnectionsPossiblyToRemove.clear();
-    m_cssConnectionsEncounteredDuringBuild.clear();
+    ASSERT(m_cssConnectionsPossiblyToRemove.isEmpty());
+    ASSERT(m_cssConnectionsEncounteredDuringBuild.isEmpty());
+    ASSERT(m_stagingArea.isEmpty());
     for (size_t i = 0; i < m_cssFontFaceSet->faceCount(); ++i) {
         CSSFontFace& face = m_cssFontFaceSet.get()[i];
         if (face.cssConnection())
@@ -124,7 +130,9 @@
 
     for (auto& item : m_stagingArea)
         addFontFaceRule(item.styleRuleFontFace, item.isInitiatingElementInUserAgentShadowTree);
+    m_cssConnectionsEncounteredDuringBuild.clear();
     m_stagingArea.clear();
+    m_cssConnectionsPossiblyToRemove.clear();
 }
 
 void CSSFontSelector::addFontFaceRule(StyleRuleFontFace& fontFaceRule, bool isInitiatingElementInUserAgentShadowTree)
@@ -162,7 +170,7 @@
     if (!srcList.length())
         return;
 
-    m_creatingFont = true;
+    SetForScope<bool> creatingFont(m_creatingFont, true);
     Ref<CSSFontFace> fontFace = CSSFontFace::create(this, &fontFaceRule);
 
     if (!fontFace->setFamilies(*fontFamily))
@@ -211,7 +219,6 @@
     }
 
     m_cssFontFaceSet->add(fontFace.get());
-    m_creatingFont = false;
     ++m_version;
 }
 
@@ -242,7 +249,7 @@
 
 void CSSFontSelector::fontModified()
 {
-    if (!m_creatingFont)
+    if (!m_creatingFont && !m_buildIsUnderway)
         dispatchInvalidationCallbacks();
 }
 
@@ -280,7 +287,7 @@
 FontRanges CSSFontSelector::fontRangesForFamily(const FontDescription& fontDescription, const AtomicString& familyName)
 {
     // If this ASSERT() fires, it usually means you forgot a document.updateStyleIfNeeded() somewhere.
-    ASSERT(!m_buildIsUnderway || m_isComputingRootStyleFont);
+    ASSERT(!m_buildIsUnderway || m_computingRootStyleFontCount);
 
     // FIXME: The spec (and Firefox) says user specified generic families (sans-serif etc.) should be resolved before the @font-face lookup too.
     bool resolveGenericFamilyFirst = familyName == standardFamily;

Modified: trunk/Source/WebCore/css/CSSFontSelector.h (219144 => 219145)


--- trunk/Source/WebCore/css/CSSFontSelector.h	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/css/CSSFontSelector.h	2017-07-05 19:53:55 UTC (rev 219145)
@@ -63,6 +63,7 @@
     RefPtr<Font> fallbackFontAt(const FontDescription&, size_t) final;
 
     void clearDocument();
+    void emptyCaches();
     void buildStarted();
     void buildCompleted();
 
@@ -82,7 +83,8 @@
 
     FontFaceSet& fontFaceSet();
 
-    void setIsComputingRootStyleFont(bool value) { m_isComputingRootStyleFont = value; }
+    void incrementIsComputingRootStyleFont() { ++m_computingRootStyleFontCount; }
+    void decrementIsComputingRootStyleFont() { --m_computingRootStyleFontCount; }
 
 private:
     explicit CSSFontSelector(Document&);
@@ -111,9 +113,9 @@
 
     unsigned m_uniqueId;
     unsigned m_version;
+    unsigned m_computingRootStyleFontCount { 0 };
     bool m_creatingFont { false };
     bool m_buildIsUnderway { false };
-    bool m_isComputingRootStyleFont { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (219144 => 219145)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2017-07-05 19:53:55 UTC (rev 219145)
@@ -222,10 +222,10 @@
     if (root) {
         m_rootDefaultStyle = styleForElement(*root, m_document.renderStyle(), nullptr, MatchOnlyUserAgentRules).renderStyle;
         // Turn off assertion against font lookups during style resolver initialization. We may need root style font for media queries.
-        m_document.fontSelector().setIsComputingRootStyleFont(true);
+        m_document.fontSelector().incrementIsComputingRootStyleFont();
         m_rootDefaultStyle->fontCascade().update(&m_document.fontSelector());
         m_rootDefaultStyle->fontCascade().primaryFont();
-        m_document.fontSelector().setIsComputingRootStyleFont(false);
+        m_document.fontSelector().decrementIsComputingRootStyleFont();
     }
 
     if (m_rootDefaultStyle && view)
@@ -232,7 +232,10 @@
         m_mediaQueryEvaluator = MediaQueryEvaluator { view->mediaType(), m_document, m_rootDefaultStyle.get() };
 
     m_ruleSets.resetAuthorStyle();
+}
 
+void StyleResolver::addCurrentSVGFontFaceRules()
+{
 #if ENABLE(SVG_FONTS)
     if (m_document.svgExtensions()) {
         const HashSet<SVGFontFaceElement*>& svgFontFaceElements = m_document.svgExtensions()->svgFontFaceElements();
@@ -246,8 +249,6 @@
 {
     m_ruleSets.appendAuthorStyleSheets(styleSheets, &m_mediaQueryEvaluator, m_inspectorCSSOMWrappers, this);
 
-    document().fontSelector().buildCompleted();
-
     if (auto renderView = document().renderView())
         renderView->style().fontCascade().update(&document().fontSelector());
 

Modified: trunk/Source/WebCore/css/StyleResolver.h (219144 => 219145)


--- trunk/Source/WebCore/css/StyleResolver.h	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/css/StyleResolver.h	2017-07-05 19:53:55 UTC (rev 219145)
@@ -157,6 +157,8 @@
 
     void setOverrideDocumentElementStyle(RenderStyle* style) { m_overrideDocumentElementStyle = style; }
 
+    void addCurrentSVGFontFaceRules();
+
 private:
     std::unique_ptr<RenderStyle> styleForKeyframe(const RenderStyle*, const StyleRuleKeyframe*, KeyframeValue&);
 

Modified: trunk/Source/WebCore/dom/Document.cpp (219144 => 219145)


--- trunk/Source/WebCore/dom/Document.cpp	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-07-05 19:53:55 UTC (rev 219145)
@@ -1838,6 +1838,8 @@
 
             RenderTreeUpdater updater(*this);
             updater.commit(WTFMove(styleUpdate));
+
+            frameView.styleDidChange();
         }
 
         updatedCompositingLayers = frameView.updateCompositingLayersAfterStyleChange();
@@ -2148,8 +2150,6 @@
 void Document::didClearStyleResolver()
 {
     m_userAgentShadowTreeStyleResolver = nullptr;
-
-    m_fontSelector->buildStarted();
 }
 
 void Document::createRenderTree()

Modified: trunk/Source/WebCore/page/MemoryRelease.cpp (219144 => 219145)


--- trunk/Source/WebCore/page/MemoryRelease.cpp	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/page/MemoryRelease.cpp	2017-07-05 19:53:55 UTC (rev 219145)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "MemoryRelease.h"
 
+#include "CSSFontSelector.h"
 #include "CSSValuePool.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
@@ -84,8 +85,10 @@
 
     Vector<RefPtr<Document>> documents;
     copyToVector(Document::allDocuments(), documents);
-    for (auto& document : documents)
+    for (auto& document : documents) {
         document->styleScope().clearResolver();
+        document->fontSelector().emptyCaches();
+    }
 
     GCController::singleton().deleteAllCode(JSC::DeleteAllCodeIfNotCollecting);
 

Modified: trunk/Source/WebCore/style/StyleScope.cpp (219144 => 219145)


--- trunk/Source/WebCore/style/StyleScope.cpp	2017-07-05 19:05:24 UTC (rev 219144)
+++ trunk/Source/WebCore/style/StyleScope.cpp	2017-07-05 19:53:55 UTC (rev 219145)
@@ -28,6 +28,7 @@
 #include "config.h"
 #include "StyleScope.h"
 
+#include "CSSFontSelector.h"
 #include "CSSStyleSheet.h"
 #include "Element.h"
 #include "ElementChildIterator.h"
@@ -95,14 +96,20 @@
 
     if (!m_resolver) {
         SetForScope<bool> isUpdatingStyleResolver { m_isUpdatingStyleResolver, true };
+
         m_resolver = std::make_unique<StyleResolver>(m_document);
 
-        if (!m_shadowRoot)
+        if (!m_shadowRoot) {
+            m_document.fontSelector().buildStarted();
             m_resolver->ruleSets().initializeUserStyle();
-        else
+        } else
             m_resolver->ruleSets().setUsesSharedUserStyle(m_shadowRoot->mode() != ShadowRootMode::UserAgent);
 
+        m_resolver->addCurrentSVGFontFaceRules();
         m_resolver->appendAuthorStyleSheets(m_activeStyleSheets);
+
+        if (!m_shadowRoot)
+            m_document.fontSelector().buildCompleted();
     }
     ASSERT(!m_shadowRoot || &m_document == &m_shadowRoot->document());
     ASSERT(&m_resolver->document() == &m_document);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to