Changeset 224116 in webkit


Ignore:
Timestamp:
Oct 27, 2017 10:06:17 AM (6 years ago)
Author:
Ryan Haddad
Message:

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

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r224115 r224116  
     12017-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
    1142017-10-27  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WebCore/dom/Document.cpp

    r224113 r224116  
    481481    , m_scriptRunner(std::make_unique<ScriptRunner>(*this))
    482482    , m_moduleLoader(std::make_unique<ScriptModuleLoader>(*this))
    483     , m_applyPendingXSLTransformsTimer(*this, &Document::applyPendingXSLTransformsTimerFired)
    484483    , m_xmlVersion(ASCIILiteral("1.0"))
    485484    , m_constantPropertyMap(std::make_unique<ConstantPropertyMap>(*this))
     
    27472746    RefPtr<Frame> f = frame();
    27482747    if (f) {
    2749         // Apply XSL transforms before load events so that event handlers can access the transformed DOM tree.
    2750         applyPendingXSLTransformsNowIfScheduled();
    2751 
    27522748        if (auto* documentLoader = loader())
    27532749            documentLoader->startIconLoading();
     
    50765072#if ENABLE(XSLT)
    50775073
    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     }
     5074void 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);
    51155086}
    51165087
     
    52945265    setParsing(false);
    52955266
    5296     Ref<Document> protectedThis(*this);
    5297 
    52985267    if (!m_documentTiming.domContentLoadedEventStart)
    52995268        m_documentTiming.domContentLoadedEventStart = MonotonicTime::now();
     
    53055274
    53065275    if (RefPtr<Frame> frame = this->frame()) {
    5307         applyPendingXSLTransformsNowIfScheduled();
    5308 
    53095276        // FrameLoader::finishedParsing() might end up calling Document::implicitClose() if all
    53105277        // resource loads are complete. HTMLObjectElements can start loading their resources from
  • trunk/Source/WebCore/dom/Document.h

    r224113 r224116  
    953953
    954954#if ENABLE(XSLT)
    955     void scheduleToApplyXSLTransforms();
    956     void applyPendingXSLTransformsNowIfScheduled();
     955    void applyXSLTransform(ProcessingInstruction* pi);
    957956    RefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
    958957    void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
     
    15691568
    15701569#if ENABLE(XSLT)
    1571     void applyPendingXSLTransformsTimerFired();
    1572 
    15731570    std::unique_ptr<TransformSource> m_transformSource;
    15741571    RefPtr<Document> m_transformSourceDocument;
    1575     Timer m_applyPendingXSLTransformsTimer;
    15761572#endif
    15771573
  • trunk/Source/WebCore/dom/ProcessingInstruction.cpp

    r223999 r224116  
    127127                m_sheet = XSLStyleSheet::createEmbedded(this, finalURL);
    128128                m_loading = false;
    129                 document().scheduleToApplyXSLTransforms();
    130129            }
    131130#endif
     
    181180#if ENABLE(XSLT)
    182181                if (m_isXSL)
    183                     document().scheduleToApplyXSLTransforms();
     182                    document().styleScope().flushPendingUpdate();
    184183#endif
    185184            }
     
    204203#if ENABLE(XSLT)
    205204        if (m_isXSL)
    206             document().scheduleToApplyXSLTransforms();
     205            document().styleScope().flushPendingUpdate();
    207206#endif
    208207        return true;
  • trunk/Source/WebCore/style/StyleScope.cpp

    r223999 r224116  
    291291}
    292292
     293void 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();
    293305#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            }
    304313#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();
    318314        } else if (is<HTMLLinkElement>(*node) || is<HTMLStyleElement>(*node) || is<SVGStyleElement>(*node)) {
    319315            Element& element = downcast<Element>(*node);
     
    369365        }
    370366        if (sheet)
    371             sheets.append(WTFMove(sheet));
     367            sheets.append(sheet);
    372368    }
    373369}
  • trunk/Source/WebCore/style/StyleScope.h

    r223999 r224116  
    109109    void flushPendingUpdate();
    110110
    111 #if ENABLE(XSLT)
    112     Vector<Ref<ProcessingInstruction>> collectXSLTransforms();
    113 #endif
    114 
    115111    StyleResolver& resolver();
    116112    StyleResolver* resolverIfExists();
  • trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp

    r223999 r224116  
    13341334
    13351335        document()->setParsing(false); // Make the document think it's done, so it will apply XSL stylesheets.
    1336         document()->applyPendingXSLTransformsNowIfScheduled();
     1336        document()->styleScope().didChangeActiveStyleSheetCandidates();
    13371337
    13381338        // styleResolverChanged() call can detach the parser and null out its document.
Note: See TracChangeset for help on using the changeset viewer.