Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1451289 - Part 8: Merge ServoSupportsRule and CSSSupportsRule r=e…
Browse files Browse the repository at this point in the history
…milio

MozReview-Commit-ID: HX6NJNGJi0p
  • Loading branch information
canova committed Jun 5, 2018
1 parent 30afd70 commit 5a22dd9
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 134 deletions.
56 changes: 56 additions & 0 deletions layout/style/CSSSupportsRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,69 @@

#include "mozilla/dom/CSSSupportsRule.h"

#include "mozilla/css/GroupRule.h"
#include "mozilla/dom/CSSSupportsRuleBinding.h"
#include "mozilla/ServoBindings.h"

using namespace mozilla::css;

namespace mozilla {
namespace dom {

CSSSupportsRule::CSSSupportsRule(RefPtr<RawServoSupportsRule> aRawRule,
uint32_t aLine, uint32_t aColumn)
: css::ConditionRule(Servo_SupportsRule_GetRules(aRawRule).Consume(),
aLine, aColumn)
, mRawRule(std::move(aRawRule))
{
}

NS_IMPL_ADDREF_INHERITED(CSSSupportsRule, ConditionRule)
NS_IMPL_RELEASE_INHERITED(CSSSupportsRule, ConditionRule)

// QueryInterface implementation for SupportsRule
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSSupportsRule)
NS_INTERFACE_MAP_END_INHERITING(ConditionRule)

#ifdef DEBUG
/* virtual */ void
CSSSupportsRule::List(FILE* out, int32_t aIndent) const
{
nsAutoCString str;
for (int32_t i = 0; i < aIndent; i++) {
str.AppendLiteral(" ");
}
Servo_SupportsRule_Debug(mRawRule, &str);
fprintf_stderr(out, "%s\n", str.get());
}
#endif

void
CSSSupportsRule::GetConditionText(nsAString& aConditionText)
{
Servo_SupportsRule_GetConditionText(mRawRule, &aConditionText);
}

void
CSSSupportsRule::SetConditionText(const nsAString& aConditionText,
ErrorResult& aRv)
{
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
}

/* virtual */ void
CSSSupportsRule::GetCssText(nsAString& aCssText) const
{
Servo_SupportsRule_GetCssText(mRawRule, &aCssText);
}

/* virtual */ size_t
CSSSupportsRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
// TODO Implement this!
return aMallocSizeOf(this);
}

/* virtual */ JSObject*
CSSSupportsRule::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
Expand Down
27 changes: 23 additions & 4 deletions layout/style/CSSSupportsRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,41 @@
#define mozilla_dom_CSSSupportsRule_h

#include "mozilla/css/GroupRule.h"
#include "mozilla/ServoBindingTypes.h"

namespace mozilla {
namespace dom {

class CSSSupportsRule : public css::ConditionRule
{
protected:
using ConditionRule::ConditionRule;
virtual ~CSSSupportsRule() {}

public:
CSSSupportsRule(RefPtr<RawServoSupportsRule> aRawRule,
uint32_t aLine, uint32_t aColumn);

NS_DECL_ISUPPORTS_INHERITED

#ifdef DEBUG
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
#endif

RawServoSupportsRule* Raw() const { return mRawRule; }

// WebIDL interface
uint16_t Type() const override { return CSSRuleBinding::SUPPORTS_RULE; }
void GetCssText(nsAString& aCssText) const final;
void GetConditionText(nsAString& aConditionText) final;
void SetConditionText(const nsAString& aConditionText,
ErrorResult& aRv) final;

size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
const override;
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;

private:
~CSSSupportsRule() = default;

RefPtr<RawServoSupportsRule> mRawRule;
};

} // namespace dom
Expand Down
4 changes: 2 additions & 2 deletions layout/style/ServoCSSRuleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#include "mozilla/dom/CSSNamespaceRule.h"
#include "mozilla/dom/CSSPageRule.h"
#include "mozilla/dom/CSSStyleRule.h"
#include "mozilla/dom/CSSSupportsRule.h"
#include "mozilla/IntegerRange.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoDocumentRule.h"
#include "mozilla/ServoImportRule.h"
#include "mozilla/ServoFontFeatureValuesRule.h"
#include "mozilla/ServoSupportsRule.h"
#include "mozilla/StyleSheet.h"

using namespace mozilla::dom;
Expand Down Expand Up @@ -109,7 +109,7 @@ ServoCSSRuleList::GetRule(uint32_t aIndex)
CASE_RULE_CSS(MEDIA, Media)
CASE_RULE_CSS(NAMESPACE, Namespace)
CASE_RULE_CSS(PAGE, Page)
CASE_RULE(SUPPORTS, Supports)
CASE_RULE_CSS(SUPPORTS, Supports)
CASE_RULE(DOCUMENT, Document)
CASE_RULE(IMPORT, Import)
CASE_RULE(FONT_FEATURE_VALUES, FontFeatureValues)
Expand Down
76 changes: 0 additions & 76 deletions layout/style/ServoSupportsRule.cpp

This file was deleted.

48 changes: 0 additions & 48 deletions layout/style/ServoSupportsRule.h

This file was deleted.

2 changes: 0 additions & 2 deletions layout/style/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ EXPORTS.mozilla += [
'ServoSpecifiedValues.h',
'ServoStyleSet.h',
'ServoStyleSetInlines.h',
'ServoSupportsRule.h',
'ServoTraversalStatistics.h',
'ServoTypes.h',
'ServoUtils.h',
Expand Down Expand Up @@ -209,7 +208,6 @@ UNIFIED_SOURCES += [
'ServoImportRule.cpp',
'ServoSpecifiedValues.cpp',
'ServoStyleSet.cpp',
'ServoSupportsRule.cpp',
'StreamLoader.cpp',
'StyleAnimationValue.cpp',
'StyleComplexColor.cpp',
Expand Down
2 changes: 0 additions & 2 deletions layout/style/nsMediaFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
#include "nsPresContext.h"
#include "nsCSSProps.h"
#include "nsCSSValue.h"
#ifdef XP_WIN
#include "mozilla/LookAndFeel.h"
#endif
#include "nsDeviceContext.h"
#include "nsIBaseWindow.h"
#include "nsIDocShell.h"
Expand Down

0 comments on commit 5a22dd9

Please sign in to comment.