2004-04-13 01:56:09 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
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/. */
|
2006-03-25 08:47:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* style sheet and style rule processor representing data from presentational
|
|
|
|
* HTML attributes
|
|
|
|
*/
|
|
|
|
|
2004-04-13 01:56:09 +04:00
|
|
|
#ifndef nsHTMLStyleSheet_h_
|
|
|
|
#define nsHTMLStyleSheet_h_
|
|
|
|
|
2013-03-22 04:05:20 +04:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsColor.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2004-04-13 01:56:09 +04:00
|
|
|
#include "nsIStyleRule.h"
|
2013-03-22 04:05:20 +04:00
|
|
|
#include "nsIStyleRuleProcessor.h"
|
2004-04-13 01:56:09 +04:00
|
|
|
#include "pldhash.h"
|
2012-06-19 07:26:34 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2013-05-30 12:00:20 +04:00
|
|
|
#include "nsString.h"
|
2012-06-19 07:26:34 +04:00
|
|
|
|
2013-09-16 05:06:52 +04:00
|
|
|
class nsIDocument;
|
2004-04-13 01:56:09 +04:00
|
|
|
class nsMappedAttributes;
|
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
class nsHTMLStyleSheet MOZ_FINAL : public nsIStyleRuleProcessor
|
2012-06-19 07:26:34 +04:00
|
|
|
{
|
2004-04-13 01:56:09 +04:00
|
|
|
public:
|
2013-06-14 09:34:37 +04:00
|
|
|
nsHTMLStyleSheet(nsIDocument* aDocument);
|
2004-04-13 01:56:09 +04:00
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
void SetOwningDocument(nsIDocument* aDocument);
|
2004-04-13 01:56:09 +04:00
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
2004-04-13 01:56:09 +04:00
|
|
|
|
|
|
|
// nsIStyleRuleProcessor API
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual void RulesMatching(ElementRuleProcessorData* aData) MOZ_OVERRIDE;
|
|
|
|
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) MOZ_OVERRIDE;
|
|
|
|
virtual void RulesMatching(AnonBoxRuleProcessorData* aData) MOZ_OVERRIDE;
|
2009-12-11 10:37:40 +03:00
|
|
|
#ifdef MOZ_XUL
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual void RulesMatching(XULTreeRuleProcessorData* aData) MOZ_OVERRIDE;
|
2009-12-11 10:37:40 +03:00
|
|
|
#endif
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData) MOZ_OVERRIDE;
|
|
|
|
virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) MOZ_OVERRIDE;
|
2010-04-01 04:43:32 +04:00
|
|
|
virtual nsRestyleHint
|
2012-09-14 20:10:08 +04:00
|
|
|
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) MOZ_OVERRIDE;
|
|
|
|
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) MOZ_OVERRIDE;
|
2013-06-23 16:03:39 +04:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
2013-03-24 06:14:43 +04:00
|
|
|
const MOZ_MUST_OVERRIDE MOZ_OVERRIDE;
|
2013-06-23 16:03:39 +04:00
|
|
|
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
2013-03-24 06:14:43 +04:00
|
|
|
const MOZ_MUST_OVERRIDE MOZ_OVERRIDE;
|
2013-06-23 16:03:39 +04:00
|
|
|
size_t DOMSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2004-04-13 01:56:09 +04:00
|
|
|
|
2013-06-14 09:34:37 +04:00
|
|
|
void Reset();
|
2004-04-13 01:56:09 +04:00
|
|
|
nsresult SetLinkColor(nscolor aColor);
|
|
|
|
nsresult SetActiveLinkColor(nscolor aColor);
|
|
|
|
nsresult SetVisitedLinkColor(nscolor aColor);
|
|
|
|
|
|
|
|
// Mapped Attribute management methods
|
|
|
|
already_AddRefed<nsMappedAttributes>
|
|
|
|
UniqueMappedAttributes(nsMappedAttributes* aMapped);
|
|
|
|
void DropMappedAttributes(nsMappedAttributes* aMapped);
|
|
|
|
|
2013-05-30 12:00:20 +04:00
|
|
|
nsIStyleRule* LangRuleFor(const nsString& aLanguage);
|
|
|
|
|
2004-04-13 01:56:09 +04:00
|
|
|
private:
|
2011-12-16 23:42:07 +04:00
|
|
|
nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy) MOZ_DELETE;
|
|
|
|
nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy) MOZ_DELETE;
|
2004-04-13 01:56:09 +04:00
|
|
|
|
|
|
|
~nsHTMLStyleSheet();
|
|
|
|
|
|
|
|
class HTMLColorRule;
|
|
|
|
friend class HTMLColorRule;
|
2012-06-19 07:26:34 +04:00
|
|
|
class HTMLColorRule MOZ_FINAL : public nsIStyleRule {
|
2004-04-13 01:56:09 +04:00
|
|
|
public:
|
2004-10-31 20:33:50 +03:00
|
|
|
HTMLColorRule() {}
|
2004-04-13 01:56:09 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2004-10-31 20:33:50 +03:00
|
|
|
// nsIStyleRule interface
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
|
2004-04-13 01:56:09 +04:00
|
|
|
#ifdef DEBUG
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
2004-04-13 01:56:09 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
nscolor mColor;
|
|
|
|
};
|
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
// Implementation of SetLink/VisitedLink/ActiveLinkColor
|
|
|
|
nsresult ImplLinkColorSetter(nsRefPtr<HTMLColorRule>& aRule, nscolor aColor);
|
2006-05-14 17:34:32 +04:00
|
|
|
|
2004-04-13 01:56:09 +04:00
|
|
|
class GenericTableRule;
|
|
|
|
friend class GenericTableRule;
|
2012-06-19 07:26:34 +04:00
|
|
|
class GenericTableRule : public nsIStyleRule {
|
2004-04-13 01:56:09 +04:00
|
|
|
public:
|
2004-10-31 20:33:50 +03:00
|
|
|
GenericTableRule() {}
|
2012-06-19 07:26:34 +04:00
|
|
|
virtual ~GenericTableRule() {}
|
2004-04-13 01:56:09 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2004-10-31 20:33:50 +03:00
|
|
|
// nsIStyleRule interface
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE = 0;
|
2004-04-13 01:56:09 +04:00
|
|
|
#ifdef DEBUG
|
2012-09-14 20:10:08 +04:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
2004-04-13 01:56:09 +04:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
// this rule handles <th> inheritance
|
|
|
|
class TableTHRule;
|
|
|
|
friend class TableTHRule;
|
2012-06-19 07:26:34 +04:00
|
|
|
class TableTHRule MOZ_FINAL : public GenericTableRule {
|
2004-04-13 01:56:09 +04:00
|
|
|
public:
|
2004-10-31 20:33:50 +03:00
|
|
|
TableTHRule() {}
|
2004-04-13 01:56:09 +04:00
|
|
|
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
|
2004-04-13 01:56:09 +04:00
|
|
|
};
|
|
|
|
|
2011-06-01 15:43:31 +04:00
|
|
|
// Rule to handle quirk table colors
|
2012-06-19 07:26:34 +04:00
|
|
|
class TableQuirkColorRule MOZ_FINAL : public GenericTableRule {
|
2011-06-01 15:43:31 +04:00
|
|
|
public:
|
|
|
|
TableQuirkColorRule() {}
|
|
|
|
|
2013-05-14 20:33:23 +04:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
|
2011-06-01 15:43:31 +04:00
|
|
|
};
|
|
|
|
|
2013-05-30 12:00:20 +04:00
|
|
|
public: // for mLangRuleTable structures only
|
|
|
|
|
|
|
|
// Rule to handle xml:lang attributes, of which we have exactly one
|
|
|
|
// per language string, maintained in mLangRuleTable.
|
|
|
|
class LangRule MOZ_FINAL : public nsIStyleRule {
|
|
|
|
public:
|
|
|
|
LangRule(const nsSubstring& aLang) : mLang(aLang) {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIStyleRule interface
|
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) MOZ_OVERRIDE;
|
|
|
|
#ifdef DEBUG
|
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsString mLang;
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2010-05-18 08:00:39 +04:00
|
|
|
nsIDocument* mDocument;
|
|
|
|
nsRefPtr<HTMLColorRule> mLinkRule;
|
|
|
|
nsRefPtr<HTMLColorRule> mVisitedRule;
|
|
|
|
nsRefPtr<HTMLColorRule> mActiveRule;
|
2011-06-01 15:43:31 +04:00
|
|
|
nsRefPtr<TableQuirkColorRule> mTableQuirkColorRule;
|
2010-05-18 08:00:39 +04:00
|
|
|
nsRefPtr<TableTHRule> mTableTHRule;
|
2004-04-13 01:56:09 +04:00
|
|
|
|
2010-05-18 08:00:39 +04:00
|
|
|
PLDHashTable mMappedAttrTable;
|
2013-05-30 12:00:20 +04:00
|
|
|
PLDHashTable mLangRuleTable;
|
2004-04-13 01:56:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsHTMLStyleSheet_h_) */
|