Unreviewed, rolling out r239347.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2018 19:11:06 +0000 (19:11 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2018 19:11:06 +0000 (19:11 +0000)
Caused the leaks bot to hit an exception and the new test
crashes on certain configurations.

Reverted changeset:

"Synchronous media query evaluation could destroy current
Frame/FrameView."
https://bugs.webkit.org/show_bug.cgi?id=192781
https://trac.webkit.org/changeset/239347

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239381 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/printing/print-with-media-query-destory-expected.txt [deleted file]
LayoutTests/printing/print-with-media-query-destory.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/FrameView.cpp

index 821c757..d248c17 100644 (file)
@@ -1,3 +1,17 @@
+2018-12-19  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r239347.
+
+        Caused the leaks bot to hit an exception and the new test
+        crashes on certain configurations.
+
+        Reverted changeset:
+
+        "Synchronous media query evaluation could destroy current
+        Frame/FrameView."
+        https://bugs.webkit.org/show_bug.cgi?id=192781
+        https://trac.webkit.org/changeset/239347
+
 2018-12-18  Justin Michaud  <justin_michaud@apple.com>
 
         Update CSS Properties and Values API to use new cycle fallback behaviour
diff --git a/LayoutTests/printing/print-with-media-query-destory-expected.txt b/LayoutTests/printing/print-with-media-query-destory-expected.txt
deleted file mode 100644 (file)
index 6e69738..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Pass if no crash or assert
-
diff --git a/LayoutTests/printing/print-with-media-query-destory.html b/LayoutTests/printing/print-with-media-query-destory.html
deleted file mode 100644 (file)
index ebeb7ff..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<div>Pass if no crash or assert</div>\r
-<script>\r
-if (window.testRunner)\r
-    testRunner.dumpAsText();\r
-    \r
-function wait() {\r
-if (window.testRunner)\r
-    testRunner.waitUntilDone();\r
-}\r
-\r
-function done() {\r
-if (window.testRunner)\r
-    testRunner.notifyDone();\r
-}\r
-</script>\r
-<iframe srcdoc="<script>\r
-window.matchMedia('print').addListener(function(mql) {\r
-    let parentWindow = window.parent;\r
-    window.frameElement.remove();\r
-    parentWindow.done();\r
-});\r
-\r
-if (window.internals) {\r
-    internals.setPrinting(800, 600);\r
-    window.parent.wait();\r
-} else\r
-    print();\r
-</script>">\r
index e96c6ac..8ca9cf9 100644 (file)
@@ -1,3 +1,17 @@
+2018-12-19  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r239347.
+
+        Caused the leaks bot to hit an exception and the new test
+        crashes on certain configurations.
+
+        Reverted changeset:
+
+        "Synchronous media query evaluation could destroy current
+        Frame/FrameView."
+        https://bugs.webkit.org/show_bug.cgi?id=192781
+        https://trac.webkit.org/changeset/239347
+
 2018-12-19  Truitt Savell  <tsavell@apple.com>
 
         Unreviewed, rolling out r239358.
index edec9d4..2f508eb 100644 (file)
@@ -435,8 +435,6 @@ void DocumentLoader::finishedLoading()
     if (!m_mainDocumentError.isNull())
         return;
     clearMainResourceLoader();
-    if (!frameLoader())
-        return;
     if (!frameLoader()->stateMachine().creatingInitialEmptyDocument())
         frameLoader()->checkLoadComplete();
 
index 25d3e55..8d2c3ef 100644 (file)
@@ -661,23 +661,22 @@ bool Frame::selectionChangeCallbacksDisabled() const
 
 void Frame::setPrinting(bool printing, const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize)
 {
-    if (!view())
-        return;
     // In setting printing, we should not validate resources already cached for the document.
     // See https://bugs.webkit.org/show_bug.cgi?id=43704
     ResourceCacheValidationSuppressor validationSuppressor(m_doc->cachedResourceLoader());
 
     m_doc->setPrinting(printing);
-    auto& frameView = *view();
-    frameView.adjustMediaTypeForPrinting(printing);
-
-    m_doc->styleScope().didChangeStyleSheetEnvironment();
-    if (shouldUsePrintingLayout())
-        frameView.forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize);
-    else {
-        frameView.forceLayout();
-        if (shouldAdjustViewSize == AdjustViewSize)
-            frameView.adjustViewSize();
+    if (auto* frameView = view()) {
+        frameView->adjustMediaTypeForPrinting(printing);
+
+        m_doc->styleScope().didChangeStyleSheetEnvironment();
+        if (shouldUsePrintingLayout())
+            frameView->forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize);
+        else {
+            frameView->forceLayout();
+            if (shouldAdjustViewSize == AdjustViewSize)
+                frameView->adjustViewSize();
+        }
     }
 
     // Subframes of the one we're printing don't lay out to the page size.
index b626f69..edd1ceb 100644 (file)
@@ -4586,56 +4586,48 @@ void FrameView::forceLayout(bool allowSubtreeLayout)
 
 void FrameView::forceLayoutForPagination(const FloatSize& pageSize, const FloatSize& originalPageSize, float maximumShrinkFactor, AdjustViewSizeOrNot shouldAdjustViewSize)
 {
-    if (!renderView())
-        return;
-
-    Ref<FrameView> protectedThis(*this);
-    auto& renderView = *this->renderView();
-
     // Dumping externalRepresentation(frame().renderer()).ascii() is a good trick to see
     // the state of things before and after the layout
-    float pageLogicalWidth = renderView.style().isHorizontalWritingMode() ? pageSize.width() : pageSize.height();
-    float pageLogicalHeight = renderView.style().isHorizontalWritingMode() ? pageSize.height() : pageSize.width();
-
-    renderView.setPageLogicalSize({ floor(pageLogicalWidth), floor(pageLogicalHeight) });
-    renderView.setNeedsLayoutAndPrefWidthsRecalc();
-    forceLayout();
-    if (hasOneRef())
-        return;
-
-    // If we don't fit in the given page width, we'll lay out again. If we don't fit in the
-    // page width when shrunk, we will lay out at maximum shrink and clip extra content.
-    // FIXME: We are assuming a shrink-to-fit printing implementation. A cropping
-    // implementation should not do this!
-    bool horizontalWritingMode = renderView.style().isHorizontalWritingMode();
-    const LayoutRect& documentRect = renderView.documentRect();
-    LayoutUnit docLogicalWidth = horizontalWritingMode ? documentRect.width() : documentRect.height();
-    if (docLogicalWidth > pageLogicalWidth) {
-        int expectedPageWidth = std::min<float>(documentRect.width(), pageSize.width() * maximumShrinkFactor);
-        int expectedPageHeight = std::min<float>(documentRect.height(), pageSize.height() * maximumShrinkFactor);
-        FloatSize maxPageSize = frame().resizePageRectsKeepingRatio(FloatSize(originalPageSize.width(), originalPageSize.height()), FloatSize(expectedPageWidth, expectedPageHeight));
-        pageLogicalWidth = horizontalWritingMode ? maxPageSize.width() : maxPageSize.height();
-        pageLogicalHeight = horizontalWritingMode ? maxPageSize.height() : maxPageSize.width();
-
-        renderView.setPageLogicalSize({ floor(pageLogicalWidth), floor(pageLogicalHeight) });
-        renderView.setNeedsLayoutAndPrefWidthsRecalc();
+    if (RenderView* renderView = this->renderView()) {
+        float pageLogicalWidth = renderView->style().isHorizontalWritingMode() ? pageSize.width() : pageSize.height();
+        float pageLogicalHeight = renderView->style().isHorizontalWritingMode() ? pageSize.height() : pageSize.width();
+
+        renderView->setPageLogicalSize({ floor(pageLogicalWidth), floor(pageLogicalHeight) });
+        renderView->setNeedsLayoutAndPrefWidthsRecalc();
         forceLayout();
-        if (hasOneRef())
-            return;
 
-        const LayoutRect& updatedDocumentRect = renderView.documentRect();
-        LayoutUnit docLogicalHeight = horizontalWritingMode ? updatedDocumentRect.height() : updatedDocumentRect.width();
-        LayoutUnit docLogicalTop = horizontalWritingMode ? updatedDocumentRect.y() : updatedDocumentRect.x();
-        LayoutUnit docLogicalRight = horizontalWritingMode ? updatedDocumentRect.maxX() : updatedDocumentRect.maxY();
-        LayoutUnit clippedLogicalLeft;
-        if (!renderView.style().isLeftToRightDirection())
-            clippedLogicalLeft = docLogicalRight - pageLogicalWidth;
-        LayoutRect overflow(clippedLogicalLeft, docLogicalTop, pageLogicalWidth, docLogicalHeight);
-
-        if (!horizontalWritingMode)
-            overflow = overflow.transposedRect();
-        renderView.clearLayoutOverflow();
-        renderView.addLayoutOverflow(overflow); // This is how we clip in case we overflow again.
+        // If we don't fit in the given page width, we'll lay out again. If we don't fit in the
+        // page width when shrunk, we will lay out at maximum shrink and clip extra content.
+        // FIXME: We are assuming a shrink-to-fit printing implementation.  A cropping
+        // implementation should not do this!
+        bool horizontalWritingMode = renderView->style().isHorizontalWritingMode();
+        const LayoutRect& documentRect = renderView->documentRect();
+        LayoutUnit docLogicalWidth = horizontalWritingMode ? documentRect.width() : documentRect.height();
+        if (docLogicalWidth > pageLogicalWidth) {
+            int expectedPageWidth = std::min<float>(documentRect.width(), pageSize.width() * maximumShrinkFactor);
+            int expectedPageHeight = std::min<float>(documentRect.height(), pageSize.height() * maximumShrinkFactor);
+            FloatSize maxPageSize = frame().resizePageRectsKeepingRatio(FloatSize(originalPageSize.width(), originalPageSize.height()), FloatSize(expectedPageWidth, expectedPageHeight));
+            pageLogicalWidth = horizontalWritingMode ? maxPageSize.width() : maxPageSize.height();
+            pageLogicalHeight = horizontalWritingMode ? maxPageSize.height() : maxPageSize.width();
+
+            renderView->setPageLogicalSize({ floor(pageLogicalWidth), floor(pageLogicalHeight) });
+            renderView->setNeedsLayoutAndPrefWidthsRecalc();
+            forceLayout();
+
+            const LayoutRect& updatedDocumentRect = renderView->documentRect();
+            LayoutUnit docLogicalHeight = horizontalWritingMode ? updatedDocumentRect.height() : updatedDocumentRect.width();
+            LayoutUnit docLogicalTop = horizontalWritingMode ? updatedDocumentRect.y() : updatedDocumentRect.x();
+            LayoutUnit docLogicalRight = horizontalWritingMode ? updatedDocumentRect.maxX() : updatedDocumentRect.maxY();
+            LayoutUnit clippedLogicalLeft;
+            if (!renderView->style().isLeftToRightDirection())
+                clippedLogicalLeft = docLogicalRight - pageLogicalWidth;
+            LayoutRect overflow(clippedLogicalLeft, docLogicalTop, pageLogicalWidth, docLogicalHeight);
+
+            if (!horizontalWritingMode)
+                overflow = overflow.transposedRect();
+            renderView->clearLayoutOverflow();
+            renderView->addLayoutOverflow(overflow); // This is how we clip in case we overflow again.
+        }
     }
 
     if (shouldAdjustViewSize)