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/. */
|
|
|
|
|
|
|
|
#include "mozilla/ServoStyleSheet.h"
|
2016-03-02 01:38:13 +03:00
|
|
|
#include "mozilla/StyleBackendType.h"
|
2016-02-24 10:01:11 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
ServoStyleSheet::ServoStyleSheet(CORSMode aCORSMode,
|
|
|
|
net::ReferrerPolicy aReferrerPolicy,
|
|
|
|
const dom::SRIMetadata& aIntegrity)
|
2016-03-02 01:38:13 +03:00
|
|
|
: StyleSheet(StyleBackendType::Servo)
|
|
|
|
, StyleSheetInfo(aCORSMode, aReferrerPolicy, aIntegrity)
|
2016-02-24 10:01:11 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
ServoStyleSheet::~ServoStyleSheet()
|
2016-02-24 10:01:11 +03:00
|
|
|
{
|
2016-02-26 04:51:01 +03:00
|
|
|
DropSheet();
|
2016-02-24 10:01:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ServoStyleSheet::IsApplicable() const
|
|
|
|
{
|
2016-02-26 04:51:01 +03:00
|
|
|
return !mDisabled && mComplete;
|
2016-02-24 10:01:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ServoStyleSheet::HasRules() const
|
|
|
|
{
|
2016-02-26 05:57:42 +03:00
|
|
|
return Servo_StyleSheetHasRules(RawSheet());
|
2016-02-24 10:01:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIDocument*
|
|
|
|
ServoStyleSheet::GetOwningDocument() const
|
|
|
|
{
|
2016-04-27 05:34:49 +03:00
|
|
|
return mDocument;
|
2016-02-24 10:01:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-02-26 04:51:01 +03:00
|
|
|
ServoStyleSheet::SetOwningDocument(nsIDocument* aDocument)
|
2016-02-24 10:01:11 +03:00
|
|
|
{
|
2016-04-27 05:34:49 +03:00
|
|
|
// XXXheycam: Traverse to child ServoStyleSheets to set this, like
|
|
|
|
// CSSStyleSheet::SetOwningDocument does.
|
|
|
|
|
|
|
|
mDocument = aDocument;
|
2016-02-24 10:01:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
StyleSheetHandle
|
|
|
|
ServoStyleSheet::GetParentSheet() const
|
|
|
|
{
|
2016-04-27 05:34:49 +03:00
|
|
|
// XXXheycam: When we implement support for child sheets, we'll have
|
|
|
|
// to fix SetOwningDocument to propagate the owning document down
|
|
|
|
// to the children.
|
2016-02-24 10:01:11 +03:00
|
|
|
MOZ_CRASH("stylo: not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ServoStyleSheet::AppendStyleSheet(StyleSheetHandle aSheet)
|
|
|
|
{
|
2016-04-27 05:34:49 +03:00
|
|
|
// XXXheycam: When we implement support for child sheets, we'll have
|
|
|
|
// to fix SetOwningDocument to propagate the owning document down
|
|
|
|
// to the children.
|
2016-02-24 10:01:11 +03:00
|
|
|
MOZ_CRASH("stylo: not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ServoStyleSheet::ParseSheet(const nsAString& aInput,
|
|
|
|
nsIURI* aSheetURI,
|
|
|
|
nsIURI* aBaseURI,
|
|
|
|
nsIPrincipal* aSheetPrincipal,
|
|
|
|
uint32_t aLineNumber,
|
|
|
|
css::SheetParsingMode aParsingMode)
|
|
|
|
{
|
2016-02-26 04:51:01 +03:00
|
|
|
DropSheet();
|
|
|
|
|
2016-05-21 03:02:54 +03:00
|
|
|
RefPtr<ThreadSafeURIHolder> base = new ThreadSafeURIHolder(aBaseURI);
|
|
|
|
RefPtr<ThreadSafeURIHolder> referrer = new ThreadSafeURIHolder(aSheetURI);
|
|
|
|
RefPtr<ThreadSafePrincipalHolder> principal =
|
|
|
|
new ThreadSafePrincipalHolder(aSheetPrincipal);
|
|
|
|
|
2016-02-26 04:51:01 +03:00
|
|
|
NS_ConvertUTF16toUTF8 input(aInput);
|
|
|
|
mSheet = already_AddRefed<RawServoStyleSheet>(Servo_StylesheetFromUTF8Bytes(
|
2016-05-21 03:02:54 +03:00
|
|
|
reinterpret_cast<const uint8_t*>(input.get()), input.Length(), aParsingMode,
|
|
|
|
base, referrer, principal));
|
2016-02-26 04:51:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ServoStyleSheet::DropSheet()
|
|
|
|
{
|
|
|
|
mSheet = nullptr;
|
2016-02-24 10:01:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ServoStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
|
|
|
{
|
|
|
|
MOZ_CRASH("stylo: not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
ServoStyleSheet::List(FILE* aOut, int32_t aIndex) const
|
|
|
|
{
|
|
|
|
MOZ_CRASH("stylo: not implemented");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace mozilla
|