2015-05-03 22:32:37 +03: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 15:12:37 +04: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 19:27:19 +04: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-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-08-06 19:27:19 +04:00
|
|
|
#include "nsString.h"
|
2012-11-15 02:10:08 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2007-08-06 19:27:19 +04:00
|
|
|
|
2011-03-11 05:48:57 +03:00
|
|
|
namespace mozilla {
|
2016-10-18 07:29:03 +03:00
|
|
|
class DeclarationBlock;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2007-08-06 19:27:19 +04:00
|
|
|
|
2016-08-02 21:05:38 +03:00
|
|
|
// IID for nsStyledElement interface
|
|
|
|
#define NS_STYLED_ELEMENT_IID \
|
|
|
|
{ 0xacbd9ea6, 0x15aa, 0x4f37, \
|
|
|
|
{ 0x8c, 0xe0, 0x35, 0x1e, 0xd7, 0x21, 0xca, 0xe9 } }
|
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
typedef mozilla::dom::Element nsStyledElementBase;
|
2007-08-06 19:27:19 +04:00
|
|
|
|
2016-08-02 21:05:38 +03:00
|
|
|
class nsStyledElement : public nsStyledElementBase
|
2007-08-06 19:27:19 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2016-08-02 21:05:38 +03:00
|
|
|
inline explicit nsStyledElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2007-08-06 19:27:19 +04:00
|
|
|
: nsStyledElementBase(aNodeInfo)
|
|
|
|
{}
|
|
|
|
|
|
|
|
public:
|
2016-08-02 21:05:38 +03:00
|
|
|
// We don't want to implement AddRef/Release because that would add an extra
|
|
|
|
// function call for those on pretty much all elements. But we do need QI, so
|
|
|
|
// we can QI to nsStyledElement.
|
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
|
|
|
|
2015-11-09 10:57:16 +03:00
|
|
|
// Element interface methods
|
2016-10-18 07:29:03 +03:00
|
|
|
virtual mozilla::DeclarationBlock* GetInlineStyleDeclaration() override;
|
|
|
|
virtual nsresult SetInlineStyleDeclaration(mozilla::DeclarationBlock* aDeclaration,
|
2015-11-09 10:57:16 +03:00
|
|
|
const nsAString* aSerialized,
|
|
|
|
bool aNotify) override;
|
2007-08-06 19:27:19 +04:00
|
|
|
|
2013-01-11 12:42:59 +04:00
|
|
|
nsICSSDeclaration* Style();
|
2010-08-06 01:59:36 +04:00
|
|
|
|
2016-08-02 21:05:38 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_STYLED_ELEMENT_IID)
|
|
|
|
|
2010-02-24 07:37:46 +03:00
|
|
|
protected:
|
|
|
|
|
2016-08-08 13:29:11 +03:00
|
|
|
nsICSSDeclaration* GetExistingStyle();
|
|
|
|
|
2007-08-06 19:27:19 +04: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 07:37:46 +03:00
|
|
|
void ParseStyleAttribute(const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aForceInDataDoc);
|
2007-08-06 19:27:19 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsAString& aValue, nsAttrValue& aResult) override;
|
2007-08-06 19:27:19 +04:00
|
|
|
|
2012-11-15 02:10:07 +04:00
|
|
|
friend class mozilla::dom::Element;
|
2012-03-22 08:10:51 +04:00
|
|
|
|
2008-02-19 20:52:00 +03: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 10:19:26 +04:00
|
|
|
nsresult ReparseStyleAttribute(bool aForceInDataDoc);
|
2007-08-06 19:27:19 +04:00
|
|
|
};
|
|
|
|
|
2016-08-02 21:05:38 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsStyledElement, NS_STYLED_ELEMENT_IID)
|
2007-08-06 19:27:19 +04:00
|
|
|
#endif // __NS_STYLEDELEMENT_H_
|