michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /** michael@0: * nsStyledElement is the base for elements supporting styling via the michael@0: * id/class/style attributes; it is a common base for their support in HTML, michael@0: * SVG and MathML. michael@0: */ michael@0: michael@0: #ifndef __NS_STYLEDELEMENT_H_ michael@0: #define __NS_STYLEDELEMENT_H_ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsString.h" michael@0: #include "mozilla/dom/Element.h" michael@0: michael@0: namespace mozilla { michael@0: namespace css { michael@0: class StyleRule; michael@0: } michael@0: } michael@0: michael@0: typedef mozilla::dom::Element nsStyledElementBase; michael@0: michael@0: class nsStyledElementNotElementCSSInlineStyle : public nsStyledElementBase michael@0: { michael@0: michael@0: protected: michael@0: michael@0: inline nsStyledElementNotElementCSSInlineStyle(already_AddRefed& aNodeInfo) michael@0: : nsStyledElementBase(aNodeInfo) michael@0: {} michael@0: michael@0: public: michael@0: // nsIContent interface methods michael@0: virtual nsIAtom* GetClassAttributeName() const MOZ_OVERRIDE; michael@0: virtual nsIAtom* GetIDAttributeName() const MOZ_OVERRIDE; michael@0: virtual nsIAtom* DoGetID() const MOZ_OVERRIDE; michael@0: virtual const nsAttrValue* DoGetClasses() const MOZ_OVERRIDE; michael@0: michael@0: virtual mozilla::css::StyleRule* GetInlineStyleRule(); michael@0: virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule, michael@0: const nsAString* aSerialized, michael@0: bool aNotify) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, michael@0: bool aNotify) MOZ_OVERRIDE; michael@0: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, michael@0: const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE; michael@0: michael@0: nsICSSDeclaration* Style(); michael@0: michael@0: protected: michael@0: michael@0: /** michael@0: * Parse a style attr value into a CSS rulestruct (or, if there is no michael@0: * document, leave it as a string) and return as nsAttrValue. michael@0: * michael@0: * @param aValue the value to parse michael@0: * @param aResult the resulting HTMLValue [OUT] michael@0: */ michael@0: void ParseStyleAttribute(const nsAString& aValue, michael@0: nsAttrValue& aResult, michael@0: bool aForceInDataDoc); michael@0: michael@0: virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, michael@0: const nsAString& aValue, nsAttrValue& aResult) MOZ_OVERRIDE; michael@0: michael@0: friend class mozilla::dom::Element; michael@0: michael@0: /** michael@0: * Create the style struct from the style attr. Used when an element is michael@0: * first put into a document. Only has an effect if the old value is a michael@0: * string. If aForceInDataDoc is true, will reparse even if we're in a data michael@0: * document. michael@0: */ michael@0: nsresult ReparseStyleAttribute(bool aForceInDataDoc); michael@0: }; michael@0: michael@0: class nsStyledElement : public nsStyledElementNotElementCSSInlineStyle { michael@0: protected: michael@0: inline nsStyledElement(already_AddRefed& aNodeInfo) michael@0: : nsStyledElementNotElementCSSInlineStyle(aNodeInfo) michael@0: {} michael@0: }; michael@0: michael@0: #endif // __NS_STYLEDELEMENT_H_