| 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 "CSSPropertyNames.h" | 26 #include "CSSPropertyNames.h" |
| 27 #include "CSSValueKeywords.h" | 27 #include "CSSValueKeywords.h" |
| 28 #include "HTMLNames.h" | 28 #include "HTMLNames.h" |
| 29 #include "bindings/v8/ExceptionMessages.h" | |
| 30 #include "bindings/v8/ExceptionState.h" | 29 #include "bindings/v8/ExceptionState.h" |
| 31 #include "core/dom/ExceptionCode.h" | 30 #include "core/dom/ExceptionCode.h" |
| 32 #include "core/rendering/RenderMarquee.h" | 31 #include "core/rendering/RenderMarquee.h" |
| 33 | 32 |
| 34 namespace WebCore { | 33 namespace WebCore { |
| 35 | 34 |
| 36 using namespace HTMLNames; | 35 using namespace HTMLNames; |
| 37 | 36 |
| 38 inline HTMLMarqueeElement::HTMLMarqueeElement(Document& document) | 37 inline HTMLMarqueeElement::HTMLMarqueeElement(Document& document) |
| 39 : HTMLElement(marqueeTag, document) | 38 : HTMLElement(marqueeTag, document) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 int HTMLMarqueeElement::scrollAmount() const | 123 int HTMLMarqueeElement::scrollAmount() const |
| 125 { | 124 { |
| 126 bool ok; | 125 bool ok; |
| 127 int scrollAmount = fastGetAttribute(scrollamountAttr).toInt(&ok); | 126 int scrollAmount = fastGetAttribute(scrollamountAttr).toInt(&ok); |
| 128 return ok && scrollAmount >= 0 ? scrollAmount : RenderStyle::initialMarqueeI
ncrement().intValue(); | 127 return ok && scrollAmount >= 0 ? scrollAmount : RenderStyle::initialMarqueeI
ncrement().intValue(); |
| 129 } | 128 } |
| 130 | 129 |
| 131 void HTMLMarqueeElement::setScrollAmount(int scrollAmount, ExceptionState& excep
tionState) | 130 void HTMLMarqueeElement::setScrollAmount(int scrollAmount, ExceptionState& excep
tionState) |
| 132 { | 131 { |
| 133 if (scrollAmount < 0) | 132 if (scrollAmount < 0) |
| 134 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToSet("scrollAmount", "HTMLMarqueeElement", "The provided value (" + String::n
umber(scrollAmount) + ") is negative.")); | 133 exceptionState.throwDOMException(IndexSizeError, "The provided value ("
+ String::number(scrollAmount) + ") is negative."); |
| 135 else | 134 else |
| 136 setIntegralAttribute(scrollamountAttr, scrollAmount); | 135 setIntegralAttribute(scrollamountAttr, scrollAmount); |
| 137 } | 136 } |
| 138 | 137 |
| 139 int HTMLMarqueeElement::scrollDelay() const | 138 int HTMLMarqueeElement::scrollDelay() const |
| 140 { | 139 { |
| 141 bool ok; | 140 bool ok; |
| 142 int scrollDelay = fastGetAttribute(scrolldelayAttr).toInt(&ok); | 141 int scrollDelay = fastGetAttribute(scrolldelayAttr).toInt(&ok); |
| 143 return ok && scrollDelay >= 0 ? scrollDelay : RenderStyle::initialMarqueeSpe
ed(); | 142 return ok && scrollDelay >= 0 ? scrollDelay : RenderStyle::initialMarqueeSpe
ed(); |
| 144 } | 143 } |
| 145 | 144 |
| 146 void HTMLMarqueeElement::setScrollDelay(int scrollDelay, ExceptionState& excepti
onState) | 145 void HTMLMarqueeElement::setScrollDelay(int scrollDelay, ExceptionState& excepti
onState) |
| 147 { | 146 { |
| 148 if (scrollDelay < 0) | 147 if (scrollDelay < 0) |
| 149 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToSet("scrollDelay", "HTMLMarqueeElement", "The provided value (" + String::nu
mber(scrollDelay) + ") is negative.")); | 148 exceptionState.throwDOMException(IndexSizeError, "The provided value ("
+ String::number(scrollDelay) + ") is negative."); |
| 150 else | 149 else |
| 151 setIntegralAttribute(scrolldelayAttr, scrollDelay); | 150 setIntegralAttribute(scrolldelayAttr, scrollDelay); |
| 152 } | 151 } |
| 153 | 152 |
| 154 int HTMLMarqueeElement::loop() const | 153 int HTMLMarqueeElement::loop() const |
| 155 { | 154 { |
| 156 bool ok; | 155 bool ok; |
| 157 int loopValue = fastGetAttribute(loopAttr).toInt(&ok); | 156 int loopValue = fastGetAttribute(loopAttr).toInt(&ok); |
| 158 return ok && loopValue > 0 ? loopValue : -1; | 157 return ok && loopValue > 0 ? loopValue : -1; |
| 159 } | 158 } |
| 160 | 159 |
| 161 void HTMLMarqueeElement::setLoop(int loop, ExceptionState& exceptionState) | 160 void HTMLMarqueeElement::setLoop(int loop, ExceptionState& exceptionState) |
| 162 { | 161 { |
| 163 if (loop <= 0 && loop != -1) | 162 if (loop <= 0 && loop != -1) |
| 164 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToSet("loop", "HTMLMarqueeElement", "The provided value (" + String::number(lo
op) + ") is neither positive nor -1.")); | 163 exceptionState.throwDOMException(IndexSizeError, "The provided value ("
+ String::number(loop) + ") is neither positive nor -1."); |
| 165 else | 164 else |
| 166 setIntegralAttribute(loopAttr, loop); | 165 setIntegralAttribute(loopAttr, loop); |
| 167 } | 166 } |
| 168 | 167 |
| 169 void HTMLMarqueeElement::suspend() | 168 void HTMLMarqueeElement::suspend() |
| 170 { | 169 { |
| 171 if (RenderMarquee* marqueeRenderer = renderMarquee()) | 170 if (RenderMarquee* marqueeRenderer = renderMarquee()) |
| 172 marqueeRenderer->suspend(); | 171 marqueeRenderer->suspend(); |
| 173 } | 172 } |
| 174 | 173 |
| 175 void HTMLMarqueeElement::resume() | 174 void HTMLMarqueeElement::resume() |
| 176 { | 175 { |
| 177 if (RenderMarquee* marqueeRenderer = renderMarquee()) | 176 if (RenderMarquee* marqueeRenderer = renderMarquee()) |
| 178 marqueeRenderer->updateMarqueePosition(); | 177 marqueeRenderer->updateMarqueePosition(); |
| 179 } | 178 } |
| 180 | 179 |
| 181 RenderMarquee* HTMLMarqueeElement::renderMarquee() const | 180 RenderMarquee* HTMLMarqueeElement::renderMarquee() const |
| 182 { | 181 { |
| 183 if (renderer() && renderer()->isMarquee()) | 182 if (renderer() && renderer()->isMarquee()) |
| 184 return toRenderMarquee(renderer()); | 183 return toRenderMarquee(renderer()); |
| 185 return 0; | 184 return 0; |
| 186 } | 185 } |
| 187 | 186 |
| 188 RenderObject* HTMLMarqueeElement::createRenderer(RenderStyle*) | 187 RenderObject* HTMLMarqueeElement::createRenderer(RenderStyle*) |
| 189 { | 188 { |
| 190 return new RenderMarquee(this); | 189 return new RenderMarquee(this); |
| 191 } | 190 } |
| 192 | 191 |
| 193 } // namespace WebCore | 192 } // namespace WebCore |
| OLD | NEW |