瀏覽代碼

LibWeb: Omit origin check for content document in FrameBox::paint()

Once we paint, it's way too late for this check to happen anyway.

Additionally, the spec's steps for retrieving the content document
assume that both the browsing context's active document and the
container's node document are non-null, which evidently isn't always the
case here, as seen by crashes on the SerenityOS 2nd and 3rd birthday
pages (I'm not sure about the details though).

Fixes #12565.
Linus Groh 3 年之前
父節點
當前提交
c7f8c20f8b

+ 7 - 0
Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp

@@ -60,4 +60,11 @@ const DOM::Document* BrowsingContextContainer::content_document() const
     return document;
     return document;
 }
 }
 
 
+DOM::Document const* BrowsingContextContainer::content_document_without_origin_check() const
+{
+    if (!m_nested_browsing_context)
+        return nullptr;
+    return m_nested_browsing_context->active_document();
+}
+
 }
 }

+ 1 - 0
Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h

@@ -19,6 +19,7 @@ public:
     const BrowsingContext* nested_browsing_context() const { return m_nested_browsing_context; }
     const BrowsingContext* nested_browsing_context() const { return m_nested_browsing_context; }
 
 
     const DOM::Document* content_document() const;
     const DOM::Document* content_document() const;
+    DOM::Document const* content_document_without_origin_check() const;
 
 
     virtual void inserted() override;
     virtual void inserted() override;
 
 

+ 1 - 1
Userland/Libraries/LibWeb/Layout/FrameBox.cpp

@@ -36,7 +36,7 @@ void FrameBox::paint(PaintContext& context, PaintPhase phase)
     ReplacedBox::paint(context, phase);
     ReplacedBox::paint(context, phase);
 
 
     if (phase == PaintPhase::Foreground) {
     if (phase == PaintPhase::Foreground) {
-        auto* hosted_document = dom_node().content_document();
+        auto* hosted_document = dom_node().content_document_without_origin_check();
         if (!hosted_document)
         if (!hosted_document)
             return;
             return;
         auto* hosted_layout_tree = hosted_document->layout_node();
         auto* hosted_layout_tree = hosted_document->layout_node();