Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 * | 20 * |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 #include "core/html/HTMLMarqueeElement.h" | 24 #include "core/html/HTMLMarqueeElement.h" |
| 25 | 25 |
| 26 #include "bindings/core/v8/ExceptionState.h" | 26 #include "bindings/core/v8/ExceptionState.h" |
| 27 #include "bindings/core/v8/PrivateScriptRunner.h" | |
| 28 #include "bindings/core/v8/V8HTMLMarqueeElement.h" | |
| 27 #include "core/CSSPropertyNames.h" | 29 #include "core/CSSPropertyNames.h" |
| 28 #include "core/CSSValueKeywords.h" | 30 #include "core/CSSValueKeywords.h" |
| 29 #include "core/HTMLNames.h" | 31 #include "core/HTMLNames.h" |
| 32 #include "core/dom/ActiveDOMObject.h" | |
| 33 #include "core/dom/Document.h" | |
| 30 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
| 31 #include "core/rendering/RenderMarquee.h" | |
| 32 | 35 |
| 33 namespace blink { | 36 namespace blink { |
| 34 | 37 |
| 35 using namespace HTMLNames; | 38 using namespace HTMLNames; |
| 36 | 39 |
| 37 inline HTMLMarqueeElement::HTMLMarqueeElement(Document& document) | 40 inline HTMLMarqueeElement::HTMLMarqueeElement(Document& document) |
| 38 : HTMLElement(marqueeTag, document) | 41 : HTMLElement(marqueeTag, document) |
| 39 , ActiveDOMObject(&document) | 42 , ActiveDOMObject(&document) |
| 40 { | 43 { |
| 41 ScriptWrappable::init(this); | 44 ScriptWrappable::init(this); |
| 45 v8::Handle<v8::Value> classObject = PrivateScriptRunner::installClassIfNeede d(document.frame(), "HTMLMarqueeElement"); | |
| 46 RELEASE_ASSERT(!classObject.IsEmpty()); | |
| 42 } | 47 } |
| 43 | 48 |
| 44 PassRefPtrWillBeRawPtr<HTMLMarqueeElement> HTMLMarqueeElement::create(Document& document) | 49 PassRefPtrWillBeRawPtr<HTMLMarqueeElement> HTMLMarqueeElement::create(Document& document) |
| 45 { | 50 { |
| 46 RefPtrWillBeRawPtr<HTMLMarqueeElement> marqueeElement(adoptRefWillBeNoop(new HTMLMarqueeElement(document))); | 51 RefPtrWillBeRawPtr<HTMLMarqueeElement> marqueeElement(adoptRefWillBeNoop(new HTMLMarqueeElement(document))); |
| 47 marqueeElement->suspendIfNeeded(); | 52 marqueeElement->suspendIfNeeded(); |
| 53 ScriptForbiddenScope::AllowUserAgentScript script; | |
| 54 V8HTMLMarqueeElement::createdCallbackMethodImplementedInPrivateScript(docume nt.frame(), marqueeElement.get()); | |
| 48 return marqueeElement.release(); | 55 return marqueeElement.release(); |
| 49 } | 56 } |
| 50 | 57 |
| 51 int HTMLMarqueeElement::minimumDelay() const | 58 void HTMLMarqueeElement::attributeWillChange(const QualifiedName& name, const At omicString& oldValue, const AtomicString& newValue) |
| 52 { | 59 { |
| 53 if (fastGetAttribute(truespeedAttr).isEmpty()) { | 60 HTMLElement::attributeWillChange(name, oldValue, newValue); |
| 54 // WinIE uses 60ms as the minimum delay by default. | 61 ScriptForbiddenScope::AllowUserAgentScript script; |
| 55 return 60; | 62 V8HTMLMarqueeElement::attributeChangedCallbackMethodImplementedInPrivateScri pt(document().frame(), this); |
| 56 } | |
| 57 return 0; | |
| 58 } | 63 } |
| 59 | 64 |
| 60 void HTMLMarqueeElement::didMoveToNewDocument(Document& oldDocument) | 65 Node::InsertionNotificationRequest HTMLMarqueeElement::insertedInto(ContainerNod e* insertionPoint) |
| 61 { | 66 { |
| 62 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 67 HTMLElement::insertedInto(insertionPoint); |
| 63 HTMLElement::didMoveToNewDocument(oldDocument); | 68 if (inDocument()) { |
| 69 ScriptForbiddenScope::AllowUserAgentScript script; | |
| 70 V8HTMLMarqueeElement::attachedCallbackMethodImplementedInPrivateScript(d ocument().frame(), this); | |
| 71 } | |
| 72 return InsertionDone; | |
| 64 } | 73 } |
| 65 | 74 |
| 66 bool HTMLMarqueeElement::isPresentationAttribute(const QualifiedName& name) cons t | 75 void HTMLMarqueeElement::removedFrom(ContainerNode* insertionPoint) |
| 67 { | 76 { |
| 68 if (name == widthAttr || name == heightAttr || name == bgcolorAttr || name = = vspaceAttr || name == hspaceAttr || name == scrollamountAttr || name == scroll delayAttr || name == loopAttr || name == behaviorAttr || name == directionAttr) | 77 HTMLElement::removedFrom(insertionPoint); |
| 69 return true; | 78 if (insertionPoint->inDocument()) { |
| 70 return HTMLElement::isPresentationAttribute(name); | 79 ScriptForbiddenScope::AllowUserAgentScript script; |
|
arv (Not doing code reviews)
2014/07/24 16:59:37
Could/should this be baked into the generated code
| |
| 71 } | 80 V8HTMLMarqueeElement::detachedCallbackMethodImplementedInPrivateScript(i nsertionPoint->document().frame(), this); |
| 72 | 81 } |
| 73 void HTMLMarqueeElement::collectStyleForPresentationAttribute(const QualifiedNam e& name, const AtomicString& value, MutableStylePropertySet* style) | |
| 74 { | |
| 75 if (name == widthAttr) { | |
| 76 if (!value.isEmpty()) | |
| 77 addHTMLLengthToStyle(style, CSSPropertyWidth, value); | |
| 78 } else if (name == heightAttr) { | |
| 79 if (!value.isEmpty()) | |
| 80 addHTMLLengthToStyle(style, CSSPropertyHeight, value); | |
| 81 } else if (name == bgcolorAttr) { | |
| 82 if (!value.isEmpty()) | |
| 83 addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value); | |
| 84 } else if (name == vspaceAttr) { | |
| 85 if (!value.isEmpty()) { | |
| 86 addHTMLLengthToStyle(style, CSSPropertyMarginTop, value); | |
| 87 addHTMLLengthToStyle(style, CSSPropertyMarginBottom, value); | |
| 88 } | |
| 89 } else if (name == hspaceAttr) { | |
| 90 if (!value.isEmpty()) { | |
| 91 addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value); | |
| 92 addHTMLLengthToStyle(style, CSSPropertyMarginRight, value); | |
| 93 } | |
| 94 } else if (name == scrollamountAttr) { | |
| 95 if (!value.isEmpty()) | |
| 96 addHTMLLengthToStyle(style, CSSPropertyInternalMarqueeIncrement, val ue); | |
| 97 } else if (name == scrolldelayAttr) { | |
| 98 if (!value.isEmpty()) | |
| 99 addHTMLLengthToStyle(style, CSSPropertyInternalMarqueeSpeed, value); | |
| 100 } else if (name == loopAttr) { | |
| 101 if (!value.isEmpty()) { | |
| 102 if (value == "-1" || equalIgnoringCase(value, "infinite")) | |
| 103 addPropertyToPresentationAttributeStyle(style, CSSPropertyIntern alMarqueeRepetition, CSSValueInfinite); | |
| 104 else | |
| 105 addHTMLLengthToStyle(style, CSSPropertyInternalMarqueeRepetition , value); | |
| 106 } | |
| 107 } else if (name == behaviorAttr) { | |
| 108 if (!value.isEmpty()) | |
| 109 addPropertyToPresentationAttributeStyle(style, CSSPropertyInternalMa rqueeStyle, value); | |
| 110 } else if (name == directionAttr) { | |
| 111 if (!value.isEmpty()) | |
| 112 addPropertyToPresentationAttributeStyle(style, CSSPropertyInternalMa rqueeDirection, value); | |
| 113 } else | |
| 114 HTMLElement::collectStyleForPresentationAttribute(name, value, style); | |
| 115 } | |
| 116 | |
| 117 void HTMLMarqueeElement::start() | |
| 118 { | |
| 119 if (RenderMarquee* marqueeRenderer = renderMarquee()) | |
| 120 marqueeRenderer->start(); | |
| 121 } | |
| 122 | |
| 123 void HTMLMarqueeElement::stop() | |
| 124 { | |
| 125 if (RenderMarquee* marqueeRenderer = renderMarquee()) | |
| 126 marqueeRenderer->stop(); | |
| 127 } | |
| 128 | |
| 129 void HTMLMarqueeElement::suspend() | |
| 130 { | |
| 131 if (RenderMarquee* marqueeRenderer = renderMarquee()) | |
| 132 marqueeRenderer->suspend(); | |
| 133 } | |
| 134 | |
| 135 void HTMLMarqueeElement::resume() | |
| 136 { | |
| 137 if (RenderMarquee* marqueeRenderer = renderMarquee()) | |
| 138 marqueeRenderer->updateMarqueePosition(); | |
| 139 } | |
| 140 | |
| 141 RenderMarquee* HTMLMarqueeElement::renderMarquee() const | |
| 142 { | |
| 143 if (renderer() && renderer()->isMarquee()) | |
| 144 return toRenderMarquee(renderer()); | |
| 145 return 0; | |
| 146 } | |
| 147 | |
| 148 RenderObject* HTMLMarqueeElement::createRenderer(RenderStyle*) | |
| 149 { | |
| 150 return new RenderMarquee(this); | |
| 151 } | |
| 152 | |
| 153 void HTMLMarqueeElement::timerFired(Timer<HTMLMarqueeElement>*) | |
| 154 { | |
| 155 if (!renderer()) | |
| 156 return; | |
| 157 | |
| 158 document().updateLayout(); | |
| 159 | |
| 160 // The updateLayout() could have destroyed renderer(), so this re-check is v ery important. | |
| 161 if (renderer()) | |
| 162 toRenderMarquee(renderer())->timerFired(); | |
| 163 } | 82 } |
| 164 | 83 |
| 165 } // namespace blink | 84 } // namespace blink |
| OLD | NEW |