tor-browser

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

nsXMLElement.cpp (1658B)


      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 "nsXMLElement.h"
      8 
      9 #include "mozilla/dom/ElementBinding.h"
     10 #include "mozilla/dom/ElementInlines.h"
     11 #include "nsContentUtils.h"  // nsAutoScriptBlocker
     12 
     13 using namespace mozilla;
     14 using namespace mozilla::dom;
     15 
     16 nsresult NS_NewXMLElement(
     17    Element** aInstancePtrResult,
     18    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) {
     19  RefPtr<mozilla::dom::NodeInfo> nodeInfo(std::move(aNodeInfo));
     20  auto* nim = nodeInfo->NodeInfoManager();
     21  RefPtr<nsXMLElement> it = new (nim) nsXMLElement(nodeInfo.forget());
     22 
     23  it.forget(aInstancePtrResult);
     24  return NS_OK;
     25 }
     26 
     27 void nsXMLElement::UnbindFromTree(UnbindContext& aContext) {
     28  nsAtom* property;
     29  switch (GetPseudoElementType()) {
     30    case PseudoStyleType::marker:
     31      property = nsGkAtoms::markerPseudoProperty;
     32      break;
     33    case PseudoStyleType::before:
     34      property = nsGkAtoms::beforePseudoProperty;
     35      break;
     36    case PseudoStyleType::after:
     37      property = nsGkAtoms::afterPseudoProperty;
     38      break;
     39    case PseudoStyleType::backdrop:
     40      property = nsGkAtoms::backdropPseudoProperty;
     41      break;
     42    default:
     43      property = nullptr;
     44  }
     45  if (property) {
     46    MOZ_ASSERT(GetParent());
     47    MOZ_ASSERT(GetParent()->IsElement());
     48    GetParent()->RemoveProperty(property);
     49  }
     50  Element::UnbindFromTree(aContext);
     51 }
     52 
     53 NS_IMPL_ELEMENT_CLONE(nsXMLElement)