2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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_
|
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-08-06 15:27:19 +00:00
|
|
|
#include "nsString.h"
|
2012-11-14 22:10:08 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
2007-08-06 15:27:19 +00:00
|
|
|
|
2011-03-11 02:48:57 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace css {
|
2015-11-09 07:57:16 +00:00
|
|
|
class Declaration;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace css
|
|
|
|
} // namespace mozilla
|
2007-08-06 15:27:19 +00:00
|
|
|
|
2012-11-14 22:10:08 +00:00
|
|
|
typedef mozilla::dom::Element nsStyledElementBase;
|
2007-08-06 15:27:19 +00:00
|
|
|
|
2011-04-08 05:27:57 +00:00
|
|
|
class nsStyledElementNotElementCSSInlineStyle : public nsStyledElementBase
|
2007-08-06 15:27:19 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2014-08-05 13:19:51 +00:00
|
|
|
inline explicit nsStyledElementNotElementCSSInlineStyle(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2007-08-06 15:27:19 +00:00
|
|
|
: nsStyledElementBase(aNodeInfo)
|
|
|
|
{}
|
|
|
|
|
|
|
|
public:
|
2015-11-09 07:57:16 +00:00
|
|
|
// Element interface methods
|
|
|
|
virtual mozilla::css::Declaration* GetInlineStyleDeclaration() override;
|
|
|
|
virtual nsresult SetInlineStyleDeclaration(mozilla::css::Declaration* aDeclaration,
|
|
|
|
const nsAString* aSerialized,
|
|
|
|
bool aNotify) override;
|
2007-08-06 15:27:19 +00:00
|
|
|
|
2013-01-11 08:42:59 +00:00
|
|
|
nsICSSDeclaration* Style();
|
2010-08-05 21:59:36 +00:00
|
|
|
|
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
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsAString& aValue, nsAttrValue& aResult) override;
|
2007-08-06 15:27:19 +00:00
|
|
|
|
2012-11-14 22:10:07 +00:00
|
|
|
friend class mozilla::dom::Element;
|
2012-03-22 04:10:51 +00:00
|
|
|
|
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:
|
2014-08-05 13:19:51 +00:00
|
|
|
inline explicit nsStyledElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2011-04-08 05:27:57 +00:00
|
|
|
: nsStyledElementNotElementCSSInlineStyle(aNodeInfo)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2007-08-06 15:27:19 +00:00
|
|
|
#endif // __NS_STYLEDELEMENT_H_
|