Changeset 58160 in webkit
- Timestamp:
- Apr 23, 2010 2:31:53 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r58158 r58160 1 2010-04-23 Jeff Schiller <codedread@gmail.com> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Display tooltips when hovering over SVG elements, Bug 16854 6 https://bugs.webkit.org/show_bug.cgi?id=16854 7 8 Manual test added for verifying tooltips. 9 10 * manual-tests/svg-tooltip.svg: Added. 11 * svg/SVGAElement.cpp: 12 (WebCore::SVGAElement::title): xlink:title takes precedence, otherwise SVGStyledElement::title() is used 13 * svg/SVGStyledElement.cpp: 14 (WebCore::SVGStyledElement::title): checks for a shadow parent and uses that title, otherwise uses the content's title 15 * svg/SVGStyledElement.h: add title() method declaration 16 1 17 2010-04-23 David Kilzer <ddkilzer@apple.com> 2 18 -
trunk/WebCore/svg/SVGAElement.cpp
r53879 r58160 61 61 String SVGAElement::title() const 62 62 { 63 return getAttribute(XLinkNames::titleAttr); 63 // If the xlink:title is set (non-empty string), use it. 64 const AtomicString& title = getAttribute(XLinkNames::titleAttr); 65 if (!title.isEmpty()) 66 return title; 67 68 // Otherwise, use the title of this element. 69 return SVGStyledElement::title(); 64 70 } 65 71 -
trunk/WebCore/svg/SVGStyledElement.cpp
r57886 r58160 44 44 #include "SVGResource.h" 45 45 #include "SVGSVGElement.h" 46 #include "SVGUseElement.h" 46 47 #include <wtf/Assertions.h> 47 48 … … 65 66 { 66 67 SVGResource::removeClient(this); 68 } 69 70 String SVGStyledElement::title() const 71 { 72 // According to spec, we should not return titles when hovering over <svg> elements (those 73 // <title> elements are the title of the document, not a tooltip) so we instantly return. 74 if (hasTagName(SVGNames::svgTag)) 75 return String(); 76 77 // Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title. 78 Node* parent = const_cast<SVGStyledElement*>(this); 79 while (parent) { 80 if (!parent->isShadowNode()) { 81 parent = parent->parentNode(); 82 continue; 83 } 84 85 // Get the <use> element. 86 Node* shadowParent = parent->shadowParentNode(); 87 if (shadowParent && shadowParent->isSVGElement() && shadowParent->hasTagName(SVGNames::useTag)) { 88 SVGUseElement* useElement = static_cast<SVGUseElement*>(shadowParent); 89 // If the <use> title is not empty we found the title to use. 90 String useTitle(useElement->title()); 91 if (useTitle.isEmpty()) 92 break; 93 return useTitle; 94 } 95 parent = parent->parentNode(); 96 } 97 98 // If we aren't an instance in a <use> or the <use> title was not found, then find the first 99 // <title> child of this element. 100 Element* titleElement = firstElementChild(); 101 for (; titleElement; titleElement = titleElement->nextElementSibling()) { 102 if (titleElement->hasTagName(SVGNames::titleTag) && titleElement->isSVGElement()) 103 break; 104 } 105 106 // If a title child was found, return the text contents. 107 if (titleElement) 108 return titleElement->innerText(); 109 110 // Otherwise return a null/empty string. 111 return String(); 67 112 } 68 113 -
trunk/WebCore/svg/SVGStyledElement.h
r56905 r58160 39 39 SVGStyledElement(const QualifiedName&, Document*); 40 40 virtual ~SVGStyledElement(); 41 42 virtual String title() const; 41 43 42 44 virtual bool hasRelativeValues() const { return false; }
Note: See TracChangeset
for help on using the changeset viewer.