content/base/src/nsStyledElement.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
     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/. */
     7 /**
     8  * nsStyledElement is the base for elements supporting styling via the
     9  * id/class/style attributes; it is a common base for their support in HTML,
    10  * SVG and MathML.
    11  */
    13 #ifndef __NS_STYLEDELEMENT_H_
    14 #define __NS_STYLEDELEMENT_H_
    16 #include "mozilla/Attributes.h"
    17 #include "nsString.h"
    18 #include "mozilla/dom/Element.h"
    20 namespace mozilla {
    21 namespace css {
    22 class StyleRule;
    23 }
    24 }
    26 typedef mozilla::dom::Element nsStyledElementBase;
    28 class nsStyledElementNotElementCSSInlineStyle : public nsStyledElementBase
    29 {
    31 protected:
    33   inline nsStyledElementNotElementCSSInlineStyle(already_AddRefed<nsINodeInfo>& aNodeInfo)
    34     : nsStyledElementBase(aNodeInfo)
    35   {}
    37 public:
    38   // nsIContent interface methods
    39   virtual nsIAtom* GetClassAttributeName() const MOZ_OVERRIDE;
    40   virtual nsIAtom* GetIDAttributeName() const MOZ_OVERRIDE;
    41   virtual nsIAtom* DoGetID() const MOZ_OVERRIDE;
    42   virtual const nsAttrValue* DoGetClasses() const MOZ_OVERRIDE;
    44   virtual mozilla::css::StyleRule* GetInlineStyleRule();
    45   virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
    46                                       const nsAString* aSerialized,
    47                                       bool aNotify) MOZ_OVERRIDE;
    49   virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
    50                              bool aNotify) MOZ_OVERRIDE;
    51   virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
    52                                 const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE;
    54   nsICSSDeclaration* Style();
    56 protected:
    58   /**
    59    * Parse a style attr value into a CSS rulestruct (or, if there is no
    60    * document, leave it as a string) and return as nsAttrValue.
    61    *
    62    * @param aValue the value to parse
    63    * @param aResult the resulting HTMLValue [OUT]
    64    */
    65   void ParseStyleAttribute(const nsAString& aValue,
    66                            nsAttrValue& aResult,
    67                            bool aForceInDataDoc);
    69   virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
    70                                 const nsAString& aValue, nsAttrValue& aResult) MOZ_OVERRIDE;
    72   friend class mozilla::dom::Element;
    74   /**
    75    * Create the style struct from the style attr.  Used when an element is
    76    * first put into a document.  Only has an effect if the old value is a
    77    * string.  If aForceInDataDoc is true, will reparse even if we're in a data
    78    * document.
    79    */
    80   nsresult  ReparseStyleAttribute(bool aForceInDataDoc);
    81 };
    83 class nsStyledElement : public nsStyledElementNotElementCSSInlineStyle {
    84 protected:
    85   inline nsStyledElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
    86     : nsStyledElementNotElementCSSInlineStyle(aNodeInfo)
    87   {}
    88 };
    90 #endif // __NS_STYLEDELEMENT_H_

mercurial