| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 SVGCursorElement::~SVGCursorElement() | 43 SVGCursorElement::~SVGCursorElement() |
| 44 { | 44 { |
| 45 // The below teardown is all handled by weak pointer processing in oilpan. | 45 // The below teardown is all handled by weak pointer processing in oilpan. |
| 46 #if !ENABLE(OILPAN) | 46 #if !ENABLE(OILPAN) |
| 47 for (const auto& client : m_clients) | 47 for (const auto& client : m_clients) |
| 48 client->cursorElementRemoved(); | 48 client->cursorElementRemoved(); |
| 49 #endif | 49 #endif |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool SVGCursorElement::isSupportedAttribute(const QualifiedName& attrName) | |
| 53 { | |
| 54 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | |
| 55 if (supportedAttributes.isEmpty()) { | |
| 56 SVGTests::addSupportedAttributes(supportedAttributes); | |
| 57 SVGURIReference::addSupportedAttributes(supportedAttributes); | |
| 58 supportedAttributes.add(SVGNames::xAttr); | |
| 59 supportedAttributes.add(SVGNames::yAttr); | |
| 60 } | |
| 61 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | |
| 62 } | |
| 63 | |
| 64 void SVGCursorElement::addClient(SVGElement* element) | 52 void SVGCursorElement::addClient(SVGElement* element) |
| 65 { | 53 { |
| 66 m_clients.add(element); | 54 m_clients.add(element); |
| 67 element->setCursorElement(this); | 55 element->setCursorElement(this); |
| 68 } | 56 } |
| 69 | 57 |
| 70 #if !ENABLE(OILPAN) | 58 #if !ENABLE(OILPAN) |
| 71 void SVGCursorElement::removeClient(SVGElement* element) | 59 void SVGCursorElement::removeClient(SVGElement* element) |
| 72 { | 60 { |
| 73 HashSet<RawPtr<SVGElement>>::iterator it = m_clients.find(element); | 61 HashSet<RawPtr<SVGElement>>::iterator it = m_clients.find(element); |
| 74 if (it != m_clients.end()) { | 62 if (it != m_clients.end()) { |
| 75 m_clients.remove(it); | 63 m_clients.remove(it); |
| 76 element->cursorElementRemoved(); | 64 element->cursorElementRemoved(); |
| 77 } | 65 } |
| 78 } | 66 } |
| 79 #endif | 67 #endif |
| 80 | 68 |
| 81 void SVGCursorElement::removeReferencedElement(SVGElement* element) | 69 void SVGCursorElement::removeReferencedElement(SVGElement* element) |
| 82 { | 70 { |
| 83 m_clients.remove(element); | 71 m_clients.remove(element); |
| 84 } | 72 } |
| 85 | 73 |
| 86 void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName) | 74 void SVGCursorElement::svgAttributeChanged(const QualifiedName& attrName) |
| 87 { | 75 { |
| 88 if (!isSupportedAttribute(attrName)) { | 76 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr |
| 89 SVGElement::svgAttributeChanged(attrName); | 77 || SVGTests::isKnownAttribute(attrName) |
| 78 || SVGURIReference::isKnownAttribute(attrName)) { |
| 79 SVGElement::InvalidationGuard invalidationGuard(this); |
| 80 |
| 81 // Any change of a cursor specific attribute triggers this recalc. |
| 82 for (const auto& client : m_clients) |
| 83 client->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor
Tracing::create(StyleChangeReason::SVGCursor)); |
| 84 |
| 90 return; | 85 return; |
| 91 } | 86 } |
| 92 | 87 |
| 93 SVGElement::InvalidationGuard invalidationGuard(this); | 88 SVGElement::svgAttributeChanged(attrName); |
| 94 | |
| 95 // Any change of a cursor specific attribute triggers this recalc. | |
| 96 for (const auto& client : m_clients) | |
| 97 client->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTrac
ing::create(StyleChangeReason::SVGCursor)); | |
| 98 } | 89 } |
| 99 | 90 |
| 100 DEFINE_TRACE(SVGCursorElement) | 91 DEFINE_TRACE(SVGCursorElement) |
| 101 { | 92 { |
| 102 #if ENABLE(OILPAN) | 93 #if ENABLE(OILPAN) |
| 103 visitor->trace(m_x); | 94 visitor->trace(m_x); |
| 104 visitor->trace(m_y); | 95 visitor->trace(m_y); |
| 105 visitor->trace(m_clients); | 96 visitor->trace(m_clients); |
| 106 #endif | 97 #endif |
| 107 SVGElement::trace(visitor); | 98 SVGElement::trace(visitor); |
| 108 SVGTests::trace(visitor); | 99 SVGTests::trace(visitor); |
| 109 SVGURIReference::trace(visitor); | 100 SVGURIReference::trace(visitor); |
| 110 } | 101 } |
| 111 | 102 |
| 112 } // namespace blink | 103 } // namespace blink |
| OLD | NEW |