Bug 1451289 - Part 1: Merge ServoNamespaceRule and css::CSSNamespaceRule r=emilio

MozReview-Commit-ID: D5kU7f0hluL

--HG--
rename : layout/style/ServoNamespaceRule.cpp => layout/style/CSSNamespaceRule.cpp
extra : rebase_source : 9fd5cb862b6f606b056e935c75655415f40c9b64
This commit is contained in:
Nazım Can Altınova 2018-06-01 12:35:39 +02:00
Родитель 13565e21f4
Коммит 6cdcd1d100
6 изменённых файлов: 47 добавлений и 66 удалений

Просмотреть файл

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ServoNamespaceRule.h" #include "mozilla/dom/CSSNamespaceRule.h"
#include "mozilla/ServoBindings.h" #include "mozilla/ServoBindings.h"
@ -12,13 +12,13 @@ using namespace mozilla::dom;
namespace mozilla { namespace mozilla {
ServoNamespaceRule::~ServoNamespaceRule() CSSNamespaceRule::~CSSNamespaceRule()
{ {
} }
#ifdef DEBUG #ifdef DEBUG
void void
ServoNamespaceRule::List(FILE* out, int32_t aIndent) const CSSNamespaceRule::List(FILE* out, int32_t aIndent) const
{ {
nsAutoCString str; nsAutoCString str;
for (int32_t i = 0; i < aIndent; i++) { for (int32_t i = 0; i < aIndent; i++) {
@ -30,26 +30,26 @@ ServoNamespaceRule::List(FILE* out, int32_t aIndent) const
#endif #endif
nsAtom* nsAtom*
ServoNamespaceRule::GetPrefix() const CSSNamespaceRule::GetPrefix() const
{ {
return Servo_NamespaceRule_GetPrefix(mRawRule); return Servo_NamespaceRule_GetPrefix(mRawRule);
} }
void void
ServoNamespaceRule::GetURLSpec(nsString& aURLSpec) const CSSNamespaceRule::GetURLSpec(nsString& aURLSpec) const
{ {
nsAtom* atom = Servo_NamespaceRule_GetURI(mRawRule); nsAtom* atom = Servo_NamespaceRule_GetURI(mRawRule);
atom->ToString(aURLSpec); atom->ToString(aURLSpec);
} }
void void
ServoNamespaceRule::GetCssText(nsAString& aCssText) const CSSNamespaceRule::GetCssText(nsAString& aCssText) const
{ {
Servo_NamespaceRule_GetCssText(mRawRule, &aCssText); Servo_NamespaceRule_GetCssText(mRawRule, &aCssText);
} }
size_t size_t
ServoNamespaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const CSSNamespaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{ {
return aMallocSizeOf(this); return aMallocSizeOf(this);
} }

Просмотреть файл

@ -9,40 +9,58 @@
#include "mozilla/css/Rule.h" #include "mozilla/css/Rule.h"
#include "mozilla/dom/CSSNamespaceRuleBinding.h" #include "mozilla/dom/CSSNamespaceRuleBinding.h"
#include "mozilla/ServoBindingTypes.h"
class nsAtom; class nsAtom;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class CSSNamespaceRule : public css::Rule class CSSNamespaceRule final : public css::Rule
{ {
protected:
using Rule::Rule;
public: public:
CSSNamespaceRule(already_AddRefed<RawServoNamespaceRule> aRule,
uint32_t aLine, uint32_t aColumn)
: css::Rule(aLine, aColumn)
, mRawRule(std::move(aRule))
{
}
bool IsCCLeaf() const final { bool IsCCLeaf() const final {
return Rule::IsCCLeaf(); return Rule::IsCCLeaf();
} }
virtual nsAtom* GetPrefix() const = 0; #ifdef DEBUG
virtual void GetURLSpec(nsString& aURLSpec) const = 0; void List(FILE* out = stdout, int32_t aIndent = 0) const final;
#endif
nsAtom* GetPrefix() const;
void GetURLSpec(nsString& aURLSpec) const;
// WebIDL interface
void GetCssText(nsAString& aCssText) const final;
// WebIDL interfaces // WebIDL interfaces
uint16_t Type() const final { return CSSRuleBinding::NAMESPACE_RULE; } uint16_t Type() const final { return CSSRuleBinding::NAMESPACE_RULE; }
void GetNamespaceURI(nsString& aNamespaceURI) { void GetNamespaceURI(nsString& aNamespaceURI) {
GetURLSpec(aNamespaceURI); GetURLSpec(aNamespaceURI);
} }
void GetPrefix(DOMString& aPrefix) { void GetPrefix(DOMString& aPrefix) {
aPrefix.SetKnownLiveAtom(GetPrefix(), DOMString::eTreatNullAsEmpty); aPrefix.SetKnownLiveAtom(GetPrefix(), DOMString::eTreatNullAsEmpty);
} }
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override = 0; size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
JSObject* WrapObject(JSContext* aCx, JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) final { JS::Handle<JSObject*> aGivenProto) final {
return CSSNamespaceRuleBinding::Wrap(aCx, this, aGivenProto); return CSSNamespaceRuleBinding::Wrap(aCx, this, aGivenProto);
} }
private:
~CSSNamespaceRule();
RefPtr<RawServoNamespaceRule> mRawRule;
}; };
} // namespace dom } // namespace dom

Просмотреть файл

@ -264,6 +264,7 @@ SERVO_BINDING_FUNC(Servo_CssRules_DeleteRule, nsresult,
BASIC_RULE_FUNCS(type_) \ BASIC_RULE_FUNCS(type_) \
SERVO_BINDING_FUNC(Servo_##type_##Rule_GetRules, ServoCssRulesStrong, \ SERVO_BINDING_FUNC(Servo_##type_##Rule_GetRules, ServoCssRulesStrong, \
RawServo##type_##RuleBorrowed rule) RawServo##type_##RuleBorrowed rule)
BASIC_RULE_FUNCS(Style) BASIC_RULE_FUNCS(Style)
BASIC_RULE_FUNCS(Import) BASIC_RULE_FUNCS(Import)
BASIC_RULE_FUNCS_WITHOUT_GETTER(Keyframe) BASIC_RULE_FUNCS_WITHOUT_GETTER(Keyframe)

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/ServoCSSRuleList.h" #include "mozilla/ServoCSSRuleList.h"
#include "mozilla/dom/CSSNamespaceRule.h"
#include "mozilla/IntegerRange.h" #include "mozilla/IntegerRange.h"
#include "mozilla/ServoBindings.h" #include "mozilla/ServoBindings.h"
#include "mozilla/ServoCounterStyleRule.h" #include "mozilla/ServoCounterStyleRule.h"
@ -17,7 +18,6 @@
#include "mozilla/ServoFontFeatureValuesRule.h" #include "mozilla/ServoFontFeatureValuesRule.h"
#include "mozilla/ServoKeyframesRule.h" #include "mozilla/ServoKeyframesRule.h"
#include "mozilla/ServoMediaRule.h" #include "mozilla/ServoMediaRule.h"
#include "mozilla/ServoNamespaceRule.h"
#include "mozilla/ServoPageRule.h" #include "mozilla/ServoPageRule.h"
#include "mozilla/ServoStyleRule.h" #include "mozilla/ServoStyleRule.h"
#include "mozilla/ServoSupportsRule.h" #include "mozilla/ServoSupportsRule.h"
@ -93,10 +93,21 @@ ServoCSSRuleList::GetRule(uint32_t aIndex)
ruleObj = new Servo##name_##Rule(rule.forget(), line, column); \ ruleObj = new Servo##name_##Rule(rule.forget(), line, column); \
break; \ break; \
} }
#define CASE_RULE_CSS(const_, name_) \
case CSSRuleBinding::const_##_RULE: { \
uint32_t line = 0, column = 0; \
RefPtr<RawServo##name_##Rule> rule = \
Servo_CssRules_Get##name_##RuleAt( \
mRawRules, aIndex, &line, &column \
).Consume(); \
MOZ_ASSERT(rule); \
ruleObj = new CSS##name_##Rule(rule.forget(), line, column); \
break; \
}
CASE_RULE(STYLE, Style) CASE_RULE(STYLE, Style)
CASE_RULE(KEYFRAMES, Keyframes) CASE_RULE(KEYFRAMES, Keyframes)
CASE_RULE(MEDIA, Media) CASE_RULE(MEDIA, Media)
CASE_RULE(NAMESPACE, Namespace) CASE_RULE_CSS(NAMESPACE, Namespace)
CASE_RULE(PAGE, Page) CASE_RULE(PAGE, Page)
CASE_RULE(SUPPORTS, Supports) CASE_RULE(SUPPORTS, Supports)
CASE_RULE(DOCUMENT, Document) CASE_RULE(DOCUMENT, Document)

Просмотреть файл

@ -1,48 +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/. */
#ifndef mozilla_ServoNamespaceRule_h
#define mozilla_ServoNamespaceRule_h
#include "mozilla/ServoBindingTypes.h"
#include "mozilla/dom/CSSNamespaceRule.h"
namespace mozilla {
class ServoNamespaceRule : public dom::CSSNamespaceRule
{
public:
ServoNamespaceRule(already_AddRefed<RawServoNamespaceRule> aRule,
uint32_t aLine, uint32_t aColumn)
: CSSNamespaceRule(aLine, aColumn)
, mRawRule(std::move(aRule))
{
}
NS_INLINE_DECL_REFCOUNTING_INHERITED(ServoNamespaceRule,
dom::CSSNamespaceRule)
#ifdef DEBUG
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
#endif
nsAtom* GetPrefix() const final;
void GetURLSpec(nsString& aURLSpec) const final;
// WebIDL interface
void GetCssText(nsAString& aCssText) const final;
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
private:
~ServoNamespaceRule();
RefPtr<RawServoNamespaceRule> mRawRule;
};
} // namespace mozilla
#endif // mozilla_ServoNamespaceRule_h

Просмотреть файл

@ -94,7 +94,6 @@ EXPORTS.mozilla += [
'ServoKeyframeRule.h', 'ServoKeyframeRule.h',
'ServoKeyframesRule.h', 'ServoKeyframesRule.h',
'ServoMediaRule.h', 'ServoMediaRule.h',
'ServoNamespaceRule.h',
'ServoPageRule.h', 'ServoPageRule.h',
'ServoSpecifiedValues.h', 'ServoSpecifiedValues.h',
'ServoStyleRule.h', 'ServoStyleRule.h',
@ -160,6 +159,7 @@ UNIFIED_SOURCES += [
'CSSLexer.cpp', 'CSSLexer.cpp',
'CSSMediaRule.cpp', 'CSSMediaRule.cpp',
'CSSMozDocumentRule.cpp', 'CSSMozDocumentRule.cpp',
'CSSNamespaceRule.cpp',
'CSSPageRule.cpp', 'CSSPageRule.cpp',
'CSSRuleList.cpp', 'CSSRuleList.cpp',
'CSSSupportsRule.cpp', 'CSSSupportsRule.cpp',
@ -213,7 +213,6 @@ UNIFIED_SOURCES += [
'ServoKeyframeRule.cpp', 'ServoKeyframeRule.cpp',
'ServoKeyframesRule.cpp', 'ServoKeyframesRule.cpp',
'ServoMediaRule.cpp', 'ServoMediaRule.cpp',
'ServoNamespaceRule.cpp',
'ServoPageRule.cpp', 'ServoPageRule.cpp',
'ServoSpecifiedValues.cpp', 'ServoSpecifiedValues.cpp',
'ServoStyleRule.cpp', 'ServoStyleRule.cpp',