2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* style sheet and style rule processor representing data from presentational
|
|
|
|
* HTML attributes
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsHTMLStyleSheet_h_
|
|
|
|
#define nsHTMLStyleSheet_h_
|
|
|
|
|
2013-03-21 17:05:20 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsColor.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIStyleRule.h"
|
2013-03-21 17:05:20 -07:00
|
|
|
#include "nsIStyleRuleProcessor.h"
|
|
|
|
#include "nsIStyleSheet.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "pldhash.h"
|
2012-06-18 20:26:34 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsMappedAttributes;
|
|
|
|
|
2012-06-18 20:26:34 -07:00
|
|
|
class nsHTMLStyleSheet MOZ_FINAL : public nsIStyleSheet,
|
|
|
|
public nsIStyleRuleProcessor
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2012-08-04 00:44:01 -07:00
|
|
|
nsHTMLStyleSheet(nsIURI* aURL, nsIDocument* aDocument);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIStyleSheet api
|
2010-05-17 21:00:39 -07:00
|
|
|
virtual nsIURI* GetSheetURI() const;
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsIURI* GetBaseURI() const MOZ_OVERRIDE;
|
|
|
|
virtual void GetTitle(nsString& aTitle) const MOZ_OVERRIDE;
|
|
|
|
virtual void GetType(nsString& aType) const MOZ_OVERRIDE;
|
|
|
|
virtual bool HasRules() const MOZ_OVERRIDE;
|
|
|
|
virtual bool IsApplicable() const MOZ_OVERRIDE;
|
|
|
|
virtual void SetEnabled(bool aEnabled) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsComplete() const MOZ_OVERRIDE;
|
|
|
|
virtual void SetComplete() MOZ_OVERRIDE;
|
|
|
|
virtual nsIStyleSheet* GetParentSheet() const MOZ_OVERRIDE; // will be null
|
|
|
|
virtual nsIDocument* GetOwningDocument() const MOZ_OVERRIDE;
|
|
|
|
virtual void SetOwningDocument(nsIDocument* aDocumemt) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// nsIStyleRuleProcessor API
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void RulesMatching(ElementRuleProcessorData* aData) MOZ_OVERRIDE;
|
|
|
|
virtual void RulesMatching(PseudoElementRuleProcessorData* aData) MOZ_OVERRIDE;
|
|
|
|
virtual void RulesMatching(AnonBoxRuleProcessorData* aData) MOZ_OVERRIDE;
|
2009-12-10 23:37:40 -08:00
|
|
|
#ifdef MOZ_XUL
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void RulesMatching(XULTreeRuleProcessorData* aData) MOZ_OVERRIDE;
|
2009-12-10 23:37:40 -08:00
|
|
|
#endif
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData) MOZ_OVERRIDE;
|
|
|
|
virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData) MOZ_OVERRIDE;
|
2010-03-31 17:43:32 -07:00
|
|
|
virtual nsRestyleHint
|
2012-09-14 09:10:08 -07:00
|
|
|
HasAttributeDependentStyle(AttributeRuleProcessorData* aData) MOZ_OVERRIDE;
|
|
|
|
virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) MOZ_OVERRIDE;
|
2013-03-23 19:14:43 -07:00
|
|
|
virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
|
|
|
const MOZ_MUST_OVERRIDE MOZ_OVERRIDE;
|
|
|
|
virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf)
|
|
|
|
const MOZ_MUST_OVERRIDE MOZ_OVERRIDE;
|
2012-02-01 13:58:01 -08:00
|
|
|
size_t DOMSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-17 21:00:39 -07:00
|
|
|
void Reset(nsIURI* aURL);
|
2007-03-22 10:30:00 -07: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);
|
|
|
|
|
|
|
|
private:
|
2011-12-16 11:42:07 -08:00
|
|
|
nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy) MOZ_DELETE;
|
|
|
|
nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy) MOZ_DELETE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
~nsHTMLStyleSheet();
|
|
|
|
|
|
|
|
class HTMLColorRule;
|
|
|
|
friend class HTMLColorRule;
|
2012-06-18 20:26:34 -07:00
|
|
|
class HTMLColorRule MOZ_FINAL : public nsIStyleRule {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
HTMLColorRule() {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIStyleRule interface
|
2010-05-19 19:28:00 -07:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
nscolor mColor;
|
|
|
|
};
|
|
|
|
|
2010-06-18 09:23:05 -07:00
|
|
|
// Implementation of SetLink/VisitedLink/ActiveLinkColor
|
|
|
|
nsresult ImplLinkColorSetter(nsRefPtr<HTMLColorRule>& aRule, nscolor aColor);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class GenericTableRule;
|
|
|
|
friend class GenericTableRule;
|
2012-06-18 20:26:34 -07:00
|
|
|
class GenericTableRule : public nsIStyleRule {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
GenericTableRule() {}
|
2012-06-18 20:26:34 -07:00
|
|
|
virtual ~GenericTableRule() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIStyleRule interface
|
2011-06-01 04:43:31 -07:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
// this rule handles <th> inheritance
|
|
|
|
class TableTHRule;
|
|
|
|
friend class TableTHRule;
|
2012-06-18 20:26:34 -07:00
|
|
|
class TableTHRule MOZ_FINAL : public GenericTableRule {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
TableTHRule() {}
|
|
|
|
|
2010-05-19 19:28:00 -07:00
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2011-06-01 04:43:31 -07:00
|
|
|
// Rule to handle quirk table colors
|
2012-06-18 20:26:34 -07:00
|
|
|
class TableQuirkColorRule MOZ_FINAL : public GenericTableRule {
|
2011-06-01 04:43:31 -07:00
|
|
|
public:
|
|
|
|
TableQuirkColorRule() {}
|
|
|
|
|
|
|
|
virtual void MapRuleInfoInto(nsRuleData* aRuleData);
|
|
|
|
};
|
|
|
|
|
2010-05-17 21:00:39 -07:00
|
|
|
nsCOMPtr<nsIURI> mURL;
|
|
|
|
nsIDocument* mDocument;
|
|
|
|
nsRefPtr<HTMLColorRule> mLinkRule;
|
|
|
|
nsRefPtr<HTMLColorRule> mVisitedRule;
|
|
|
|
nsRefPtr<HTMLColorRule> mActiveRule;
|
2011-06-01 04:43:31 -07:00
|
|
|
nsRefPtr<TableQuirkColorRule> mTableQuirkColorRule;
|
2010-05-17 21:00:39 -07:00
|
|
|
nsRefPtr<TableTHRule> mTableTHRule;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-17 21:00:39 -07:00
|
|
|
PLDHashTable mMappedAttrTable;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsHTMLStyleSheet_h_) */
|