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/. */
|
|
|
|
|
2016-03-02 01:38:13 +03:00
|
|
|
#include "mozilla/StyleSheet.h"
|
|
|
|
|
2016-03-02 02:10:45 +03:00
|
|
|
#include "mozilla/dom/ShadowRoot.h"
|
2016-03-02 01:38:13 +03:00
|
|
|
#include "mozilla/ServoStyleSheet.h"
|
|
|
|
#include "mozilla/StyleSheetInlines.h"
|
|
|
|
#include "mozilla/CSSStyleSheet.h"
|
2016-02-26 04:51:01 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-03-02 01:38:13 +03:00
|
|
|
StyleSheet::StyleSheet(StyleBackendType aType)
|
2016-03-01 23:39:29 +03:00
|
|
|
: mDocument(nullptr)
|
|
|
|
, mOwningNode(nullptr)
|
2016-02-26 04:51:01 +03:00
|
|
|
, mParsingMode(css::eUserSheetFeatures)
|
2016-03-02 01:38:13 +03:00
|
|
|
, mType(aType)
|
2016-02-26 04:51:01 +03:00
|
|
|
, mDisabled(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
StyleSheet::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-01 23:39:29 +03:00
|
|
|
: mDocument(aDocumentToUse)
|
|
|
|
, mOwningNode(aOwningNodeToUse)
|
2016-02-26 04:51:01 +03:00
|
|
|
, mParsingMode(aCopy.mParsingMode)
|
2016-03-02 01:38:13 +03:00
|
|
|
, mType(aCopy.mType)
|
2016-02-26 04:51:01 +03:00
|
|
|
, mDisabled(aCopy.mDisabled)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-02 02:10:45 +03:00
|
|
|
bool
|
|
|
|
StyleSheet::IsComplete() const
|
|
|
|
{
|
|
|
|
return SheetInfo().mComplete;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StyleSheet::SetComplete()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!IsGecko() || !AsGecko().mDirty, "Can't set a dirty sheet complete!");
|
|
|
|
SheetInfo().mComplete = true;
|
|
|
|
if (mDocument && !mDisabled) {
|
|
|
|
// Let the document know
|
|
|
|
mDocument->BeginUpdate(UPDATE_STYLE);
|
|
|
|
mDocument->SetStyleSheetApplicableState(AsHandle(), true);
|
|
|
|
mDocument->EndUpdate(UPDATE_STYLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mOwningNode && !mDisabled &&
|
|
|
|
mOwningNode->HasFlag(NODE_IS_IN_SHADOW_TREE) &&
|
|
|
|
mOwningNode->IsContent()) {
|
|
|
|
ShadowRoot* shadowRoot = mOwningNode->AsContent()->GetContainingShadow();
|
|
|
|
shadowRoot->StyleSheetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 01:38:13 +03:00
|
|
|
StyleSheetInfo&
|
|
|
|
StyleSheet::SheetInfo()
|
|
|
|
{
|
|
|
|
if (IsServo()) {
|
|
|
|
return AsServo();
|
|
|
|
}
|
|
|
|
return *AsGecko().mInner;
|
|
|
|
}
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
} // namespace mozilla
|