2017-10-27 17:33:53 +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: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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 05:47:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* style sheet and style rule processor representing data from presentational
|
|
|
|
* HTML attributes
|
|
|
|
*/
|
|
|
|
|
2004-04-12 21:56:09 +00:00
|
|
|
#ifndef nsHTMLStyleSheet_h_
|
|
|
|
#define nsHTMLStyleSheet_h_
|
|
|
|
|
2013-03-22 00:05:20 +00:00
|
|
|
#include "nsColor.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2017-10-02 22:05:19 +00:00
|
|
|
#include "nsAtom.h"
|
2015-09-16 03:49:53 +00:00
|
|
|
#include "PLDHashTable.h"
|
2012-06-19 03:26:34 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2013-05-30 08:00:20 +00:00
|
|
|
#include "nsString.h"
|
2012-06-19 03:26:34 +00:00
|
|
|
|
2004-04-12 21:56:09 +00:00
|
|
|
class nsMappedAttributes;
|
2017-06-01 18:37:02 +00:00
|
|
|
struct RawServoDeclarationBlock;
|
2019-03-08 21:48:39 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Document;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2004-04-12 21:56:09 +00:00
|
|
|
|
2018-02-01 04:04:04 +00:00
|
|
|
class nsHTMLStyleSheet final {
|
2004-04-12 21:56:09 +00:00
|
|
|
public:
|
2019-01-02 13:05:23 +00:00
|
|
|
explicit nsHTMLStyleSheet(mozilla::dom::Document* aDocument);
|
2004-04-12 21:56:09 +00:00
|
|
|
|
2019-01-02 13:05:23 +00:00
|
|
|
void SetOwningDocument(mozilla::dom::Document* aDocument);
|
2004-04-12 21:56:09 +00:00
|
|
|
|
2018-02-01 04:04:04 +00:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsHTMLStyleSheet)
|
|
|
|
|
2013-06-23 12:03:39 +00:00
|
|
|
size_t DOMSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2004-04-12 21:56:09 +00:00
|
|
|
|
2013-06-14 05:34:37 +00:00
|
|
|
void Reset();
|
2004-04-12 21:56:09 +00:00
|
|
|
nsresult SetLinkColor(nscolor aColor);
|
|
|
|
nsresult SetActiveLinkColor(nscolor aColor);
|
|
|
|
nsresult SetVisitedLinkColor(nscolor aColor);
|
|
|
|
|
2017-06-01 18:37:02 +00:00
|
|
|
const RefPtr<RawServoDeclarationBlock>& GetServoUnvisitedLinkDecl() const {
|
|
|
|
return mServoUnvisitedLinkDecl;
|
|
|
|
}
|
|
|
|
const RefPtr<RawServoDeclarationBlock>& GetServoVisitedLinkDecl() const {
|
|
|
|
return mServoVisitedLinkDecl;
|
|
|
|
}
|
|
|
|
const RefPtr<RawServoDeclarationBlock>& GetServoActiveLinkDecl() const {
|
|
|
|
return mServoActiveLinkDecl;
|
|
|
|
}
|
|
|
|
|
2004-04-12 21:56:09 +00:00
|
|
|
// Mapped Attribute management methods
|
|
|
|
already_AddRefed<nsMappedAttributes> UniqueMappedAttributes(
|
|
|
|
nsMappedAttributes* aMapped);
|
|
|
|
void DropMappedAttributes(nsMappedAttributes* aMapped);
|
2017-01-19 23:56:53 +00:00
|
|
|
// For each mapped presentation attribute in the cache, resolve
|
2018-05-30 16:15:25 +00:00
|
|
|
// the attached DeclarationBlock by running the mapping
|
2017-01-19 23:56:53 +00:00
|
|
|
// and converting the ruledata to Servo specified values.
|
2018-01-05 12:47:04 +00:00
|
|
|
void CalculateMappedServoDeclarations();
|
2004-04-12 21:56:09 +00:00
|
|
|
|
2017-06-16 21:59:08 +00:00
|
|
|
private:
|
2015-01-06 23:35:02 +00:00
|
|
|
nsHTMLStyleSheet(const nsHTMLStyleSheet& aCopy) = delete;
|
|
|
|
nsHTMLStyleSheet& operator=(const nsHTMLStyleSheet& aCopy) = delete;
|
2004-04-12 21:56:09 +00:00
|
|
|
|
2020-03-17 09:38:32 +00:00
|
|
|
~nsHTMLStyleSheet() = default;
|
2004-04-12 21:56:09 +00:00
|
|
|
|
2018-02-01 04:04:04 +00:00
|
|
|
// Implementation of SetLink/VisitedLink/ActiveLinkColor
|
|
|
|
nsresult ImplLinkColorSetter(RefPtr<RawServoDeclarationBlock>& aDecl,
|
|
|
|
nscolor aColor);
|
2013-05-30 08:00:20 +00:00
|
|
|
|
|
|
|
public: // for mLangRuleTable structures only
|
|
|
|
private:
|
2019-01-02 13:05:23 +00:00
|
|
|
mozilla::dom::Document* mDocument;
|
2017-06-01 18:37:02 +00:00
|
|
|
RefPtr<RawServoDeclarationBlock> mServoUnvisitedLinkDecl;
|
|
|
|
RefPtr<RawServoDeclarationBlock> mServoVisitedLinkDecl;
|
|
|
|
RefPtr<RawServoDeclarationBlock> mServoActiveLinkDecl;
|
2004-04-12 21:56:09 +00:00
|
|
|
|
2015-05-19 23:46:17 +00:00
|
|
|
PLDHashTable mMappedAttrTable;
|
2017-01-19 23:56:53 +00:00
|
|
|
// Whether or not the mapped attributes table
|
|
|
|
// has been changed since the last call to
|
|
|
|
// CalculateMappedServoDeclarations()
|
|
|
|
bool mMappedAttrsDirty;
|
2004-04-12 21:56:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !defined(nsHTMLStyleSheet_h_) */
|