<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>107223</bug_id>
          
          <creation_ts>2013-01-17 21:50:56 -0800</creation_ts>
          <short_desc>ASSERTION FAILED: parent-&gt;inDocument() loading playboy.com</short_desc>
          <delta_ts>2013-01-18 16:59:42 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>106224</dup_id>
          
          <bug_file_loc>http://www.playboy.com</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>eric</cc>
    
    <cc>esprehn</cc>
    
    <cc>koivisto</cc>
    
    <cc>morrita</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>tomi.kyostila</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>810218</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2013-01-17 21:50:56 -0800</bug_when>
    <thetext>Loading http://www.playboy.com (which is in the Alexa 1000) hits:

ASSERTION FAILED: parent-&gt;inDocument()
/Volumes/DataSSD/Development/apple/webkit/WebKit.git/Source/WebCore/dom/PseudoElement.cpp(47) : WebCore::PseudoElement::PseudoElement(WebCore::Element *, WebCore::PseudoId)
1   0x1046ce23b WebCore::PseudoElement::PseudoElement(WebCore::Element*, WebCore::PseudoId)
2   0x1046ce143 WebCore::PseudoElement::PseudoElement(WebCore::Element*, WebCore::PseudoId)
3   0x103a5f1d1 WebCore::PseudoElement::create(WebCore::Element*, WebCore::PseudoId)
4   0x103a5a7ac WebCore::Element::createPseudoElementIfNeeded(WebCore::PseudoId)
5   0x103a56493 WebCore::Element::updatePseudoElement(WebCore::PseudoId, WebCore::Node::StyleChange)
6   0x103a56221 WebCore::Element::attach()
7   0x1036206e3 WebCore::ContainerNode::attachChildren()
8   0x10361dd49 WebCore::ContainerNode::attach()
9   0x103a5620e WebCore::Element::attach()
10  0x103a5e746 WebCore::Node::reattach()
11  0x103a56e2d WebCore::Element::recalcStyle(WebCore::Node::StyleChange)
12  0x103a572bd WebCore::Element::recalcStyle(WebCore::Node::StyleChange)
13  0x10383bf3e WebCore::Document::recalcStyle(WebCore::Node::StyleChange)
14  0x1038392ad WebCore::Document::styleResolverChanged(WebCore::StyleResolverUpdateFlag)
15  0x10383fca5 WebCore::Document::didRemoveAllPendingStylesheet()
16  0x1038c3210 WebCore::DocumentStyleSheetCollection::removePendingSheet(WebCore::DocumentStyleSheetCollection::RemovePendingSheetNotificationType)
17  0x104bb767b WebCore::StyleElement::sheetLoaded(WebCore::Document*)
18  0x103d45b7e WebCore::HTMLStyleElement::sheetLoaded()
19  0x104c2d3e7 WebCore::StyleSheetContents::checkLoaded()
20  0x104bb74ba WebCore::StyleElement::createSheet(WebCore::Element*, WTF::OrdinalNumber, WTF::String const&amp;)
21  0x104bb6b00 WebCore::StyleElement::process(WebCore::Element*)
22  0x104bb6872 WebCore::StyleElement::insertedIntoDocument(WebCore::Document*, WebCore::Element*)
23  0x103d45030 WebCore::HTMLStyleElement::insertedInto(WebCore::ContainerNode*)
24  0x103623f32 WebCore::ChildNodeInsertionNotifier::notifyNodeInsertedIntoDocument(WebCore::Node*)
25  0x1036244b3 WebCore::ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument(WebCore::ContainerNode*)
26  0x103623f80 WebCore::ChildNodeInsertionNotifier::notifyNodeInsertedIntoDocument(WebCore::Node*)
27  0x10361fe0a WebCore::ChildNodeInsertionNotifier::notify(WebCore::Node*)
28  0x10361c0a5 WebCore::updateTreeAfterInsertion(WebCore::ContainerNode*, WebCore::Node*, bool)
29  0x10361b8d2 WebCore::ContainerNode::appendChild(WTF::PassRefPtr&lt;WebCore::Node&gt;, int&amp;, bool)
30  0x1045fdf8a WebCore::Node::appendChild(WTF::PassRefPtr&lt;WebCore::Node&gt;, int&amp;, bool)
31  0x104237e21 WebCore::JSNode::appendChild(JSC::ExecState*)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>810223</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2013-01-17 21:54:34 -0800</bug_when>
    <thetext>WebKit r140093</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>810261</commentid>
    <comment_count>2</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2013-01-17 22:38:02 -0800</bug_when>
    <thetext>ccing esprehn
Looks like same as https://code.google.com/p/chromium/issues/detail?id=170225
(not visible outside chromium...), which says http://stuffandnonsense.co.uk/blog/about/home-screen-icons-and-startup-screens crashes and show similar stack trace.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>810419</commentid>
    <comment_count>3</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-01-18 02:56:49 -0800</bug_when>
    <thetext>I believe I&apos;ve figured this out:

When you appendChild a node with a &lt;style&gt; in it we recursively notify all the children with Node::insertedInto which hits the HTMLStyleElement::insertedInto which then calls StyleElement::insertedIntoDocument if the insertionPoint is inDocument. This kicks off a bunch of style machinery and we end up in Document::styleResolverChanged where we do a recalcStyle(Forced) on the Document which may cause a reattach() which would then recursively walk the tree creating renderers.

At this point we&apos;re still inside the HTMLStyleElement::insertedInto so none of the siblings of that style element know they&apos;re inDocument yet, even though they&apos;re going through recalcStyle, being attached, and creating renderers.

Something like:

var div = document.createElement(&apos;div&apos;);
var style = document.createElement(&apos;style&apos;);
style.textContent = &apos;body { display: inline; } span:before { content: &quot;x&quot;; }&apos;;
div.appendChild(style);
div.appendChild(document.createElement(&apos;span&apos;));
document.body.appendChild(div);

Here we end up reattach()&apos;ing &lt;body&gt; because now it&apos;s inline, which then attach()&apos;s the &lt;span&gt;, which creates a PseudoElement, but the &lt;span&gt; still hasn&apos;t been notified it&apos;s inDocument since this all was triggered inside HTMLStyleElement::insertedInto.

This feels really wrong, but it&apos;s always been this way so the fix is to just remove that assertion and then make Element::insertedInto call insertedInto on the PseudoElements.

Eventually we should fix this though since it appears if you appendChild a &lt;div&gt; that contains three &lt;style&gt; elements, each of which changes the display of the &lt;body&gt;, we&apos;ll destroy and recreate the entire document three times even though we really only needed to do it once!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>810423</commentid>
    <comment_count>4</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-01-18 02:59:48 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; I believe I&apos;ve figured this out:
&gt; ...

@eseidel I think the above should be of particular interest to you as it seems bad for perf to create/destroy the render tree repeatedly when inserting style elements. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>810425</commentid>
    <comment_count>5</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-01-18 03:00:20 -0800</bug_when>
    <thetext>*** Bug 106224 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>810626</commentid>
    <comment_count>6</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-01-18 08:23:10 -0800</bug_when>
    <thetext>Why forward dupe? It is generally advisable to dupe to oldest bugs, unless there are specific reasons to do otherwise.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>811168</commentid>
    <comment_count>7</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-01-18 16:55:39 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; Why forward dupe? It is generally advisable to dupe to oldest bugs, unless there are specific reasons to do otherwise.

Because I had already posted the whole explanation of what&apos;s going on here. I can paste it into the other bug if you want and reverse the dupes?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>811174</commentid>
    <comment_count>8</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-01-18 16:59:42 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 106224 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>