Diff
Modified: trunk/Source/WebCore/ChangeLog (224115 => 224116)
--- trunk/Source/WebCore/ChangeLog 2017-10-27 16:49:56 UTC (rev 224115)
+++ trunk/Source/WebCore/ChangeLog 2017-10-27 17:06:17 UTC (rev 224116)
@@ -1,3 +1,16 @@
+2017-10-27 Ryan Haddad <[email protected]>
+
+ Unreviewed, rolling out r223999.
+
+ Caused xsl LayoutTest flakiness.
+
+ Reverted changeset:
+
+ "Style::Scope::flushPendingUpdate() can replace the entire
+ document in XSLTProcessor::createDocumentFromSource"
+ https://bugs.webkit.org/show_bug.cgi?id=178715
+ https://trac.webkit.org/changeset/223999
+
2017-10-27 Chris Dumez <[email protected]>
Audit init*Event() method to make sure they reset internal data members
Modified: trunk/Source/WebCore/dom/Document.cpp (224115 => 224116)
--- trunk/Source/WebCore/dom/Document.cpp 2017-10-27 16:49:56 UTC (rev 224115)
+++ trunk/Source/WebCore/dom/Document.cpp 2017-10-27 17:06:17 UTC (rev 224116)
@@ -480,7 +480,6 @@
, m_documentCreationTime(MonotonicTime::now())
, m_scriptRunner(std::make_unique<ScriptRunner>(*this))
, m_moduleLoader(std::make_unique<ScriptModuleLoader>(*this))
- , m_applyPendingXSLTransformsTimer(*this, &Document::applyPendingXSLTransformsTimerFired)
, m_xmlVersion(ASCIILiteral("1.0"))
, m_constantPropertyMap(std::make_unique<ConstantPropertyMap>(*this))
, m_documentClasses(documentClasses)
@@ -2746,9 +2745,6 @@
// ramifications, and we need to decide what is the Right Thing To Do(tm)
RefPtr<Frame> f = frame();
if (f) {
- // Apply XSL transforms before load events so that event handlers can access the transformed DOM tree.
- applyPendingXSLTransformsNowIfScheduled();
-
if (auto* documentLoader = loader())
documentLoader->startIconLoading();
@@ -5075,45 +5071,20 @@
#if ENABLE(XSLT)
-void Document::scheduleToApplyXSLTransforms()
+void Document::applyXSLTransform(ProcessingInstruction* pi)
{
- if (!m_applyPendingXSLTransformsTimer.isActive())
- m_applyPendingXSLTransformsTimer.startOneShot(0_s);
-}
-
-void Document::applyPendingXSLTransformsNowIfScheduled()
-{
- if (!m_applyPendingXSLTransformsTimer.isActive())
+ RefPtr<XSLTProcessor> processor = XSLTProcessor::create();
+ processor->setXSLStyleSheet(downcast<XSLStyleSheet>(pi->sheet()));
+ String resultMIMEType;
+ String newSource;
+ String resultEncoding;
+ if (!processor->transformToString(*this, resultMIMEType, newSource, resultEncoding))
return;
- m_applyPendingXSLTransformsTimer.stop();
- applyPendingXSLTransformsTimerFired();
+ // FIXME: If the transform failed we should probably report an error (like Mozilla does).
+ Frame* ownerFrame = frame();
+ processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, this, ownerFrame);
}
-void Document::applyPendingXSLTransformsTimerFired()
-{
- if (parsing())
- return;
-
- ASSERT(NoEventDispatchAssertion::isEventAllowedInMainThread());
- for (auto& processingInstruction : styleScope().collectXSLTransforms()) {
- ASSERT(processingInstruction->isXSL());
-
- // Don't apply XSL transforms to already transformed documents -- <rdar://problem/4132806>
- if (transformSourceDocument() || !processingInstruction->sheet())
- return;
-
- auto processor = XSLTProcessor::create();
- processor->setXSLStyleSheet(downcast<XSLStyleSheet>(processingInstruction->sheet()));
- String resultMIMEType;
- String newSource;
- String resultEncoding;
- if (!processor->transformToString(*this, resultMIMEType, newSource, resultEncoding))
- continue;
- // FIXME: If the transform failed we should probably report an error (like Mozilla does).
- processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, this, frame());
- }
-}
-
void Document::setTransformSource(std::unique_ptr<TransformSource> source)
{
m_transformSource = WTFMove(source);
@@ -5293,8 +5264,6 @@
ASSERT(!scriptableDocumentParser() || m_readyState != Loading);
setParsing(false);
- Ref<Document> protectedThis(*this);
-
if (!m_documentTiming.domContentLoadedEventStart)
m_documentTiming.domContentLoadedEventStart = MonotonicTime::now();
@@ -5304,8 +5273,6 @@
m_documentTiming.domContentLoadedEventEnd = MonotonicTime::now();
if (RefPtr<Frame> frame = this->frame()) {
- applyPendingXSLTransformsNowIfScheduled();
-
// FrameLoader::finishedParsing() might end up calling Document::implicitClose() if all
// resource loads are complete. HTMLObjectElements can start loading their resources from
// post attach callbacks triggered by resolveStyle(). This means if we parse out an <object>
Modified: trunk/Source/WebCore/dom/Document.h (224115 => 224116)
--- trunk/Source/WebCore/dom/Document.h 2017-10-27 16:49:56 UTC (rev 224115)
+++ trunk/Source/WebCore/dom/Document.h 2017-10-27 17:06:17 UTC (rev 224116)
@@ -952,8 +952,7 @@
void popCurrentScript();
#if ENABLE(XSLT)
- void scheduleToApplyXSLTransforms();
- void applyPendingXSLTransformsNowIfScheduled();
+ void applyXSLTransform(ProcessingInstruction* pi);
RefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
@@ -1568,11 +1567,8 @@
Vector<RefPtr<HTMLScriptElement>> m_currentScriptStack;
#if ENABLE(XSLT)
- void applyPendingXSLTransformsTimerFired();
-
std::unique_ptr<TransformSource> m_transformSource;
RefPtr<Document> m_transformSourceDocument;
- Timer m_applyPendingXSLTransformsTimer;
#endif
String m_xmlEncoding;
Modified: trunk/Source/WebCore/dom/ProcessingInstruction.cpp (224115 => 224116)
--- trunk/Source/WebCore/dom/ProcessingInstruction.cpp 2017-10-27 16:49:56 UTC (rev 224115)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.cpp 2017-10-27 17:06:17 UTC (rev 224116)
@@ -126,7 +126,6 @@
URL finalURL(ParsedURLString, m_localHref);
m_sheet = XSLStyleSheet::createEmbedded(this, finalURL);
m_loading = false;
- document().scheduleToApplyXSLTransforms();
}
#endif
} else {
@@ -180,7 +179,7 @@
document().styleScope().removePendingSheet(*this);
#if ENABLE(XSLT)
if (m_isXSL)
- document().scheduleToApplyXSLTransforms();
+ document().styleScope().flushPendingUpdate();
#endif
}
}
@@ -203,7 +202,7 @@
document().styleScope().removePendingSheet(*this);
#if ENABLE(XSLT)
if (m_isXSL)
- document().scheduleToApplyXSLTransforms();
+ document().styleScope().flushPendingUpdate();
#endif
return true;
}
Modified: trunk/Source/WebCore/style/StyleScope.cpp (224115 => 224116)
--- trunk/Source/WebCore/style/StyleScope.cpp 2017-10-27 16:49:56 UTC (rev 224115)
+++ trunk/Source/WebCore/style/StyleScope.cpp 2017-10-27 17:06:17 UTC (rev 224116)
@@ -290,19 +290,6 @@
didChangeActiveStyleSheetCandidates();
}
-#if ENABLE(XSLT)
-// FIXME: <https://webkit.org/b/178830> Remove XSLT relaed code from Style::Scope.
-Vector<Ref<ProcessingInstruction>> Scope::collectXSLTransforms()
-{
- Vector<Ref<ProcessingInstruction>> processingInstructions;
- for (auto& node : m_styleSheetCandidateNodes) {
- if (is<ProcessingInstruction>(*node) && downcast<ProcessingInstruction>(*node).isXSL())
- processingInstructions.append(downcast<ProcessingInstruction>(*node));
- }
- return processingInstructions;
-}
-#endif
-
void Scope::collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>& sheets)
{
if (!m_document.settings().authorAndUserStylesEnabled())
@@ -309,12 +296,21 @@
return;
for (auto& node : m_styleSheetCandidateNodes) {
- RefPtr<StyleSheet> sheet;
+ StyleSheet* sheet = nullptr;
if (is<ProcessingInstruction>(*node)) {
- if (!downcast<ProcessingInstruction>(*node).isCSS())
- continue;
+ // Processing instruction (XML documents only).
// We don't support linking to embedded CSS stylesheets, see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion.
- sheet = downcast<ProcessingInstruction>(*node).sheet();
+ ProcessingInstruction& pi = downcast<ProcessingInstruction>(*node);
+ sheet = pi.sheet();
+#if ENABLE(XSLT)
+ // Don't apply XSL transforms to already transformed documents -- <rdar://problem/4132806>
+ if (pi.isXSL() && !m_document.transformSourceDocument()) {
+ // Don't apply XSL transforms until loading is finished.
+ if (!m_document.parsing())
+ m_document.applyXSLTransform(&pi);
+ return;
+ }
+#endif
} else if (is<HTMLLinkElement>(*node) || is<HTMLStyleElement>(*node) || is<SVGStyleElement>(*node)) {
Element& element = downcast<Element>(*node);
AtomicString title = element.attributeWithoutSynchronization(titleAttr);
@@ -368,7 +364,7 @@
sheet = nullptr;
}
if (sheet)
- sheets.append(WTFMove(sheet));
+ sheets.append(sheet);
}
}
Modified: trunk/Source/WebCore/style/StyleScope.h (224115 => 224116)
--- trunk/Source/WebCore/style/StyleScope.h 2017-10-27 16:49:56 UTC (rev 224115)
+++ trunk/Source/WebCore/style/StyleScope.h 2017-10-27 17:06:17 UTC (rev 224116)
@@ -108,10 +108,6 @@
bool hasPendingUpdate() const { return m_pendingUpdate || m_hasDescendantWithPendingUpdate; }
void flushPendingUpdate();
-#if ENABLE(XSLT)
- Vector<Ref<ProcessingInstruction>> collectXSLTransforms();
-#endif
-
StyleResolver& resolver();
StyleResolver* resolverIfExists();
void clearResolver();
Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (224115 => 224116)
--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2017-10-27 16:49:56 UTC (rev 224115)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2017-10-27 17:06:17 UTC (rev 224116)
@@ -1333,7 +1333,7 @@
document()->setTransformSource(std::make_unique<TransformSource>(doc));
document()->setParsing(false); // Make the document think it's done, so it will apply XSL stylesheets.
- document()->applyPendingXSLTransformsNowIfScheduled();
+ document()->styleScope().didChangeActiveStyleSheetCandidates();
// styleResolverChanged() call can detach the parser and null out its document.
// In that case, we just bail out.