content/base/src/nsStyledElement.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/src/nsStyledElement.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,90 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/**
    1.11 + * nsStyledElement is the base for elements supporting styling via the
    1.12 + * id/class/style attributes; it is a common base for their support in HTML,
    1.13 + * SVG and MathML.
    1.14 + */
    1.15 +
    1.16 +#ifndef __NS_STYLEDELEMENT_H_
    1.17 +#define __NS_STYLEDELEMENT_H_
    1.18 +
    1.19 +#include "mozilla/Attributes.h"
    1.20 +#include "nsString.h"
    1.21 +#include "mozilla/dom/Element.h"
    1.22 +
    1.23 +namespace mozilla {
    1.24 +namespace css {
    1.25 +class StyleRule;
    1.26 +}
    1.27 +}
    1.28 +
    1.29 +typedef mozilla::dom::Element nsStyledElementBase;
    1.30 +
    1.31 +class nsStyledElementNotElementCSSInlineStyle : public nsStyledElementBase
    1.32 +{
    1.33 +
    1.34 +protected:
    1.35 +
    1.36 +  inline nsStyledElementNotElementCSSInlineStyle(already_AddRefed<nsINodeInfo>& aNodeInfo)
    1.37 +    : nsStyledElementBase(aNodeInfo)
    1.38 +  {}
    1.39 +
    1.40 +public:
    1.41 +  // nsIContent interface methods
    1.42 +  virtual nsIAtom* GetClassAttributeName() const MOZ_OVERRIDE;
    1.43 +  virtual nsIAtom* GetIDAttributeName() const MOZ_OVERRIDE;
    1.44 +  virtual nsIAtom* DoGetID() const MOZ_OVERRIDE;
    1.45 +  virtual const nsAttrValue* DoGetClasses() const MOZ_OVERRIDE;
    1.46 +
    1.47 +  virtual mozilla::css::StyleRule* GetInlineStyleRule();
    1.48 +  virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
    1.49 +                                      const nsAString* aSerialized,
    1.50 +                                      bool aNotify) MOZ_OVERRIDE;
    1.51 +
    1.52 +  virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
    1.53 +                             bool aNotify) MOZ_OVERRIDE;
    1.54 +  virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
    1.55 +                                const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE;
    1.56 +
    1.57 +  nsICSSDeclaration* Style();
    1.58 +
    1.59 +protected:
    1.60 +
    1.61 +  /**
    1.62 +   * Parse a style attr value into a CSS rulestruct (or, if there is no
    1.63 +   * document, leave it as a string) and return as nsAttrValue.
    1.64 +   *
    1.65 +   * @param aValue the value to parse
    1.66 +   * @param aResult the resulting HTMLValue [OUT]
    1.67 +   */
    1.68 +  void ParseStyleAttribute(const nsAString& aValue,
    1.69 +                           nsAttrValue& aResult,
    1.70 +                           bool aForceInDataDoc);
    1.71 +
    1.72 +  virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
    1.73 +                                const nsAString& aValue, nsAttrValue& aResult) MOZ_OVERRIDE;
    1.74 +
    1.75 +  friend class mozilla::dom::Element;
    1.76 +
    1.77 +  /**
    1.78 +   * Create the style struct from the style attr.  Used when an element is
    1.79 +   * first put into a document.  Only has an effect if the old value is a
    1.80 +   * string.  If aForceInDataDoc is true, will reparse even if we're in a data
    1.81 +   * document.
    1.82 +   */
    1.83 +  nsresult  ReparseStyleAttribute(bool aForceInDataDoc);
    1.84 +};
    1.85 +
    1.86 +class nsStyledElement : public nsStyledElementNotElementCSSInlineStyle {
    1.87 +protected:
    1.88 +  inline nsStyledElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
    1.89 +    : nsStyledElementNotElementCSSInlineStyle(aNodeInfo)
    1.90 +  {}
    1.91 +};
    1.92 +
    1.93 +#endif // __NS_STYLEDELEMENT_H_

mercurial