2016-02-26 04:51:01 +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_StyleSheet_h
|
|
|
|
#define mozilla_StyleSheet_h
|
|
|
|
|
|
|
|
#include "mozilla/css/SheetParsingMode.h"
|
2016-03-02 01:38:13 +03:00
|
|
|
#include "mozilla/StyleBackendType.h"
|
2016-03-02 02:10:45 +03:00
|
|
|
#include "mozilla/StyleSheetHandle.h"
|
2016-03-02 01:38:13 +03:00
|
|
|
#include "mozilla/StyleSheetInfo.h"
|
2016-02-26 04:51:01 +03:00
|
|
|
|
2016-03-01 23:39:29 +03:00
|
|
|
class nsIDocument;
|
2016-02-26 04:51:01 +03:00
|
|
|
class nsINode;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-03-02 01:38:13 +03:00
|
|
|
class CSSStyleSheet;
|
|
|
|
class ServoStyleSheet;
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
/**
|
|
|
|
* Superclass for data common to CSSStyleSheet and ServoStyleSheet.
|
|
|
|
*/
|
|
|
|
class StyleSheet
|
|
|
|
{
|
2016-03-02 01:38:13 +03:00
|
|
|
protected:
|
|
|
|
explicit StyleSheet(StyleBackendType aType);
|
2016-02-26 04:51:01 +03:00
|
|
|
StyleSheet(const StyleSheet& aCopy,
|
2016-03-01 23:39:29 +03:00
|
|
|
nsIDocument* aDocumentToUse,
|
2016-02-26 04:51:01 +03:00
|
|
|
nsINode* aOwningNodeToUse);
|
|
|
|
|
2016-03-02 01:38:13 +03:00
|
|
|
public:
|
2016-02-26 04:51:01 +03:00
|
|
|
void SetOwningNode(nsINode* aOwningNode)
|
|
|
|
{
|
|
|
|
mOwningNode = aOwningNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetParsingMode(css::SheetParsingMode aParsingMode)
|
|
|
|
{
|
|
|
|
mParsingMode = aParsingMode;
|
|
|
|
}
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
nsINode* GetOwnerNode() const { return mOwningNode; }
|
|
|
|
|
2016-03-01 23:39:29 +03:00
|
|
|
// The document this style sheet is associated with. May be null
|
|
|
|
nsIDocument* GetDocument() const { return mDocument; }
|
|
|
|
|
2016-03-02 02:10:45 +03:00
|
|
|
/**
|
|
|
|
* Whether the sheet is complete.
|
|
|
|
*/
|
|
|
|
bool IsComplete() const;
|
|
|
|
void SetComplete();
|
|
|
|
|
2016-03-02 01:38:13 +03:00
|
|
|
// Get a handle to the various stylesheet bits which live on the 'inner' for
|
|
|
|
// gecko stylesheets and live on the StyleSheet for Servo stylesheets.
|
|
|
|
StyleSheetInfo& SheetInfo();
|
|
|
|
const StyleSheetInfo& SheetInfo() const { return const_cast<StyleSheet*>(this)->SheetInfo(); };
|
|
|
|
|
|
|
|
bool IsGecko() const { return !IsServo(); }
|
|
|
|
bool IsServo() const
|
|
|
|
{
|
|
|
|
#ifdef MOZ_STYLO
|
|
|
|
return mType == StyleBackendType::Servo;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only safe to call if the caller has verified that that |this| is of the
|
|
|
|
// correct type.
|
|
|
|
inline CSSStyleSheet& AsGecko();
|
|
|
|
inline ServoStyleSheet& AsServo();
|
2016-03-02 02:10:45 +03:00
|
|
|
inline StyleSheetHandle AsHandle();
|
2016-03-02 01:38:13 +03:00
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
protected:
|
2016-03-01 23:39:29 +03:00
|
|
|
nsIDocument* mDocument; // weak ref; parents maintain this for their children
|
2016-02-26 04:51:01 +03:00
|
|
|
nsINode* mOwningNode; // weak ref
|
|
|
|
css::SheetParsingMode mParsingMode;
|
2016-03-02 01:38:13 +03:00
|
|
|
StyleBackendType mType;
|
2016-02-26 04:51:01 +03:00
|
|
|
bool mDisabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_StyleSheet_h
|