author Alexis Beingessner <>
Thu, 10 Oct 2019 23:10:28 +0000
changeset 552383 b6d82b1a6b027461055a92f052d6d0511086a5bb
parent 509549 f0a91d36587266d7454a450c6044d573664fbed5
child 552962 3a9ac43f49a645082db3619993c0365db6b7b263
permissions -rw-r--r--
Bug 1587155 - Block all hardware acceleration for AMD driver r=jrmuizel a=lizzard Driver's Haunted. Differential Revision:

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

 * nsStyledElement is the base for elements supporting styling via the
 * id/class/style attributes; it is a common base for their support in HTML,
 * SVG and MathML.


#include "mozilla/Attributes.h"
#include "nsString.h"
#include "mozilla/dom/Element.h"

namespace mozilla {
class DeclarationBlock;
}  // namespace mozilla

// IID for nsStyledElement interface
#define NS_STYLED_ELEMENT_IID                        \
  {                                                  \
    0xacbd9ea6, 0x15aa, 0x4f37, {                    \
      0x8c, 0xe0, 0x35, 0x1e, 0xd7, 0x21, 0xca, 0xe9 \
    }                                                \

typedef mozilla::dom::Element nsStyledElementBase;

class nsStyledElement : public nsStyledElementBase {
  inline explicit nsStyledElement(
      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
      : nsStyledElementBase(std::move(aNodeInfo)) {}

  // We don't want to implement AddRef/Release because that would add an extra
  // function call for those on pretty much all elements.  But we do need QI, so
  // we can QI to nsStyledElement.
  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;

  // Element interface methods
  virtual void InlineStyleDeclarationWillChange(
      mozilla::MutationClosureData& aData) override;
  virtual nsresult SetInlineStyleDeclaration(
      mozilla::DeclarationBlock& aDeclaration,
      mozilla::MutationClosureData& aData) override;

  nsICSSDeclaration* Style();


  nsICSSDeclaration* GetExistingStyle();

   * Parse a style attr value into a CSS rulestruct (or, if there is no
   * document, leave it as a string) and return as nsAttrValue.
   * @param aValue the value to parse
   * @param aMaybeScriptedPrincipal if available, the scripted principal
   *        responsible for this attribute value, as passed to
   *        Element::ParseAttribute.
   * @param aResult the resulting HTMLValue [OUT]
  void ParseStyleAttribute(const nsAString& aValue,
                           nsIPrincipal* aMaybeScriptedPrincipal,
                           nsAttrValue& aResult, bool aForceInDataDoc);

  virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
                              const nsAString& aValue,
                              nsIPrincipal* aMaybeScriptedPrincipal,
                              nsAttrValue& aResult) override;

  friend class mozilla::dom::Element;

   * Create the style struct from the style attr.  Used when an element is
   * first put into a document.  Only has an effect if the old value is a
   * string.  If aForceInDataDoc is true, will reparse even if we're in a data
   * document. If aForceIfAlreadyParsed is set, this will always reparse even
   * if the value has already been parsed.
  nsresult ReparseStyleAttribute(bool aForceInDataDoc,
                                 bool aForceIfAlreadyParsed);

  virtual void NodeInfoChanged(mozilla::dom::Document* aOldDoc) override;

  virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
                                 const nsAttrValueOrString* aValue,
                                 bool aNotify) override;

#endif  // __NS_STYLEDELEMENT_H_