| 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/PrivateScriptRunner.h" |
| 27 #include "core/CSSPropertyNames.h" | 27 #include "bindings/core/v8/V8HTMLMarqueeElement.h" |
| 28 #include "core/CSSValueKeywords.h" | |
| 29 #include "core/HTMLNames.h" | 28 #include "core/HTMLNames.h" |
| 30 #include "core/dom/ExceptionCode.h" | 29 #include "core/dom/Document.h" |
| 31 #include "core/rendering/RenderMarquee.h" | |
| 32 | 30 |
| 33 namespace blink { | 31 namespace blink { |
| 34 | 32 |
| 35 using namespace HTMLNames; | |
| 36 | |
| 37 inline HTMLMarqueeElement::HTMLMarqueeElement(Document& document) | 33 inline HTMLMarqueeElement::HTMLMarqueeElement(Document& document) |
| 38 : HTMLElement(marqueeTag, document) | 34 : HTMLElement(HTMLNames::marqueeTag, document) |
| 39 , ActiveDOMObject(&document) | |
| 40 { | 35 { |
| 36 v8::Handle<v8::Value> classObject = PrivateScriptRunner::installClassIfNeede
d(document.frame(), "HTMLMarqueeElement"); |
| 37 RELEASE_ASSERT(!classObject.IsEmpty()); |
| 41 } | 38 } |
| 42 | 39 |
| 43 PassRefPtrWillBeRawPtr<HTMLMarqueeElement> HTMLMarqueeElement::create(Document&
document) | 40 PassRefPtrWillBeRawPtr<HTMLMarqueeElement> HTMLMarqueeElement::create(Document&
document) |
| 44 { | 41 { |
| 45 RefPtrWillBeRawPtr<HTMLMarqueeElement> marqueeElement(adoptRefWillBeNoop(new
HTMLMarqueeElement(document))); | 42 RefPtrWillBeRawPtr<HTMLMarqueeElement> marqueeElement(adoptRefWillBeNoop(new
HTMLMarqueeElement(document))); |
| 46 marqueeElement->suspendIfNeeded(); | 43 V8HTMLMarqueeElement::PrivateScript::createdCallbackMethod(document.frame(),
marqueeElement.get()); |
| 47 return marqueeElement.release(); | 44 return marqueeElement.release(); |
| 48 } | 45 } |
| 49 | 46 |
| 50 int HTMLMarqueeElement::minimumDelay() const | 47 void HTMLMarqueeElement::attributeWillChange(const QualifiedName& name, const At
omicString& oldValue, const AtomicString& newValue) |
| 51 { | 48 { |
| 52 if (fastGetAttribute(truespeedAttr).isEmpty()) { | 49 HTMLElement::attributeWillChange(name, oldValue, newValue); |
| 53 // WinIE uses 60ms as the minimum delay by default. | 50 V8HTMLMarqueeElement::PrivateScript::attributeChangedCallbackMethod(document
().frame(), this, name.toString(), oldValue, newValue); |
| 54 return 60; | |
| 55 } | |
| 56 return 0; | |
| 57 } | 51 } |
| 58 | 52 |
| 59 void HTMLMarqueeElement::didMoveToNewDocument(Document& oldDocument) | 53 Node::InsertionNotificationRequest HTMLMarqueeElement::insertedInto(ContainerNod
e* insertionPoint) |
| 60 { | 54 { |
| 61 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 55 HTMLElement::insertedInto(insertionPoint); |
| 62 HTMLElement::didMoveToNewDocument(oldDocument); | 56 if (inDocument()) { |
| 57 V8HTMLMarqueeElement::PrivateScript::attachedCallbackMethod(document().f
rame(), this); |
| 58 } |
| 59 return InsertionDone; |
| 63 } | 60 } |
| 64 | 61 |
| 65 bool HTMLMarqueeElement::isPresentationAttribute(const QualifiedName& name) cons
t | 62 void HTMLMarqueeElement::removedFrom(ContainerNode* insertionPoint) |
| 66 { | 63 { |
| 67 if (name == widthAttr || name == heightAttr || name == bgcolorAttr || name =
= vspaceAttr || name == hspaceAttr || name == scrollamountAttr || name == scroll
delayAttr || name == loopAttr || name == behaviorAttr || name == directionAttr) | 64 HTMLElement::removedFrom(insertionPoint); |
| 68 return true; | 65 if (insertionPoint->inDocument()) { |
| 69 return HTMLElement::isPresentationAttribute(name); | 66 V8HTMLMarqueeElement::PrivateScript::detachedCallbackMethod(insertionPoi
nt->document().frame(), this); |
| 70 } | 67 } |
| 71 | |
| 72 void HTMLMarqueeElement::collectStyleForPresentationAttribute(const QualifiedNam
e& name, const AtomicString& value, MutableStylePropertySet* style) | |
| 73 { | |
| 74 if (name == widthAttr) { | |
| 75 if (!value.isEmpty()) | |
| 76 addHTMLLengthToStyle(style, CSSPropertyWidth, value); | |
| 77 } else if (name == heightAttr) { | |
| 78 if (!value.isEmpty()) | |
| 79 addHTMLLengthToStyle(style, CSSPropertyHeight, value); | |
| 80 } else if (name == bgcolorAttr) { | |
| 81 if (!value.isEmpty()) | |
| 82 addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value); | |
| 83 } else if (name == vspaceAttr) { | |
| 84 if (!value.isEmpty()) { | |
| 85 addHTMLLengthToStyle(style, CSSPropertyMarginTop, value); | |
| 86 addHTMLLengthToStyle(style, CSSPropertyMarginBottom, value); | |
| 87 } | |
| 88 } else if (name == hspaceAttr) { | |
| 89 if (!value.isEmpty()) { | |
| 90 addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value); | |
| 91 addHTMLLengthToStyle(style, CSSPropertyMarginRight, value); | |
| 92 } | |
| 93 } else if (name == scrollamountAttr) { | |
| 94 if (!value.isEmpty()) | |
| 95 addHTMLLengthToStyle(style, CSSPropertyInternalMarqueeIncrement, val
ue); | |
| 96 } else if (name == scrolldelayAttr) { | |
| 97 if (!value.isEmpty()) | |
| 98 addHTMLLengthToStyle(style, CSSPropertyInternalMarqueeSpeed, value); | |
| 99 } else if (name == loopAttr) { | |
| 100 if (!value.isEmpty()) { | |
| 101 if (value == "-1" || equalIgnoringCase(value, "infinite")) | |
| 102 addPropertyToPresentationAttributeStyle(style, CSSPropertyIntern
alMarqueeRepetition, CSSValueInfinite); | |
| 103 else | |
| 104 addHTMLLengthToStyle(style, CSSPropertyInternalMarqueeRepetition
, value); | |
| 105 } | |
| 106 } else if (name == behaviorAttr) { | |
| 107 if (!value.isEmpty()) | |
| 108 addPropertyToPresentationAttributeStyle(style, CSSPropertyInternalMa
rqueeStyle, value); | |
| 109 } else if (name == directionAttr) { | |
| 110 if (!value.isEmpty()) | |
| 111 addPropertyToPresentationAttributeStyle(style, CSSPropertyInternalMa
rqueeDirection, value); | |
| 112 } else | |
| 113 HTMLElement::collectStyleForPresentationAttribute(name, value, style); | |
| 114 } | |
| 115 | |
| 116 void HTMLMarqueeElement::start() | |
| 117 { | |
| 118 if (RenderMarquee* marqueeRenderer = renderMarquee()) | |
| 119 marqueeRenderer->start(); | |
| 120 } | |
| 121 | |
| 122 void HTMLMarqueeElement::stop() | |
| 123 { | |
| 124 if (RenderMarquee* marqueeRenderer = renderMarquee()) | |
| 125 marqueeRenderer->stop(); | |
| 126 } | |
| 127 | |
| 128 void HTMLMarqueeElement::suspend() | |
| 129 { | |
| 130 if (RenderMarquee* marqueeRenderer = renderMarquee()) | |
| 131 marqueeRenderer->suspend(); | |
| 132 } | |
| 133 | |
| 134 void HTMLMarqueeElement::resume() | |
| 135 { | |
| 136 if (RenderMarquee* marqueeRenderer = renderMarquee()) | |
| 137 marqueeRenderer->updateMarqueePosition(); | |
| 138 } | |
| 139 | |
| 140 RenderMarquee* HTMLMarqueeElement::renderMarquee() const | |
| 141 { | |
| 142 if (renderer() && renderer()->isMarquee()) | |
| 143 return toRenderMarquee(renderer()); | |
| 144 return 0; | |
| 145 } | |
| 146 | |
| 147 RenderObject* HTMLMarqueeElement::createRenderer(RenderStyle*) | |
| 148 { | |
| 149 return new RenderMarquee(this); | |
| 150 } | |
| 151 | |
| 152 void HTMLMarqueeElement::timerFired(Timer<HTMLMarqueeElement>*) | |
| 153 { | |
| 154 if (!renderer()) | |
| 155 return; | |
| 156 | |
| 157 document().updateLayout(); | |
| 158 | |
| 159 // The updateLayout() could have destroyed renderer(), so this re-check is v
ery important. | |
| 160 if (renderer()) | |
| 161 toRenderMarquee(renderer())->timerFired(); | |
| 162 } | 68 } |
| 163 | 69 |
| 164 } // namespace blink | 70 } // namespace blink |
| OLD | NEW |