<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[213515] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/213515">213515</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2017-03-07 08:54:56 -0800 (Tue, 07 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Differentiate between pending head and body stylesheets in Style::Scope
https://bugs.webkit.org/show_bug.cgi?id=169277
Reviewed by Andreas Kling.
Split pending stylesheet node set into separate sets for head and body elements and processing instructions.
This tightens typing and will also be useful later.
* style/StyleScope.cpp:
(WebCore::Style::Scope::~Scope):
(WebCore::Style::Scope::addPendingSheet):
(WebCore::Style::Scope::removePendingSheet):
(WebCore::Style::Scope::didRemovePendingStylesheet):
(WebCore::Style::Scope::hasPendingSheet):
(WebCore::Style::Scope::hasPendingSheetInBody):
(WebCore::Style::Scope::hasProcessingInstructionWithPendingSheet): Deleted.
* style/StyleScope.h:
(WebCore::Style::Scope::hasPendingSheet): Deleted.
(WebCore::Style::Scope::hasPendingSheets): Deleted.
* style/StyleTreeResolver.cpp:
(WebCore::Style::hasLoadingStylesheet):
Just test for body stylesheets.
(WebCore::Style::TreeResolver::resolve):
Treat all before-body stylesheets uniformly.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorestyleStyleScopecpp">trunk/Source/WebCore/style/StyleScope.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleScopeh">trunk/Source/WebCore/style/StyleScope.h</a></li>
<li><a href="#trunkSourceWebCorestyleStyleTreeResolvercpp">trunk/Source/WebCore/style/StyleTreeResolver.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213514 => 213515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-07 16:23:30 UTC (rev 213514)
+++ trunk/Source/WebCore/ChangeLog        2017-03-07 16:54:56 UTC (rev 213515)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2017-03-07 Antti Koivisto <antti@apple.com>
+
+ Differentiate between pending head and body stylesheets in Style::Scope
+ https://bugs.webkit.org/show_bug.cgi?id=169277
+
+ Reviewed by Andreas Kling.
+
+ Split pending stylesheet node set into separate sets for head and body elements and processing instructions.
+
+ This tightens typing and will also be useful later.
+
+ * style/StyleScope.cpp:
+ (WebCore::Style::Scope::~Scope):
+ (WebCore::Style::Scope::addPendingSheet):
+ (WebCore::Style::Scope::removePendingSheet):
+ (WebCore::Style::Scope::didRemovePendingStylesheet):
+ (WebCore::Style::Scope::hasPendingSheet):
+ (WebCore::Style::Scope::hasPendingSheetInBody):
+ (WebCore::Style::Scope::hasProcessingInstructionWithPendingSheet): Deleted.
+ * style/StyleScope.h:
+ (WebCore::Style::Scope::hasPendingSheet): Deleted.
+ (WebCore::Style::Scope::hasPendingSheets): Deleted.
+ * style/StyleTreeResolver.cpp:
+ (WebCore::Style::hasLoadingStylesheet):
+
+ Just test for body stylesheets.
+
+ (WebCore::Style::TreeResolver::resolve):
+
+ Treat all before-body stylesheets uniformly.
+
</ins><span class="cx"> 2017-03-07 Antoine Quint <graouts@apple.com>
</span><span class="cx">
</span><span class="cx"> [Modern Media Controls] Setting a valid source after an invalid one retains the invalid placard
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleScope.cpp (213514 => 213515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleScope.cpp        2017-03-07 16:23:30 UTC (rev 213514)
+++ trunk/Source/WebCore/style/StyleScope.cpp        2017-03-07 16:54:56 UTC (rev 213515)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include "Element.h"
</span><span class="cx"> #include "ElementChildIterator.h"
</span><span class="cx"> #include "ExtensionStyleSheets.h"
</span><ins>+#include "HTMLHeadElement.h"
</ins><span class="cx"> #include "HTMLIFrameElement.h"
</span><span class="cx"> #include "HTMLLinkElement.h"
</span><span class="cx"> #include "HTMLSlotElement.h"
</span><span class="lines">@@ -72,7 +73,7 @@
</span><span class="cx">
</span><span class="cx"> Scope::~Scope()
</span><span class="cx"> {
</span><del>- ASSERT(m_nodesWithPendingSheets.isEmpty());
</del><ins>+ ASSERT(!hasPendingSheets());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool Scope::shouldUseSharedUserAgentShadowTreeStyleResolver() const
</span><span class="lines">@@ -172,20 +173,48 @@
</span><span class="cx"> didChangeActiveStyleSheetCandidates();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Scope::addPendingSheet(const Node& node)
</del><ins>+
+void Scope::addPendingSheet(const Element& element)
</ins><span class="cx"> {
</span><del>- ASSERT(!m_nodesWithPendingSheets.contains(&node));
</del><ins>+ ASSERT(!hasPendingSheet(element));
</ins><span class="cx">
</span><del>- m_nodesWithPendingSheets.add(&node);
</del><ins>+ bool isInHead = ancestorsOfType<HTMLHeadElement>(element).first();
+ if (isInHead)
+ m_elementsInHeadWithPendingSheets.add(&element);
+ else
+ m_elementsInBodyWithPendingSheets.add(&element);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // This method is called whenever a top-level stylesheet has finished loading.
</span><del>-void Scope::removePendingSheet(const Node& node)
</del><ins>+void Scope::removePendingSheet(const Element& element)
</ins><span class="cx"> {
</span><del>- ASSERT(m_nodesWithPendingSheets.contains(&node));
</del><ins>+ ASSERT(hasPendingSheet(element));
</ins><span class="cx">
</span><del>- m_nodesWithPendingSheets.remove(&node);
- if (!m_nodesWithPendingSheets.isEmpty())
</del><ins>+ if (!m_elementsInHeadWithPendingSheets.remove(&element))
+ m_elementsInBodyWithPendingSheets.remove(&element);
+
+ didRemovePendingStylesheet();
+}
+
+void Scope::addPendingSheet(const ProcessingInstruction& processingInstruction)
+{
+ ASSERT(!m_processingInstructionsWithPendingSheets.contains(&processingInstruction));
+
+ m_processingInstructionsWithPendingSheets.add(&processingInstruction);
+}
+
+void Scope::removePendingSheet(const ProcessingInstruction& processingInstruction)
+{
+ ASSERT(m_processingInstructionsWithPendingSheets.contains(&processingInstruction));
+
+ m_processingInstructionsWithPendingSheets.remove(&processingInstruction);
+
+ didRemovePendingStylesheet();
+}
+
+void Scope::didRemovePendingStylesheet()
+{
+ if (hasPendingSheets())
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> didChangeActiveStyleSheetCandidates();
</span><span class="lines">@@ -194,19 +223,14 @@
</span><span class="cx"> m_document.didRemoveAllPendingStylesheet();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool Scope::hasProcessingInstructionWithPendingSheet()
</del><ins>+bool Scope::hasPendingSheet(const Element& element) const
</ins><span class="cx"> {
</span><del>- ASSERT(!m_shadowRoot);
</del><ins>+ return m_elementsInHeadWithPendingSheets.contains(&element) || hasPendingSheetInBody(element);
+}
</ins><span class="cx">
</span><del>- for (auto* child = m_document.firstChild(); child; child = child->nextSibling()) {
- if (is<Element>(*child))
- return false;
- if (m_nodesWithPendingSheets.contains(child)) {
- ASSERT(is<ProcessingInstruction>(*child));
- return true;
- }
- }
- return false;
</del><ins>+bool Scope::hasPendingSheetInBody(const Element& element) const
+{
+ return m_elementsInBodyWithPendingSheets.contains(&element);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Scope::addStyleSheetCandidateNode(Node& node, bool createdByParser)
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleScopeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleScope.h (213514 => 213515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleScope.h        2017-03-07 16:23:30 UTC (rev 213514)
+++ trunk/Source/WebCore/style/StyleScope.h        2017-03-07 16:54:56 UTC (rev 213515)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> class Document;
</span><span class="cx"> class Element;
</span><span class="cx"> class Node;
</span><ins>+class ProcessingInstruction;
</ins><span class="cx"> class StyleResolver;
</span><span class="cx"> class StyleSheet;
</span><span class="cx"> class StyleSheetContents;
</span><span class="lines">@@ -82,11 +83,15 @@
</span><span class="cx"> void setPreferredStylesheetSetName(const String&);
</span><span class="cx"> void setSelectedStylesheetSetName(const String&);
</span><span class="cx">
</span><del>- void addPendingSheet(const Node&);
- void removePendingSheet(const Node&);
- bool hasPendingSheet(const Node& node) const { return m_nodesWithPendingSheets.contains(&node); }
- bool hasProcessingInstructionWithPendingSheet();
- bool hasPendingSheets() const { return !m_nodesWithPendingSheets.isEmpty(); }
</del><ins>+ void addPendingSheet(const Element&);
+ void removePendingSheet(const Element&);
+ void addPendingSheet(const ProcessingInstruction&);
+ void removePendingSheet(const ProcessingInstruction&);
+ bool hasPendingSheets() const;
+ bool hasPendingSheetsBeforeBody() const;
+ bool hasPendingSheetsInBody() const;
+ bool hasPendingSheet(const Element&) const;
+ bool hasPendingSheetInBody(const Element&) const;
</ins><span class="cx">
</span><span class="cx"> bool usesStyleBasedEditability() { return m_usesStyleBasedEditability; }
</span><span class="cx">
</span><span class="lines">@@ -115,6 +120,8 @@
</span><span class="cx"> private:
</span><span class="cx"> bool shouldUseSharedUserAgentShadowTreeStyleResolver() const;
</span><span class="cx">
</span><ins>+ void didRemovePendingStylesheet();
+
</ins><span class="cx"> enum class UpdateType { ActiveSet, ContentsOrInterpretation };
</span><span class="cx"> void updateActiveStyleSheets(UpdateType);
</span><span class="cx"> void scheduleUpdate(UpdateType);
</span><span class="lines">@@ -143,7 +150,6 @@
</span><span class="cx"> Vector<RefPtr<StyleSheet>> m_styleSheetsForStyleSheetList;
</span><span class="cx"> Vector<RefPtr<CSSStyleSheet>> m_activeStyleSheets;
</span><span class="cx">
</span><del>-
</del><span class="cx"> Timer m_pendingUpdateTimer;
</span><span class="cx">
</span><span class="cx"> mutable std::unique_ptr<HashSet<const CSSStyleSheet*>> m_weakCopyOfActiveStyleSheetListForFastLookup;
</span><span class="lines">@@ -152,7 +158,9 @@
</span><span class="cx"> // Sheets loaded using the @import directive are not included in this count.
</span><span class="cx"> // We use this count of pending sheets to detect when we can begin attaching
</span><span class="cx"> // elements and when it is safe to execute scripts.
</span><del>- HashSet<const Node*> m_nodesWithPendingSheets;
</del><ins>+ HashSet<const ProcessingInstruction*> m_processingInstructionsWithPendingSheets;
+ HashSet<const Element*> m_elementsInHeadWithPendingSheets;
+ HashSet<const Element*> m_elementsInBodyWithPendingSheets;
</ins><span class="cx">
</span><span class="cx"> bool m_didUpdateActiveStyleSheets { false };
</span><span class="cx">
</span><span class="lines">@@ -168,6 +176,21 @@
</span><span class="cx"> bool m_isUpdatingStyleResolver { false };
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+inline bool Scope::hasPendingSheets() const
+{
+ return hasPendingSheetsBeforeBody() || !m_elementsInBodyWithPendingSheets.isEmpty();
+}
+
+inline bool Scope::hasPendingSheetsBeforeBody() const
+{
+ return !m_elementsInHeadWithPendingSheets.isEmpty() || !m_processingInstructionsWithPendingSheets.isEmpty();
+}
+
+inline bool Scope::hasPendingSheetsInBody() const
+{
+ return !m_elementsInBodyWithPendingSheets.isEmpty();
+}
+
</ins><span class="cx"> inline void Scope::flushPendingUpdate()
</span><span class="cx"> {
</span><span class="cx"> if (m_hasDescendantWithPendingUpdate)
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleTreeResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (213514 => 213515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleTreeResolver.cpp        2017-03-07 16:23:30 UTC (rev 213514)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp        2017-03-07 16:54:56 UTC (rev 213515)
</span><span class="lines">@@ -361,14 +361,14 @@
</span><span class="cx">
</span><span class="cx"> static bool hasLoadingStylesheet(const Style::Scope& styleScope, const Element& element, bool checkDescendants)
</span><span class="cx"> {
</span><del>- if (!styleScope.hasPendingSheets())
</del><ins>+ if (!styleScope.hasPendingSheetsInBody())
</ins><span class="cx"> return false;
</span><del>- if (styleScope.hasPendingSheet(element))
</del><ins>+ if (styleScope.hasPendingSheetInBody(element))
</ins><span class="cx"> return true;
</span><span class="cx"> if (!checkDescendants)
</span><span class="cx"> return false;
</span><span class="cx"> for (auto& descendant : descendantsOfType<Element>(element)) {
</span><del>- if (styleScope.hasPendingSheet(descendant))
</del><ins>+ if (styleScope.hasPendingSheetInBody(descendant))
</ins><span class="cx"> return true;
</span><span class="cx"> };
</span><span class="cx"> return false;
</span><span class="lines">@@ -482,7 +482,7 @@
</span><span class="cx"> if (!documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc())
</span><span class="cx"> return nullptr;
</span><span class="cx">
</span><del>- m_didSeePendingStylesheet = m_document.styleScope().hasProcessingInstructionWithPendingSheet();
</del><ins>+ m_didSeePendingStylesheet = m_document.styleScope().hasPendingSheetsBeforeBody();
</ins><span class="cx">
</span><span class="cx"> m_update = std::make_unique<Update>(m_document);
</span><span class="cx"> m_scopeStack.append(adoptRef(*new Scope(m_document)));
</span></span></pre>
</div>
</div>
</body>
</html>