зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1451289 - Part 10: Merge ServoImportRule and CSSImportRule r=emilio
MozReview-Commit-ID: JvHNGoX4AUF --HG-- extra : rebase_source : 3d30ee1278f035bd480c05ec0d8f35d4a31cf3c7
This commit is contained in:
Родитель
57afced2fc
Коммит
60852e7cad
|
@ -7,11 +7,11 @@
|
|||
#include "mozilla/ServoStyleRuleMap.h"
|
||||
|
||||
#include "mozilla/css/GroupRule.h"
|
||||
#include "mozilla/dom/CSSImportRule.h"
|
||||
#include "mozilla/dom/CSSRuleBinding.h"
|
||||
#include "mozilla/dom/CSSStyleRule.h"
|
||||
#include "mozilla/IntegerRange.h"
|
||||
#include "mozilla/ServoStyleSet.h"
|
||||
#include "mozilla/ServoImportRule.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "nsDocument.h"
|
||||
#include "nsStyleSheetService.h"
|
||||
|
@ -143,7 +143,7 @@ ServoStyleRuleMap::FillTableFromRule(css::Rule& aRule)
|
|||
break;
|
||||
}
|
||||
case CSSRuleBinding::IMPORT_RULE: {
|
||||
auto& rule = static_cast<ServoImportRule&>(aRule);
|
||||
auto& rule = static_cast<CSSImportRule&>(aRule);
|
||||
MOZ_ASSERT(aRule.GetStyleSheet());
|
||||
FillTableFromStyleSheet(*rule.GetStyleSheet());
|
||||
break;
|
||||
|
|
|
@ -8,10 +8,99 @@
|
|||
|
||||
#include "mozilla/dom/CSSImportRuleBinding.h"
|
||||
#include "mozilla/dom/MediaList.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
CSSImportRule::CSSImportRule(RefPtr<RawServoImportRule> aRawRule,
|
||||
uint32_t aLine,
|
||||
uint32_t aColumn)
|
||||
: Rule(aLine, aColumn)
|
||||
, mRawRule(std::move(aRawRule))
|
||||
{
|
||||
const auto* sheet = Servo_ImportRule_GetSheet(mRawRule.get());
|
||||
MOZ_ASSERT(sheet);
|
||||
mChildSheet = const_cast<StyleSheet*>(sheet);
|
||||
mChildSheet->SetOwnerRule(this);
|
||||
}
|
||||
|
||||
CSSImportRule::~CSSImportRule()
|
||||
{
|
||||
if (mChildSheet) {
|
||||
mChildSheet->SetOwnerRule(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
// QueryInterface implementation for CSSImportRule
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSImportRule)
|
||||
NS_INTERFACE_MAP_END_INHERITING(css::Rule)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(CSSImportRule)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(CSSImportRule, css::Rule)
|
||||
NS_IMPL_RELEASE_INHERITED(CSSImportRule, css::Rule)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CSSImportRule,
|
||||
css::Rule)
|
||||
// Note the child sheet twice, since the Servo rule also holds a strong
|
||||
// reference to it.
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mChildSheet");
|
||||
cb.NoteXPCOMChild(tmp->mChildSheet);
|
||||
MOZ_ASSERT_IF(tmp->mRawRule,
|
||||
Servo_ImportRule_GetSheet(tmp->mRawRule) == tmp->mChildSheet);
|
||||
cb.NoteXPCOMChild(tmp->mChildSheet);
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRawRule.stylesheet");
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CSSImportRule)
|
||||
if (tmp->mChildSheet) {
|
||||
tmp->mChildSheet->SetOwnerRule(nullptr);
|
||||
tmp->mChildSheet = nullptr;
|
||||
}
|
||||
tmp->mRawRule = nullptr;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(css::Rule)
|
||||
|
||||
#ifdef DEBUG
|
||||
/* virtual */ void
|
||||
CSSImportRule::List(FILE* out, int32_t aIndent) const
|
||||
{
|
||||
nsAutoCString str;
|
||||
for (int32_t i = 0; i < aIndent; i++) {
|
||||
str.AppendLiteral(" ");
|
||||
}
|
||||
Servo_ImportRule_Debug(mRawRule, &str);
|
||||
fprintf_stderr(out, "%s\n", str.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
dom::MediaList*
|
||||
CSSImportRule::GetMedia() const
|
||||
{
|
||||
// When Bug 1326509 is fixed, we can assert mChildSheet instead.
|
||||
return mChildSheet ? mChildSheet->Media() : nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
CSSImportRule::GetHref(nsAString& aHref) const
|
||||
{
|
||||
Servo_ImportRule_GetHref(mRawRule, &aHref);
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
CSSImportRule::GetCssText(nsAString& aCssText) const
|
||||
{
|
||||
Servo_ImportRule_GetCssText(mRawRule, &aCssText);
|
||||
}
|
||||
|
||||
/* virtual */ size_t
|
||||
CSSImportRule::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
// TODO Implement this!
|
||||
return aMallocSizeOf(this);
|
||||
}
|
||||
|
||||
bool
|
||||
CSSImportRule::IsCCLeaf() const
|
||||
{
|
||||
|
|
|
@ -10,28 +10,44 @@
|
|||
#include "mozilla/css/Rule.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class StyleSheet;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class CSSImportRule : public css::Rule
|
||||
class CSSImportRule final : public css::Rule
|
||||
{
|
||||
protected:
|
||||
using Rule::Rule;
|
||||
virtual ~CSSImportRule() {}
|
||||
|
||||
public:
|
||||
CSSImportRule(RefPtr<RawServoImportRule> aRawRule,
|
||||
uint32_t aLine, uint32_t aColumn);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CSSImportRule, css::Rule)
|
||||
|
||||
bool IsCCLeaf() const final;
|
||||
|
||||
#ifdef DEBUG
|
||||
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
|
||||
#endif
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
||||
const override = 0;
|
||||
const override;
|
||||
|
||||
// WebIDL interface
|
||||
uint16_t Type() const final { return CSSRuleBinding::IMPORT_RULE; }
|
||||
virtual void GetHref(nsAString& aHref) const = 0;
|
||||
virtual dom::MediaList* GetMedia() const = 0;
|
||||
virtual StyleSheet* GetStyleSheet() const = 0;
|
||||
void GetCssText(nsAString& aCssText) const override;
|
||||
void GetHref(nsAString& aHref) const;
|
||||
dom::MediaList* GetMedia() const;
|
||||
StyleSheet* GetStyleSheet() const { return mChildSheet; }
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
private:
|
||||
~CSSImportRule();
|
||||
|
||||
RefPtr<RawServoImportRule> mRawRule;
|
||||
RefPtr<StyleSheet> mChildSheet;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "mozilla/dom/CSSCounterStyleRule.h"
|
||||
#include "mozilla/dom/CSSFontFaceRule.h"
|
||||
#include "mozilla/dom/CSSImportRule.h"
|
||||
#include "mozilla/dom/CSSKeyframesRule.h"
|
||||
#include "mozilla/dom/CSSMediaRule.h"
|
||||
#include "mozilla/dom/CSSMozDocumentRule.h"
|
||||
|
@ -19,7 +20,6 @@
|
|||
#include "mozilla/dom/CSSSupportsRule.h"
|
||||
#include "mozilla/IntegerRange.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/ServoImportRule.h"
|
||||
#include "mozilla/ServoFontFeatureValuesRule.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
|
||||
|
@ -111,7 +111,7 @@ ServoCSSRuleList::GetRule(uint32_t aIndex)
|
|||
CASE_RULE_CSS(PAGE, Page)
|
||||
CASE_RULE_CSS(SUPPORTS, Supports)
|
||||
CASE_RULE_CSS(DOCUMENT, MozDocument)
|
||||
CASE_RULE(IMPORT, Import)
|
||||
CASE_RULE_CSS(IMPORT, Import)
|
||||
CASE_RULE(FONT_FEATURE_VALUES, FontFeatureValues)
|
||||
CASE_RULE_CSS(FONT_FACE, FontFace)
|
||||
CASE_RULE_CSS(COUNTER_STYLE, CounterStyle)
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
/* representation of CSSImportRule for stylo */
|
||||
|
||||
#include "mozilla/ServoImportRule.h"
|
||||
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
ServoImportRule::ServoImportRule(RefPtr<RawServoImportRule> aRawRule,
|
||||
uint32_t aLine,
|
||||
uint32_t aColumn)
|
||||
: CSSImportRule(aLine, aColumn)
|
||||
, mRawRule(std::move(aRawRule))
|
||||
{
|
||||
const auto* sheet = Servo_ImportRule_GetSheet(mRawRule.get());
|
||||
MOZ_ASSERT(sheet);
|
||||
mChildSheet = const_cast<StyleSheet*>(sheet);
|
||||
mChildSheet->SetOwnerRule(this);
|
||||
}
|
||||
|
||||
ServoImportRule::~ServoImportRule()
|
||||
{
|
||||
if (mChildSheet) {
|
||||
mChildSheet->SetOwnerRule(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
// QueryInterface implementation for ServoImportRule
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServoImportRule)
|
||||
NS_INTERFACE_MAP_END_INHERITING(dom::CSSImportRule)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(ServoImportRule)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(ServoImportRule, dom::CSSImportRule)
|
||||
NS_IMPL_RELEASE_INHERITED(ServoImportRule, dom::CSSImportRule)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServoImportRule,
|
||||
dom::CSSImportRule)
|
||||
// Note the child sheet twice, since the Servo rule also holds a strong
|
||||
// reference to it.
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mChildSheet");
|
||||
cb.NoteXPCOMChild(tmp->mChildSheet);
|
||||
MOZ_ASSERT_IF(tmp->mRawRule,
|
||||
Servo_ImportRule_GetSheet(tmp->mRawRule) == tmp->mChildSheet);
|
||||
cb.NoteXPCOMChild(tmp->mChildSheet);
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRawRule.stylesheet");
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ServoImportRule)
|
||||
if (tmp->mChildSheet) {
|
||||
tmp->mChildSheet->SetOwnerRule(nullptr);
|
||||
tmp->mChildSheet = nullptr;
|
||||
}
|
||||
tmp->mRawRule = nullptr;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(dom::CSSImportRule)
|
||||
|
||||
#ifdef DEBUG
|
||||
/* virtual */ void
|
||||
ServoImportRule::List(FILE* out, int32_t aIndent) const
|
||||
{
|
||||
nsAutoCString str;
|
||||
for (int32_t i = 0; i < aIndent; i++) {
|
||||
str.AppendLiteral(" ");
|
||||
}
|
||||
Servo_ImportRule_Debug(mRawRule, &str);
|
||||
fprintf_stderr(out, "%s\n", str.get());
|
||||
}
|
||||
#endif
|
||||
|
||||
dom::MediaList*
|
||||
ServoImportRule::GetMedia() const
|
||||
{
|
||||
// When Bug 1326509 is fixed, we can assert mChildSheet instead.
|
||||
return mChildSheet ? mChildSheet->Media() : nullptr;
|
||||
}
|
||||
|
||||
StyleSheet*
|
||||
ServoImportRule::GetStyleSheet() const
|
||||
{
|
||||
return mChildSheet;
|
||||
}
|
||||
|
||||
void
|
||||
ServoImportRule::GetHref(nsAString& aHref) const
|
||||
{
|
||||
Servo_ImportRule_GetHref(mRawRule, &aHref);
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
ServoImportRule::GetCssText(nsAString& aCssText) const
|
||||
{
|
||||
Servo_ImportRule_GetCssText(mRawRule, &aCssText);
|
||||
}
|
||||
|
||||
/* virtual */ size_t
|
||||
ServoImportRule::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
// TODO Implement this!
|
||||
return aMallocSizeOf(this);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -1,49 +0,0 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
/* representation of CSSImportRule for stylo */
|
||||
|
||||
#ifndef mozilla_ServoImportRule_h
|
||||
#define mozilla_ServoImportRule_h
|
||||
|
||||
#include "mozilla/dom/CSSImportRule.h"
|
||||
#include "mozilla/ServoBindingTypes.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ServoMediaList;
|
||||
class StyleSheet;
|
||||
|
||||
class ServoImportRule final : public dom::CSSImportRule
|
||||
{
|
||||
public:
|
||||
ServoImportRule(RefPtr<RawServoImportRule> aRawRule,
|
||||
uint32_t aLine, uint32_t aColumn);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServoImportRule, dom::CSSImportRule)
|
||||
|
||||
#ifdef DEBUG
|
||||
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
|
||||
#endif
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final;
|
||||
|
||||
// WebIDL interface
|
||||
void GetCssText(nsAString& aCssText) const override;
|
||||
void GetHref(nsAString& aHref) const final;
|
||||
dom::MediaList* GetMedia() const final;
|
||||
StyleSheet* GetStyleSheet() const final;
|
||||
|
||||
private:
|
||||
~ServoImportRule();
|
||||
|
||||
RefPtr<RawServoImportRule> mRawRule;
|
||||
RefPtr<StyleSheet> mChildSheet;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_ServoImportRule_h
|
|
@ -87,7 +87,6 @@ EXPORTS.mozilla += [
|
|||
'ServoElementSnapshot.h',
|
||||
'ServoElementSnapshotTable.h',
|
||||
'ServoFontFeatureValuesRule.h',
|
||||
'ServoImportRule.h',
|
||||
'ServoSpecifiedValues.h',
|
||||
'ServoStyleSet.h',
|
||||
'ServoStyleSetInlines.h',
|
||||
|
@ -203,7 +202,6 @@ UNIFIED_SOURCES += [
|
|||
'ServoCSSRuleList.cpp',
|
||||
'ServoElementSnapshot.cpp',
|
||||
'ServoFontFeatureValuesRule.cpp',
|
||||
'ServoImportRule.cpp',
|
||||
'ServoSpecifiedValues.cpp',
|
||||
'ServoStyleSet.cpp',
|
||||
'StreamLoader.cpp',
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nsIWidget.h"
|
||||
#include "nsThemeConstants.h" // For system widget appearance types
|
||||
|
||||
#include "mozilla/dom/Animation.h"
|
||||
#include "mozilla/dom/AnimationEffectBinding.h" // for PlaybackDirection
|
||||
#include "mozilla/LookAndFeel.h" // for system colors
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
class nsROCSSPrimitiveValue;
|
||||
|
||||
class nsDOMCSSRect final : public RefCounted<nsDOMCSSRect>
|
||||
class nsDOMCSSRect final : public mozilla::RefCounted<nsDOMCSSRect>
|
||||
{
|
||||
public:
|
||||
MOZ_DECLARE_REFCOUNTED_TYPENAME(nsDOMCSSRect);
|
||||
|
|
Загрузка…
Ссылка в новой задаче