Changeset 224116 in webkit
- Timestamp:
- Oct 27, 2017 10:06:17 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r224115 r224116 1 2017-10-27 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r223999. 4 5 Caused xsl LayoutTest flakiness. 6 7 Reverted changeset: 8 9 "Style::Scope::flushPendingUpdate() can replace the entire 10 document in XSLTProcessor::createDocumentFromSource" 11 https://bugs.webkit.org/show_bug.cgi?id=178715 12 https://trac.webkit.org/changeset/223999 13 1 14 2017-10-27 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Source/WebCore/dom/Document.cpp
r224113 r224116 481 481 , m_scriptRunner(std::make_unique<ScriptRunner>(*this)) 482 482 , m_moduleLoader(std::make_unique<ScriptModuleLoader>(*this)) 483 , m_applyPendingXSLTransformsTimer(*this, &Document::applyPendingXSLTransformsTimerFired)484 483 , m_xmlVersion(ASCIILiteral("1.0")) 485 484 , m_constantPropertyMap(std::make_unique<ConstantPropertyMap>(*this)) … … 2747 2746 RefPtr<Frame> f = frame(); 2748 2747 if (f) { 2749 // Apply XSL transforms before load events so that event handlers can access the transformed DOM tree.2750 applyPendingXSLTransformsNowIfScheduled();2751 2752 2748 if (auto* documentLoader = loader()) 2753 2749 documentLoader->startIconLoading(); … … 5076 5072 #if ENABLE(XSLT) 5077 5073 5078 void Document::scheduleToApplyXSLTransforms() 5079 { 5080 if (!m_applyPendingXSLTransformsTimer.isActive()) 5081 m_applyPendingXSLTransformsTimer.startOneShot(0_s); 5082 } 5083 5084 void Document::applyPendingXSLTransformsNowIfScheduled() 5085 { 5086 if (!m_applyPendingXSLTransformsTimer.isActive()) 5087 return; 5088 m_applyPendingXSLTransformsTimer.stop(); 5089 applyPendingXSLTransformsTimerFired(); 5090 } 5091 5092 void Document::applyPendingXSLTransformsTimerFired() 5093 { 5094 if (parsing()) 5095 return; 5096 5097 ASSERT(NoEventDispatchAssertion::isEventAllowedInMainThread()); 5098 for (auto& processingInstruction : styleScope().collectXSLTransforms()) { 5099 ASSERT(processingInstruction->isXSL()); 5100 5101 // Don't apply XSL transforms to already transformed documents -- <rdar://problem/4132806> 5102 if (transformSourceDocument() || !processingInstruction->sheet()) 5103 return; 5104 5105 auto processor = XSLTProcessor::create(); 5106 processor->setXSLStyleSheet(downcast<XSLStyleSheet>(processingInstruction->sheet())); 5107 String resultMIMEType; 5108 String newSource; 5109 String resultEncoding; 5110 if (!processor->transformToString(*this, resultMIMEType, newSource, resultEncoding)) 5111 continue; 5112 // FIXME: If the transform failed we should probably report an error (like Mozilla does). 5113 processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, this, frame()); 5114 } 5074 void Document::applyXSLTransform(ProcessingInstruction* pi) 5075 { 5076 RefPtr<XSLTProcessor> processor = XSLTProcessor::create(); 5077 processor->setXSLStyleSheet(downcast<XSLStyleSheet>(pi->sheet())); 5078 String resultMIMEType; 5079 String newSource; 5080 String resultEncoding; 5081 if (!processor->transformToString(*this, resultMIMEType, newSource, resultEncoding)) 5082 return; 5083 // FIXME: If the transform failed we should probably report an error (like Mozilla does). 5084 Frame* ownerFrame = frame(); 5085 processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, this, ownerFrame); 5115 5086 } 5116 5087 … … 5294 5265 setParsing(false); 5295 5266 5296 Ref<Document> protectedThis(*this);5297 5298 5267 if (!m_documentTiming.domContentLoadedEventStart) 5299 5268 m_documentTiming.domContentLoadedEventStart = MonotonicTime::now(); … … 5305 5274 5306 5275 if (RefPtr<Frame> frame = this->frame()) { 5307 applyPendingXSLTransformsNowIfScheduled();5308 5309 5276 // FrameLoader::finishedParsing() might end up calling Document::implicitClose() if all 5310 5277 // resource loads are complete. HTMLObjectElements can start loading their resources from -
trunk/Source/WebCore/dom/Document.h
r224113 r224116 953 953 954 954 #if ENABLE(XSLT) 955 void scheduleToApplyXSLTransforms(); 956 void applyPendingXSLTransformsNowIfScheduled(); 955 void applyXSLTransform(ProcessingInstruction* pi); 957 956 RefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; } 958 957 void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; } … … 1569 1568 1570 1569 #if ENABLE(XSLT) 1571 void applyPendingXSLTransformsTimerFired();1572 1573 1570 std::unique_ptr<TransformSource> m_transformSource; 1574 1571 RefPtr<Document> m_transformSourceDocument; 1575 Timer m_applyPendingXSLTransformsTimer;1576 1572 #endif 1577 1573 -
trunk/Source/WebCore/dom/ProcessingInstruction.cpp
r223999 r224116 127 127 m_sheet = XSLStyleSheet::createEmbedded(this, finalURL); 128 128 m_loading = false; 129 document().scheduleToApplyXSLTransforms();130 129 } 131 130 #endif … … 181 180 #if ENABLE(XSLT) 182 181 if (m_isXSL) 183 document().s cheduleToApplyXSLTransforms();182 document().styleScope().flushPendingUpdate(); 184 183 #endif 185 184 } … … 204 203 #if ENABLE(XSLT) 205 204 if (m_isXSL) 206 document().s cheduleToApplyXSLTransforms();205 document().styleScope().flushPendingUpdate(); 207 206 #endif 208 207 return true; -
trunk/Source/WebCore/style/StyleScope.cpp
r223999 r224116 291 291 } 292 292 293 void Scope::collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>& sheets) 294 { 295 if (!m_document.settings().authorAndUserStylesEnabled()) 296 return; 297 298 for (auto& node : m_styleSheetCandidateNodes) { 299 StyleSheet* sheet = nullptr; 300 if (is<ProcessingInstruction>(*node)) { 301 // Processing instruction (XML documents only). 302 // We don't support linking to embedded CSS stylesheets, see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion. 303 ProcessingInstruction& pi = downcast<ProcessingInstruction>(*node); 304 sheet = pi.sheet(); 293 305 #if ENABLE(XSLT) 294 // FIXME: <https://webkit.org/b/178830> Remove XSLT relaed code from Style::Scope. 295 Vector<Ref<ProcessingInstruction>> Scope::collectXSLTransforms() 296 { 297 Vector<Ref<ProcessingInstruction>> processingInstructions; 298 for (auto& node : m_styleSheetCandidateNodes) { 299 if (is<ProcessingInstruction>(*node) && downcast<ProcessingInstruction>(*node).isXSL()) 300 processingInstructions.append(downcast<ProcessingInstruction>(*node)); 301 } 302 return processingInstructions; 303 } 306 // Don't apply XSL transforms to already transformed documents -- <rdar://problem/4132806> 307 if (pi.isXSL() && !m_document.transformSourceDocument()) { 308 // Don't apply XSL transforms until loading is finished. 309 if (!m_document.parsing()) 310 m_document.applyXSLTransform(&pi); 311 return; 312 } 304 313 #endif 305 306 void Scope::collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>& sheets)307 {308 if (!m_document.settings().authorAndUserStylesEnabled())309 return;310 311 for (auto& node : m_styleSheetCandidateNodes) {312 RefPtr<StyleSheet> sheet;313 if (is<ProcessingInstruction>(*node)) {314 if (!downcast<ProcessingInstruction>(*node).isCSS())315 continue;316 // We don't support linking to embedded CSS stylesheets, see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion.317 sheet = downcast<ProcessingInstruction>(*node).sheet();318 314 } else if (is<HTMLLinkElement>(*node) || is<HTMLStyleElement>(*node) || is<SVGStyleElement>(*node)) { 319 315 Element& element = downcast<Element>(*node); … … 369 365 } 370 366 if (sheet) 371 sheets.append( WTFMove(sheet));367 sheets.append(sheet); 372 368 } 373 369 } -
trunk/Source/WebCore/style/StyleScope.h
r223999 r224116 109 109 void flushPendingUpdate(); 110 110 111 #if ENABLE(XSLT)112 Vector<Ref<ProcessingInstruction>> collectXSLTransforms();113 #endif114 115 111 StyleResolver& resolver(); 116 112 StyleResolver* resolverIfExists(); -
trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
r223999 r224116 1334 1334 1335 1335 document()->setParsing(false); // Make the document think it's done, so it will apply XSL stylesheets. 1336 document()-> applyPendingXSLTransformsNowIfScheduled();1336 document()->styleScope().didChangeActiveStyleSheetCandidates(); 1337 1337 1338 1338 // styleResolverChanged() call can detach the parser and null out its document.
Note: See TracChangeset
for help on using the changeset viewer.