tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SVGSymbolElement.cpp (1778B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozilla/dom/SVGSymbolElement.h"
      8 
      9 #include "mozilla/dom/SVGSymbolElementBinding.h"
     10 
     11 NS_IMPL_NS_NEW_SVG_ELEMENT(Symbol)
     12 
     13 namespace mozilla::dom {
     14 
     15 JSObject* SVGSymbolElement::WrapNode(JSContext* aCx,
     16                                     JS::Handle<JSObject*> aGivenProto) {
     17  return SVGSymbolElement_Binding::Wrap(aCx, this, aGivenProto);
     18 }
     19 
     20 //----------------------------------------------------------------------
     21 // nsISupports methods
     22 
     23 NS_IMPL_ISUPPORTS_INHERITED(SVGSymbolElement, SVGSymbolElementBase,
     24                            mozilla::dom::SVGTests)
     25 
     26 //----------------------------------------------------------------------
     27 // Implementation
     28 
     29 SVGSymbolElement::SVGSymbolElement(
     30    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
     31    : SVGSymbolElementBase(std::move(aNodeInfo)) {}
     32 
     33 Focusable SVGSymbolElement::IsFocusableWithoutStyle(IsFocusableFlags aFlags) {
     34  if (!CouldBeRendered()) {
     35    return {};
     36  }
     37  return SVGSymbolElementBase::IsFocusableWithoutStyle(aFlags);
     38 }
     39 
     40 bool SVGSymbolElement::CouldBeRendered() const {
     41  // Only <symbol> elements in the root of a <svg:use> shadow tree are
     42  // displayed.
     43  auto* shadowRoot = ShadowRoot::FromNodeOrNull(GetParentNode());
     44  return shadowRoot && shadowRoot->Host()->IsSVGElement(nsGkAtoms::use);
     45 }
     46 
     47 //----------------------------------------------------------------------
     48 // nsINode methods
     49 
     50 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGSymbolElement)
     51 
     52 }  // namespace mozilla::dom