本文整理汇总了C++中SVGUseElement::title方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGUseElement::title方法的具体用法?C++ SVGUseElement::title怎么用?C++ SVGUseElement::title使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGUseElement
的用法示例。
在下文中一共展示了SVGUseElement::title方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: title
String SVGStyledElement::title() const
{
// According to spec, we should not return titles when hovering over root <svg> elements (those
// <title> elements are the title of the document, not a tooltip) so we instantly return.
if (isOutermostSVGSVGElement())
return String();
// Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title.
if (isInShadowTree()) {
SVGUseElement* useElement = static_cast<SVGUseElement*>(treeScope()->rootNode()->shadowHost());
ASSERT(useElement);
// If the <use> title is not empty we found the title to use.
String useTitle(useElement->title());
if (!useTitle.isEmpty())
return useTitle;
}
// If we aren't an instance in a <use> or the <use> title was not found, then find the first
// <title> child of this element.
Element* titleElement = firstElementChild();
for (; titleElement; titleElement = titleElement->nextElementSibling()) {
if (titleElement->hasTagName(SVGNames::titleTag) && titleElement->isSVGElement())
break;
}
// If a title child was found, return the text contents.
if (titleElement)
return titleElement->innerText();
// Otherwise return a null/empty string.
return String();
}
示例2: title
String SVGStyledElement::title() const
{
// According to spec, we should not return titles when hovering over root <svg> elements (those
// <title> elements are the title of the document, not a tooltip) so we instantly return.
if (hasTagName(SVGNames::svgTag)) {
const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(this);
if (svg->isOutermostSVG())
return String();
}
// Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title.
Node* parent = const_cast<SVGStyledElement*>(this);
while (parent) {
if (!parent->isSVGShadowRoot()) {
parent = parent->parentNodeGuaranteedHostFree();
continue;
}
// Get the <use> element.
Element* shadowParent = parent->svgShadowHost();
if (shadowParent && shadowParent->isSVGElement() && shadowParent->hasTagName(SVGNames::useTag)) {
SVGUseElement* useElement = static_cast<SVGUseElement*>(shadowParent);
// If the <use> title is not empty we found the title to use.
String useTitle(useElement->title());
if (useTitle.isEmpty())
break;
return useTitle;
}
parent = parent->parentNode();
}
// If we aren't an instance in a <use> or the <use> title was not found, then find the first
// <title> child of this element.
Element* titleElement = firstElementChild();
for (; titleElement; titleElement = titleElement->nextElementSibling()) {
if (titleElement->hasTagName(SVGNames::titleTag) && titleElement->isSVGElement())
break;
}
// If a title child was found, return the text contents.
if (titleElement)
return titleElement->innerText();
// Otherwise return a null/empty string.
return String();
}
示例3: title
String SVGElement::title() const
{
// According to spec, we should not return titles when hovering over root <svg> elements (those
// <title> elements are the title of the document, not a tooltip) so we instantly return.
if (isOutermostSVGSVGElement())
return String();
// Walk up the tree, to find out whether we're inside a <use> shadow tree, to find the right title.
if (isInShadowTree()) {
Element* shadowHostElement = toShadowRoot(treeScope().rootNode()).host();
// At this time, SVG nodes are not allowed in non-<use> shadow trees, so any shadow root we do
// have should be a use. The assert and following test is here to catch future shadow DOM changes
// that do enable SVG in a shadow tree.
ASSERT(!shadowHostElement || shadowHostElement->hasTagName(SVGNames::useTag));
if (shadowHostElement && shadowHostElement->hasTagName(SVGNames::useTag)) {
SVGUseElement* useElement = toSVGUseElement(shadowHostElement);
// If the <use> title is not empty we found the title to use.
String useTitle(useElement->title());
if (!useTitle.isEmpty())
return useTitle;
}
}
// If we aren't an instance in a <use> or the <use> title was not found, then find the first
// <title> child of this element.
Element* titleElement = ElementTraversal::firstWithin(*this);
for (; titleElement; titleElement = ElementTraversal::nextSkippingChildren(*titleElement, this)) {
if (titleElement->hasTagName(SVGNames::titleTag) && titleElement->isSVGElement())
break;
}
// If a title child was found, return the text contents.
if (titleElement)
return titleElement->innerText();
// Otherwise return a null/empty string.
return String();
}