2016-02-24 10:01:11 +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: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_ServoStyleSheet_h
|
|
|
|
#define mozilla_ServoStyleSheet_h
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
#include "mozilla/dom/SRIMetadata.h"
|
|
|
|
#include "mozilla/RefPtr.h"
|
2016-10-24 12:16:46 +03:00
|
|
|
#include "mozilla/ServoBindingTypes.h"
|
2016-02-26 04:51:01 +03:00
|
|
|
#include "mozilla/StyleSheet.h"
|
|
|
|
#include "mozilla/StyleSheetInfo.h"
|
2017-04-04 06:41:44 +03:00
|
|
|
#include "mozilla/URLExtraData.h"
|
2017-05-14 18:11:18 +03:00
|
|
|
#include "nsCompatibility.h"
|
2016-02-24 10:01:11 +03:00
|
|
|
#include "nsStringFwd.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-11-23 02:26:20 +03:00
|
|
|
class ServoCSSRuleList;
|
|
|
|
|
2016-12-17 12:58:56 +03:00
|
|
|
namespace css {
|
|
|
|
class Loader;
|
|
|
|
}
|
|
|
|
|
2017-02-14 23:05:12 +03:00
|
|
|
// -------------------------------
|
|
|
|
// Servo Style Sheet Inner Data Container
|
|
|
|
//
|
|
|
|
|
|
|
|
struct ServoStyleSheetInner : public StyleSheetInfo
|
|
|
|
{
|
|
|
|
ServoStyleSheetInner(CORSMode aCORSMode,
|
|
|
|
ReferrerPolicy aReferrerPolicy,
|
|
|
|
const dom::SRIMetadata& aIntegrity);
|
|
|
|
|
2017-04-06 05:22:36 +03:00
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
|
|
|
|
|
2017-04-03 09:19:32 +03:00
|
|
|
RefPtr<const RawServoStyleSheet> mSheet;
|
2017-04-04 06:41:44 +03:00
|
|
|
// XXX StyleSheetInfo already has mSheetURI, mBaseURI, and mPrincipal.
|
|
|
|
// Can we somehow replace them with URLExtraData directly? The issue
|
|
|
|
// is currently URLExtraData is immutable, but URIs in StyleSheetInfo
|
|
|
|
// seems to be mutable, so we probably cannot set them altogether.
|
|
|
|
// Also, this is mostly a duplicate reference of the same url data
|
|
|
|
// inside RawServoStyleSheet. We may want to just use that instead.
|
|
|
|
RefPtr<URLExtraData> mURLData;
|
2017-02-14 23:05:12 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-02-24 10:01:11 +03:00
|
|
|
/**
|
|
|
|
* CSS style sheet object that is a wrapper for a Servo Stylesheet.
|
|
|
|
*/
|
2016-02-26 04:51:01 +03:00
|
|
|
class ServoStyleSheet : public StyleSheet
|
2016-02-24 10:01:11 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-08-02 23:12:27 +03:00
|
|
|
ServoStyleSheet(css::SheetParsingMode aParsingMode,
|
|
|
|
CORSMode aCORSMode,
|
2016-02-26 04:51:01 +03:00
|
|
|
net::ReferrerPolicy aReferrerPolicy,
|
|
|
|
const dom::SRIMetadata& aIntegrity);
|
2016-02-24 10:01:11 +03:00
|
|
|
|
2017-01-06 07:14:28 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServoStyleSheet, StyleSheet)
|
|
|
|
|
2016-02-24 10:01:11 +03:00
|
|
|
bool HasRules() const;
|
|
|
|
|
2016-12-17 12:58:56 +03:00
|
|
|
MOZ_MUST_USE nsresult ParseSheet(css::Loader* aLoader,
|
|
|
|
const nsAString& aInput,
|
2016-08-31 13:10:10 +03:00
|
|
|
nsIURI* aSheetURI,
|
|
|
|
nsIURI* aBaseURI,
|
|
|
|
nsIPrincipal* aSheetPrincipal,
|
2017-05-14 18:11:18 +03:00
|
|
|
uint32_t aLineNumber,
|
|
|
|
nsCompatibility aCompatMode);
|
2016-02-24 10:01:11 +03:00
|
|
|
|
2016-10-25 20:15:38 +03:00
|
|
|
/**
|
|
|
|
* Called instead of ParseSheet to initialize the Servo stylesheet object
|
|
|
|
* for a failed load. Either ParseSheet or LoadFailed must be called before
|
|
|
|
* adding a ServoStyleSheet to a ServoStyleSet.
|
|
|
|
*/
|
|
|
|
void LoadFailed();
|
|
|
|
|
2017-04-03 09:19:32 +03:00
|
|
|
const RawServoStyleSheet* RawSheet() const {
|
2017-02-14 23:05:12 +03:00
|
|
|
return Inner()->mSheet;
|
|
|
|
}
|
2017-04-03 09:19:32 +03:00
|
|
|
void SetSheetForImport(const RawServoStyleSheet* aSheet) {
|
2017-02-14 23:05:12 +03:00
|
|
|
MOZ_ASSERT(!Inner()->mSheet);
|
|
|
|
Inner()->mSheet = aSheet;
|
2016-12-17 12:58:56 +03:00
|
|
|
}
|
2016-02-26 05:57:42 +03:00
|
|
|
|
2017-04-04 09:09:20 +03:00
|
|
|
URLExtraData* URLData() const { return Inner()->mURLData; }
|
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
// WebIDL CSSStyleSheet API
|
|
|
|
// Can't be inline because we can't include ImportRule here. And can't be
|
|
|
|
// called GetOwnerRule because that would be ambiguous with the ImportRule
|
|
|
|
// version.
|
2017-01-13 18:41:03 +03:00
|
|
|
css::Rule* GetDOMOwnerRule() const final;
|
2016-10-14 14:25:38 +03:00
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
void WillDirty() {}
|
|
|
|
void DidDirty() {}
|
|
|
|
|
2017-02-13 21:27:46 +03:00
|
|
|
bool IsModified() const final { return false; }
|
|
|
|
|
2017-02-16 00:33:17 +03:00
|
|
|
virtual already_AddRefed<StyleSheet> Clone(StyleSheet* aCloneParent,
|
|
|
|
css::ImportRule* aCloneOwnerRule,
|
|
|
|
nsIDocument* aCloneDocument,
|
|
|
|
nsINode* aCloneOwningNode) const final;
|
|
|
|
|
2017-04-03 12:55:06 +03:00
|
|
|
// nsICSSLoaderObserver interface
|
|
|
|
NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasAlternate,
|
|
|
|
nsresult aStatus) final;
|
|
|
|
|
2016-02-24 10:01:11 +03:00
|
|
|
protected:
|
2016-10-14 14:25:38 +03:00
|
|
|
virtual ~ServoStyleSheet();
|
2016-02-26 04:51:01 +03:00
|
|
|
|
2017-02-14 23:05:12 +03:00
|
|
|
ServoStyleSheetInner* Inner() const
|
|
|
|
{
|
|
|
|
return static_cast<ServoStyleSheetInner*>(mInner);
|
|
|
|
}
|
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
// Internal methods which do not have security check and completeness check.
|
|
|
|
dom::CSSRuleList* GetCssRulesInternal(ErrorResult& aRv);
|
|
|
|
uint32_t InsertRuleInternal(const nsAString& aRule,
|
|
|
|
uint32_t aIndex, ErrorResult& aRv);
|
|
|
|
void DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv);
|
2017-03-08 10:27:53 +03:00
|
|
|
nsresult InsertRuleIntoGroupInternal(const nsAString& aRule,
|
|
|
|
css::GroupRule* aGroup,
|
|
|
|
uint32_t aIndex);
|
2016-10-14 14:25:38 +03:00
|
|
|
|
2017-01-06 10:05:24 +03:00
|
|
|
void EnabledStateChangedInternal() {}
|
|
|
|
|
2017-04-06 05:22:36 +03:00
|
|
|
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
private:
|
2017-02-16 00:33:17 +03:00
|
|
|
ServoStyleSheet(const ServoStyleSheet& aCopy,
|
|
|
|
ServoStyleSheet* aParentToUse,
|
|
|
|
css::ImportRule* aOwnerRuleToUse,
|
|
|
|
nsIDocument* aDocumentToUse,
|
|
|
|
nsINode* aOwningNodeToUse);
|
|
|
|
|
2017-01-06 07:14:28 +03:00
|
|
|
void DropRuleList();
|
2016-02-26 04:51:01 +03:00
|
|
|
|
2016-11-23 02:26:20 +03:00
|
|
|
RefPtr<ServoCSSRuleList> mRuleList;
|
2016-09-29 09:11:52 +03:00
|
|
|
|
|
|
|
friend class StyleSheet;
|
2016-02-24 10:01:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_ServoStyleSheet_h
|