| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | |
| 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | |
| 4 * | |
| 5 * This library is free software; you can redistribute it and/or | |
| 6 * modify it under the terms of the GNU Library General Public | |
| 7 * License as published by the Free Software Foundation; either | |
| 8 * version 2 of the License, or (at your option) any later version. | |
| 9 * | |
| 10 * This library is distributed in the hope that it will be useful, | |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 * Library General Public License for more details. | |
| 14 * | |
| 15 * You should have received a copy of the GNU Library General Public License | |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 18 * Boston, MA 02110-1301, USA. | |
| 19 */ | |
| 20 | |
| 21 #include "core/svg/SVGCursorElement.h" | |
| 22 | |
| 23 #include "core/SVGNames.h" | |
| 24 #include "core/dom/StyleChangeReason.h" | |
| 25 #include "core/frame/UseCounter.h" | |
| 26 | |
| 27 namespace blink { | |
| 28 | |
| 29 inline SVGCursorElement::SVGCursorElement(Document& document) | |
| 30 : SVGElement(SVGNames::cursorTag, document), | |
| 31 SVGTests(this), | |
| 32 SVGURIReference(this), | |
| 33 m_x(SVGAnimatedLength::create(this, | |
| 34 SVGNames::xAttr, | |
| 35 SVGLength::create(SVGLengthMode::Width))), | |
| 36 m_y(SVGAnimatedLength::create(this, | |
| 37 SVGNames::yAttr, | |
| 38 SVGLength::create(SVGLengthMode::Height))) { | |
| 39 addToPropertyMap(m_x); | |
| 40 addToPropertyMap(m_y); | |
| 41 | |
| 42 UseCounter::count(document, UseCounter::SVGCursorElement); | |
| 43 } | |
| 44 | |
| 45 DEFINE_NODE_FACTORY(SVGCursorElement) | |
| 46 | |
| 47 SVGCursorElement::~SVGCursorElement() {} | |
| 48 | |
| 49 void SVGCursorElement::addClient(SVGElement* element) { | |
| 50 UseCounter::count(document(), UseCounter::SVGCursorElementHasClient); | |
| 51 | |
| 52 m_clients.add(element); | |
| 53 element->setCursorElement(this); | |
| 54 } | |
| 55 | |
| 56 void SVGCursorElement::removeReferencedElement(SVGElement* element) { | |
| 57 m_clients.remove(element); | |
| 58 } | |
| 59 | |
| 60 void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName) { | |
| 61 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || | |
| 62 SVGTests::isKnownAttribute(attrName) || | |
| 63 SVGURIReference::isKnownAttribute(attrName)) { | |
| 64 SVGElement::InvalidationGuard invalidationGuard(this); | |
| 65 | |
| 66 // Any change of a cursor specific attribute triggers this recalc. | |
| 67 for (const auto& client : m_clients) | |
| 68 client->setNeedsStyleRecalc( | |
| 69 LocalStyleChange, | |
| 70 StyleChangeReasonForTracing::create(StyleChangeReason::SVGCursor)); | |
| 71 | |
| 72 return; | |
| 73 } | |
| 74 | |
| 75 SVGElement::svgAttributeChanged(attrName); | |
| 76 } | |
| 77 | |
| 78 DEFINE_TRACE(SVGCursorElement) { | |
| 79 visitor->trace(m_x); | |
| 80 visitor->trace(m_y); | |
| 81 visitor->trace(m_clients); | |
| 82 SVGElement::trace(visitor); | |
| 83 SVGTests::trace(visitor); | |
| 84 SVGURIReference::trace(visitor); | |
| 85 } | |
| 86 | |
| 87 } // namespace blink | |
| OLD | NEW |