2007-08-06 15:27:19 +00: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 11:12:37 +00: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 15:27:19 +00: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-11 02:48:57 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
|
|
|
class StyleRule;
|
|
|
|
}
|
|
|
|
}
|
2007-08-06 15:27:19 +00:00
|
|
|
|
|
|
|
typedef nsGenericElement nsStyledElementBase;
|
|
|
|
|
2011-04-08 05:27:57 +00:00
|
|
|
class nsStyledElementNotElementCSSInlineStyle : public nsStyledElementBase
|
2007-08-06 15:27:19 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2011-04-08 05:27:57 +00:00
|
|
|
inline nsStyledElementNotElementCSSInlineStyle(already_AddRefed<nsINodeInfo> aNodeInfo)
|
2007-08-06 15:27:19 +00:00
|
|
|
: nsStyledElementBase(aNodeInfo)
|
|
|
|
{}
|
|
|
|
|
|
|
|
public:
|
2010-06-04 01:09:20 +00:00
|
|
|
// nsIContent interface methods
|
2007-08-06 15:27:19 +00:00
|
|
|
virtual nsIAtom* GetClassAttributeName() const;
|
|
|
|
virtual nsIAtom* GetIDAttributeName() const;
|
2010-06-04 01:09:20 +00:00
|
|
|
virtual nsIAtom* DoGetID() const;
|
2008-09-11 03:22:20 +00:00
|
|
|
virtual const nsAttrValue* DoGetClasses() const;
|
2007-08-06 15:27:19 +00:00
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
virtual mozilla::css::StyleRule* GetInlineStyleRule();
|
2012-04-14 13:09:19 +00:00
|
|
|
virtual nsresult SetInlineStyleRule(mozilla::css::StyleRule* aStyleRule,
|
|
|
|
const nsAString* aSerialized,
|
|
|
|
bool aNotify);
|
2007-08-06 15:27:19 +00:00
|
|
|
|
2010-06-04 01:09:20 +00:00
|
|
|
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aNotify);
|
2010-09-03 22:39:29 +00:00
|
|
|
virtual nsresult AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
2012-02-14 02:00:56 +00:00
|
|
|
const nsAttrValue* aValue, bool aNotify);
|
2007-08-06 15:27:19 +00:00
|
|
|
|
2010-08-05 21:59:36 +00:00
|
|
|
nsIDOMCSSStyleDeclaration* GetStyle(nsresult* retval);
|
|
|
|
|
2010-02-24 04:37:46 +00:00
|
|
|
protected:
|
|
|
|
|
2007-08-06 15:27:19 +00: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-24 04:37:46 +00:00
|
|
|
void ParseStyleAttribute(const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aForceInDataDoc);
|
2007-08-06 15:27:19 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute,
|
2007-08-06 15:27:19 +00:00
|
|
|
const nsAString& aValue, nsAttrValue& aResult);
|
|
|
|
|
2012-03-22 04:10:51 +00:00
|
|
|
friend class nsGenericElement;
|
|
|
|
|
2008-02-19 17:52:00 +00: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-29 06:19:26 +00:00
|
|
|
nsresult ReparseStyleAttribute(bool aForceInDataDoc);
|
2007-08-06 15:27:19 +00:00
|
|
|
};
|
|
|
|
|
2011-04-08 05:27:57 +00:00
|
|
|
class nsStyledElement : public nsStyledElementNotElementCSSInlineStyle {
|
|
|
|
protected:
|
|
|
|
inline nsStyledElement(already_AddRefed<nsINodeInfo> aNodeInfo)
|
|
|
|
: nsStyledElementNotElementCSSInlineStyle(aNodeInfo)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2007-08-06 15:27:19 +00:00
|
|
|
#endif // __NS_STYLEDELEMENT_H_
|