2007-08-06 08:27:19 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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 http://mozilla.org/MPL/2.0/. */
|
2007-08-06 08:27:19 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NS_STYLEDELEMENT_H_
|
|
|
|
#define __NS_STYLEDELEMENT_H_
|
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsGenericElement.h"
|
|
|
|
|
2011-03-10 18:48:57 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
|
|
|
class StyleRule;
|
|
|
|
}
|
|
|
|
}
|
2007-08-06 08:27:19 -07:00
|
|
|
|
|
|
|
typedef nsGenericElement nsStyledElementBase;
|
|
|
|
|
2011-04-07 22:27:57 -07:00
|
|
|
class nsStyledElementNotElementCSSInlineStyle : public nsStyledElementBase
|
2007-08-06 08:27:19 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2011-04-07 22:27:57 -07:00
|
|
|
inline nsStyledElementNotElementCSSInlineStyle(already_AddRefed<nsINodeInfo> aNodeInfo)
|
2007-08-06 08:27:19 -07:00
|
|
|
: nsStyledElementBase(aNodeInfo)
|
|
|
|
{}
|
|
|
|
|
|
|
|
public:
|
2010-06-03 18:09:20 -07:00
|
|
|
// nsIContent interface methods
|
2007-08-06 08:27:19 -07:00
|
|
|
virtual nsIAtom* GetClassAttributeName() const;
|
|
|
|
virtual nsIAtom* GetIDAttributeName() const;
|
2010-06-03 18:09:20 -07:00
|
|
|
virtual nsIAtom* DoGetID() const;
|
2008-09-10 20:22:20 -07:00
|
|
|
virtual const nsAttrValue* DoGetClasses() const;
|
2007-08-06 08:27:19 -07:00
|
|
|
|
2011-03-10 18:48:57 -08:00
|
|
|
virtual mozilla::css::StyleRule* GetInlineStyleRule();
|
2012-04-14 06:09:19 -07:00
|
|
|
virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
|
|
|
|
const nsAString* aSerialized,
|
|
|
|
bool aNotify);
|
2007-08-06 08:27:19 -07:00
|
|
|
|
2010-06-03 18:09:20 -07:00
|
|
|
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aNotify);
|
2010-09-03 15:39:29 -07:00
|
|
|
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
2012-02-13 18:00:56 -08:00
|
|
|
const nsAttrValue* aValue, bool aNotify);
|
2007-08-06 08:27:19 -07:00
|
|
|
|
2010-08-05 14:59:36 -07:00
|
|
|
nsIDOMCSSStyleDeclaration* GetStyle(nsresult* retval);
|
|
|
|
|
2010-02-23 20:37:46 -08:00
|
|
|
protected:
|
|
|
|
|
2007-08-06 08:27:19 -07:00
|
|
|
/**
|
|
|
|
* 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 aResult the resulting HTMLValue [OUT]
|
|
|
|
*/
|
2010-02-23 20:37:46 -08:00
|
|
|
void ParseStyleAttribute(const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aForceInDataDoc);
|
2007-08-06 08:27:19 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
2007-08-06 08:27:19 -07:00
|
|
|
const nsAString& aValue, nsAttrValue& aResult);
|
|
|
|
|
2012-03-21 21:10:51 -07:00
|
|
|
friend class nsGenericElement;
|
|
|
|
|
2008-02-19 09:52:00 -08:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult ReparseStyleAttribute(bool aForceInDataDoc);
|
2007-08-06 08:27:19 -07:00
|
|
|
};
|
|
|
|
|
2011-04-07 22:27:57 -07:00
|
|
|
class nsStyledElement : public nsStyledElementNotElementCSSInlineStyle {
|
|
|
|
protected:
|
|
|
|
inline nsStyledElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
|
|
|
: nsStyledElementNotElementCSSInlineStyle(aNodeInfo)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2007-08-06 08:27:19 -07:00
|
|
|
#endif // __NS_STYLEDELEMENT_H_
|