Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: Source/core/html/HTMLMarqueeElement.cpp

Issue 661693002: <marquee> in <template> should not crash Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLMarqueeElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2007, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2007, 2010 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 15 matching lines...) Expand all
26 #include "bindings/core/v8/PrivateScriptRunner.h" 26 #include "bindings/core/v8/PrivateScriptRunner.h"
27 #include "bindings/core/v8/V8HTMLMarqueeElement.h" 27 #include "bindings/core/v8/V8HTMLMarqueeElement.h"
28 #include "core/HTMLNames.h" 28 #include "core/HTMLNames.h"
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/frame/UseCounter.h" 30 #include "core/frame/UseCounter.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 inline HTMLMarqueeElement::HTMLMarqueeElement(Document& document) 34 inline HTMLMarqueeElement::HTMLMarqueeElement(Document& document)
35 : HTMLElement(HTMLNames::marqueeTag, document) 35 : HTMLElement(HTMLNames::marqueeTag, document)
36 , m_didCallCreatedCallback(false)
36 { 37 {
37 v8::Handle<v8::Value> classObject = PrivateScriptRunner::installClassIfNeede d(document.frame(), "HTMLMarqueeElement");
38 RELEASE_ASSERT(!classObject.IsEmpty());
39 UseCounter::count(document, UseCounter::HTMLMarqueeElement); 38 UseCounter::count(document, UseCounter::HTMLMarqueeElement);
40 } 39 }
41 40
42 PassRefPtrWillBeRawPtr<HTMLMarqueeElement> HTMLMarqueeElement::create(Document& document) 41 PassRefPtrWillBeRawPtr<HTMLMarqueeElement> HTMLMarqueeElement::create(Document& document)
43 { 42 {
44 RefPtrWillBeRawPtr<HTMLMarqueeElement> marqueeElement(adoptRefWillBeNoop(new HTMLMarqueeElement(document))); 43 RefPtr<HTMLMarqueeElement> element = adoptRefWillBeNoop(new HTMLMarqueeEleme nt(document));
45 V8HTMLMarqueeElement::PrivateScript::createdCallbackMethod(document.frame(), marqueeElement.get()); 44 element->callCreatedCallbackIfNeeded();
46 return marqueeElement.release(); 45 return element.release();
47 } 46 }
48 47
49 void HTMLMarqueeElement::attributeWillChange(const QualifiedName& name, const At omicString& oldValue, const AtomicString& newValue) 48 void HTMLMarqueeElement::attributeWillChange(const QualifiedName& name, const At omicString& oldValue, const AtomicString& newValue)
50 { 49 {
51 HTMLElement::attributeWillChange(name, oldValue, newValue); 50 HTMLElement::attributeWillChange(name, oldValue, newValue);
52 V8HTMLMarqueeElement::PrivateScript::attributeChangedCallbackMethod(document ().frame(), this, name.toString(), oldValue, newValue); 51 V8HTMLMarqueeElement::PrivateScript::attributeChangedCallbackMethod(document ().frame(), this, name.toString(), oldValue, newValue);
53 } 52 }
54 53
55 Node::InsertionNotificationRequest HTMLMarqueeElement::insertedInto(ContainerNod e* insertionPoint) 54 Node::InsertionNotificationRequest HTMLMarqueeElement::insertedInto(ContainerNod e* insertionPoint)
56 { 55 {
57 HTMLElement::insertedInto(insertionPoint); 56 HTMLElement::insertedInto(insertionPoint);
58 if (inDocument()) { 57 if (inDocument())
59 V8HTMLMarqueeElement::PrivateScript::attachedCallbackMethod(document().f rame(), this); 58 return InsertionShouldCallDidNotifySubtreeInsertions;
60 }
61 return InsertionDone; 59 return InsertionDone;
62 } 60 }
63 61
62 void HTMLMarqueeElement::didNotifySubtreeInsertionsToDocument()
63 {
64 callCreatedCallbackIfNeeded();
65 V8HTMLMarqueeElement::PrivateScript::attachedCallbackMethod(document().frame (), this);
66 }
67
64 void HTMLMarqueeElement::removedFrom(ContainerNode* insertionPoint) 68 void HTMLMarqueeElement::removedFrom(ContainerNode* insertionPoint)
65 { 69 {
66 HTMLElement::removedFrom(insertionPoint); 70 HTMLElement::removedFrom(insertionPoint);
67 if (insertionPoint->inDocument()) { 71 if (insertionPoint->inDocument()) {
72 ASSERT(m_didCallCreatedCallback);
68 V8HTMLMarqueeElement::PrivateScript::detachedCallbackMethod(insertionPoi nt->document().frame(), this); 73 V8HTMLMarqueeElement::PrivateScript::detachedCallbackMethod(insertionPoi nt->document().frame(), this);
69 } 74 }
70 } 75 }
71 76
77 void HTMLMarqueeElement::callCreatedCallbackIfNeeded()
78 {
79 if (m_didCallCreatedCallback)
80 return;
81 // document().frame() can return 0 if this marquee element is placed in
82 // a template element. In this case we need to defer the execution of the
83 // private script to the point where the frame gets available.
84 if (!document().frame())
85 return;
86
87 V8HTMLMarqueeElement::PrivateScript::createdCallbackMethod(document().frame( ), this);
88 m_didCallCreatedCallback = true;
89 }
90
72 } // namespace blink 91 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMarqueeElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698