Skip to content

Commit

Permalink
Do not update attributes in HTMLBodyElement::insertedInto.
Browse files Browse the repository at this point in the history
Use didNotifySubtreeInsertionsToDocument instead.

BUG=356095
TEST=automated
[email protected]

Review URL: https://codereview.chromium.org/212793007

git-svn-id: svn://svn.chromium.org/blink/trunk@170216 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
[email protected] committed Mar 27, 2014
1 parent 11b4697 commit b72d4e3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PASS if not crashed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script>
if (window.testRunner)
testRunner.dumpAsText();

var iframe = null;

function start() {
iframe = document.createElement('iframe');
iframe.setAttribute('marginwidth', 1);
document.body.appendChild(iframe);

var bodyInFrame = document.createElement('body');
bodyInFrame.addEventListener('DOMSubtreeModified', removeIframe);
iframe.contentDocument.documentElement.appendChild(bodyInFrame);
document.body.innerHTML = 'PASS if not crashed.';
}

function removeIframe() {
iframe.parentNode.removeChild(iframe);
iframe = null;
gc();
}
</script>
<body onload="start()">
</body>
34 changes: 18 additions & 16 deletions Source/core/html/HTMLBodyElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,24 @@ void HTMLBodyElement::parseAttribute(const QualifiedName& name, const AtomicStri
Node::InsertionNotificationRequest HTMLBodyElement::insertedInto(ContainerNode* insertionPoint)
{
HTMLElement::insertedInto(insertionPoint);
if (insertionPoint->inDocument()) {
// FIXME: It's surprising this is web compatible since it means a marginwidth
// and marginheight attribute can magically appear on the <body> of all documents
// embedded through <iframe> or <frame>.
Element* ownerElement = document().ownerElement();
if (isHTMLFrameElementBase(ownerElement)) {
HTMLFrameElementBase& ownerFrameElement = toHTMLFrameElementBase(*ownerElement);
int marginWidth = ownerFrameElement.marginWidth();
if (marginWidth != -1)
setIntegralAttribute(marginwidthAttr, marginWidth);
int marginHeight = ownerFrameElement.marginHeight();
if (marginHeight != -1)
setIntegralAttribute(marginheightAttr, marginHeight);
}
}
return InsertionDone;
return InsertionShouldCallDidNotifySubtreeInsertions;
}

void HTMLBodyElement::didNotifySubtreeInsertionsToDocument()
{
// FIXME: It's surprising this is web compatible since it means a
// marginwidth and marginheight attribute can magically appear on the <body>
// of all documents embedded through <iframe> or <frame>.
Element* ownerElement = document().ownerElement();
if (!isHTMLFrameElementBase(ownerElement))
return;
HTMLFrameElementBase& ownerFrameElement = toHTMLFrameElementBase(*ownerElement);
int marginWidth = ownerFrameElement.marginWidth();
int marginHeight = ownerFrameElement.marginHeight();
if (marginWidth != -1)
setIntegralAttribute(marginwidthAttr, marginWidth);
if (marginHeight != -1)
setIntegralAttribute(marginheightAttr, marginHeight);
}

bool HTMLBodyElement::isURLAttribute(const Attribute& attribute) const
Expand Down
1 change: 1 addition & 0 deletions Source/core/html/HTMLBodyElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class HTMLBodyElement FINAL : public HTMLElement {
virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;

virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
virtual void didNotifySubtreeInsertionsToDocument() OVERRIDE;

virtual bool isURLAttribute(const Attribute&) const OVERRIDE;
virtual bool hasLegalLinkAttribute(const QualifiedName&) const OVERRIDE;
Expand Down

0 comments on commit b72d4e3

Please sign in to comment.