mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 12:13:22 +00:00
Bug 1325878: Pass the MediaList down to Servo, making <style media> work. r=xidorn
MozReview-Commit-ID: BUCSQJs2CNI Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
6ec12dc4f5
commit
f7cf08128a
@ -69,6 +69,10 @@ public:
|
||||
virtual bool Matches(nsPresContext& aPresContext,
|
||||
nsMediaQueryResultCacheKey* = nullptr) const = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
virtual bool IsServo() const = 0;
|
||||
#endif
|
||||
|
||||
void SetStyleSheet(StyleSheet* aSheet);
|
||||
|
||||
NS_DECL_NSIDOMMEDIALIST
|
||||
|
@ -29,6 +29,7 @@ SERVO_BINDING_FUNC(Servo_StyleSheet_FromUTF8Bytes, RawServoStyleSheetStrong,
|
||||
mozilla::ServoStyleSheet* gecko_stylesheet,
|
||||
const nsACString* data,
|
||||
mozilla::css::SheetParsingMode parsing_mode,
|
||||
const RawServoMediaList* media_list,
|
||||
RawGeckoURLExtraData* extra_data)
|
||||
SERVO_BINDING_FUNC(Servo_ImportRule_GetSheet,
|
||||
RawServoStyleSheetStrong,
|
||||
|
@ -33,6 +33,12 @@ public:
|
||||
|
||||
bool Matches(nsPresContext&, nsMediaQueryResultCacheKey*) const final;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool IsServo() const final { return true; }
|
||||
#endif
|
||||
|
||||
RawServoMediaList& RawList() { return *mRawList; }
|
||||
|
||||
protected:
|
||||
nsresult Delete(const nsAString& aOldMedium) final;
|
||||
nsresult Append(const nsAString& aNewMedium) final;
|
||||
|
@ -9,9 +9,11 @@
|
||||
#include "mozilla/css/Rule.h"
|
||||
#include "mozilla/StyleBackendType.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/ServoMediaList.h"
|
||||
#include "mozilla/ServoCSSRuleList.h"
|
||||
#include "mozilla/css/GroupRule.h"
|
||||
#include "mozilla/dom/CSSRuleList.h"
|
||||
#include "mozilla/dom/MediaList.h"
|
||||
|
||||
#include "mozAutoDocUpdate.h"
|
||||
|
||||
@ -97,15 +99,22 @@ ServoStyleSheet::ParseSheet(css::Loader* aLoader,
|
||||
nsIPrincipal* aSheetPrincipal,
|
||||
uint32_t aLineNumber)
|
||||
{
|
||||
MOZ_ASSERT_IF(mMedia, mMedia->IsServo());
|
||||
RefPtr<URLExtraData> extraData =
|
||||
new URLExtraData(aBaseURI, aSheetURI, aSheetPrincipal);
|
||||
|
||||
NS_ConvertUTF16toUTF8 input(aInput);
|
||||
if (!Inner()->mSheet) {
|
||||
auto* mediaList = static_cast<ServoMediaList*>(mMedia.get());
|
||||
RawServoMediaList* media = mediaList ? &mediaList->RawList() : nullptr;
|
||||
|
||||
Inner()->mSheet =
|
||||
Servo_StyleSheet_FromUTF8Bytes(aLoader, this, &input,
|
||||
mParsingMode, extraData).Consume();
|
||||
Servo_StyleSheet_FromUTF8Bytes(
|
||||
aLoader, this, &input, mParsingMode, media, extraData).Consume();
|
||||
} else {
|
||||
// TODO(emilio): Once we have proper inner cloning (which we don't right
|
||||
// now) we should update the mediaList here too, though it's slightly
|
||||
// tricky.
|
||||
Servo_StyleSheet_ClearAndUpdate(Inner()->mSheet, aLoader,
|
||||
this, &input, extraData);
|
||||
}
|
||||
|
@ -260,6 +260,10 @@ public:
|
||||
bool Matches(nsPresContext& aPresContext,
|
||||
nsMediaQueryResultCacheKey* aKey) const final;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool IsServo() const final { return false; }
|
||||
#endif
|
||||
|
||||
void AppendQuery(nsAutoPtr<nsMediaQuery>& aQuery) {
|
||||
// Takes ownership of aQuery
|
||||
mArray.AppendElement(aQuery.forget());
|
||||
|
@ -28,7 +28,7 @@ static void ServoParsingBench() {
|
||||
NullPrincipalURI::Create(), nullptr, NullPrincipal::Create());
|
||||
for (int i = 0; i < PARSING_REPETITIONS; i++) {
|
||||
RefPtr<RawServoStyleSheet> stylesheet = Servo_StyleSheet_FromUTF8Bytes(
|
||||
nullptr, nullptr, &css, eAuthorSheetFeatures, data
|
||||
nullptr, nullptr, &css, eAuthorSheetFeatures, nullptr, data
|
||||
).Consume();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user