Backed out changeset b49d8d47c3f1 (bug 1382078)

This commit is contained in:
Sebastian Hengst 2017-09-02 20:43:36 +02:00
Родитель 4ec0447af3
Коммит 3764de542b
7 изменённых файлов: 30 добавлений и 138 удалений

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

@ -50,7 +50,6 @@
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "mozilla/dom/NodeListBinding.h" #include "mozilla/dom/NodeListBinding.h"
#include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/ScriptSettings.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
using namespace mozilla; using namespace mozilla;
@ -746,59 +745,19 @@ nsBindingManager::MediumFeaturesChanged(nsPresContext* aPresContext)
{ {
bool rulesChanged = false; bool rulesChanged = false;
RefPtr<nsPresContext> presContext = aPresContext; RefPtr<nsPresContext> presContext = aPresContext;
bool isStyledByServo = mDocument->IsStyledByServo();
EnumerateBoundContentBindings([=, &rulesChanged](nsXBLBinding* aBinding) { EnumerateBoundContentBindings([=, &rulesChanged](nsXBLBinding* aBinding) {
if (isStyledByServo) { nsIStyleRuleProcessor* ruleProcessor =
ServoStyleSet* styleSet = aBinding->PrototypeBinding()->GetServoStyleSet(); aBinding->PrototypeBinding()->GetRuleProcessor();
if (styleSet) { if (ruleProcessor) {
bool styleSetChanged = false; bool thisChanged = ruleProcessor->MediumFeaturesChanged(presContext);
rulesChanged = rulesChanged || thisChanged;
if (styleSet->IsPresContextChanged(presContext)) {
styleSetChanged = true;
} else {
// PresContext is not changed. This means aPresContext is still
// alive since the last time it initialized this XBL styleset.
// It's safe to check whether medium features changed.
bool viewportUnitsUsed = false;
styleSetChanged =
styleSet->MediumFeaturesChangedRules(&viewportUnitsUsed);
MOZ_ASSERT(!viewportUnitsUsed,
"Non-master stylesets shouldn't get flagged as using "
"viewport units!");
}
rulesChanged = rulesChanged || styleSetChanged;
}
} else {
nsIStyleRuleProcessor* ruleProcessor =
aBinding->PrototypeBinding()->GetRuleProcessor();
if (ruleProcessor) {
bool thisChanged = ruleProcessor->MediumFeaturesChanged(presContext);
rulesChanged = rulesChanged || thisChanged;
}
} }
}); });
return rulesChanged; return rulesChanged;
} }
void
nsBindingManager::UpdateBoundContentBindingsForServo(nsPresContext* aPresContext)
{
MOZ_ASSERT(mDocument->IsStyledByServo(),
"This should be called only by servo-backend!");
RefPtr<nsPresContext> presContext = aPresContext;
EnumerateBoundContentBindings([=](nsXBLBinding* aBinding) {
nsXBLPrototypeBinding* protoBinding = aBinding->PrototypeBinding();
ServoStyleSet* styleSet = protoBinding->GetServoStyleSet();
if (styleSet && styleSet->StyleSheetsHaveChanged()) {
protoBinding->ComputeServoStyleSet(presContext);
}
});
}
void void
nsBindingManager::AppendAllSheets(nsTArray<StyleSheet*>& aArray) nsBindingManager::AppendAllSheets(nsTArray<StyleSheet*>& aArray)
{ {

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

@ -130,17 +130,13 @@ public:
void WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc, void WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc,
ElementDependentRuleProcessorData* aData); ElementDependentRuleProcessorData* aData);
/**
// Do any processing that needs to happen as a result of a change in the * Do any processing that needs to happen as a result of a change in
// characteristics of the medium, and return whether this rule processor's * the characteristics of the medium, and return whether this rule
// rules or the servo style set have changed (e.g., because of media * processor's rules have changed (e.g., because of media queries).
// queries). */
bool MediumFeaturesChanged(nsPresContext* aPresContext); bool MediumFeaturesChanged(nsPresContext* aPresContext);
// Update the content bindings in mBoundContentSet due to medium features
// changed.
void UpdateBoundContentBindingsForServo(nsPresContext* aPresContext);
void AppendAllSheets(nsTArray<mozilla::StyleSheet*>& aArray); void AppendAllSheets(nsTArray<mozilla::StyleSheet*>& aArray);
void Traverse(nsIContent *aContent, void Traverse(nsIContent *aContent,

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

@ -569,14 +569,6 @@ nsXBLPrototypeBinding::GetRuleProcessor()
return nullptr; return nullptr;
} }
void
nsXBLPrototypeBinding::ComputeServoStyleSet(nsPresContext* aPresContext)
{
if (mResources) {
mResources->ComputeServoStyleSet(aPresContext);
}
}
ServoStyleSet* ServoStyleSet*
nsXBLPrototypeBinding::GetServoStyleSet() const nsXBLPrototypeBinding::GetServoStyleSet() const
{ {

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

@ -131,7 +131,6 @@ public:
void AppendStyleSheetsTo(nsTArray<mozilla::StyleSheet*>& aResult) const; void AppendStyleSheetsTo(nsTArray<mozilla::StyleSheet*>& aResult) const;
nsIStyleRuleProcessor* GetRuleProcessor(); nsIStyleRuleProcessor* GetRuleProcessor();
void ComputeServoStyleSet(nsPresContext* aPresContext);
mozilla::ServoStyleSet* GetServoStyleSet() const; mozilla::ServoStyleSet* GetServoStyleSet() const;
nsresult FlushSkinSheets(); nsresult FlushSkinSheets();

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

@ -109,8 +109,6 @@ void
ServoStyleSet::Init(nsPresContext* aPresContext, nsBindingManager* aBindingManager) ServoStyleSet::Init(nsPresContext* aPresContext, nsBindingManager* aBindingManager)
{ {
mPresContext = aPresContext; mPresContext = aPresContext;
mPresContextInitXBLStyleSet = aPresContext;
mRawSet.reset(Servo_StyleSet_Init(aPresContext)); mRawSet.reset(Servo_StyleSet_Init(aPresContext));
mBindingManager = aBindingManager; mBindingManager = aBindingManager;
@ -170,15 +168,11 @@ nsRestyleHint
ServoStyleSet::MediumFeaturesChanged(bool aViewportChanged) ServoStyleSet::MediumFeaturesChanged(bool aViewportChanged)
{ {
bool viewportUnitsUsed = false; bool viewportUnitsUsed = false;
bool rulesChanged = MediumFeaturesChangedRules(&viewportUnitsUsed); const OriginFlags rulesChanged = static_cast<OriginFlags>(
Servo_StyleSet_MediumFeaturesChanged(mRawSet.get(), &viewportUnitsUsed));
if (mBindingManager && if (rulesChanged != OriginFlags(0)) {
mBindingManager->MediumFeaturesChanged(mPresContext)) { MarkOriginsDirty(rulesChanged);
SetStylistXBLStyleSheetsDirty();
rulesChanged = true;
}
if (rulesChanged) {
return eRestyle_Subtree; return eRestyle_Subtree;
} }
@ -189,22 +183,6 @@ ServoStyleSet::MediumFeaturesChanged(bool aViewportChanged)
return nsRestyleHint(0); return nsRestyleHint(0);
} }
bool
ServoStyleSet::MediumFeaturesChangedRules(bool* aViewportUnitsUsed)
{
MOZ_ASSERT(aViewportUnitsUsed);
const OriginFlags rulesChanged = static_cast<OriginFlags>(
Servo_StyleSet_MediumFeaturesChanged(mRawSet.get(), aViewportUnitsUsed));
if (rulesChanged != OriginFlags(0)) {
MarkOriginsDirty(rulesChanged);
return true;
}
return false;
}
MOZ_DEFINE_MALLOC_SIZE_OF(ServoStyleSetMallocSizeOf) MOZ_DEFINE_MALLOC_SIZE_OF(ServoStyleSetMallocSizeOf)
void void
@ -1394,21 +1372,13 @@ ServoStyleSet::UpdateStylist()
{ {
MOZ_ASSERT(StylistNeedsUpdate()); MOZ_ASSERT(StylistNeedsUpdate());
if (mStylistState & StylistState::StyleSheetsDirty) { // There's no need to compute invalidations and such for an XBL styleset,
// There's no need to compute invalidations and such for an XBL styleset, // since they are loaded and unloaded synchronously, and they don't have to
// since they are loaded and unloaded synchronously, and they don't have to // deal with dynamic content changes.
// deal with dynamic content changes. Element* root =
Element* root = IsMaster() ? mPresContext->Document()->GetDocumentElement() : nullptr;
IsMaster() ? mPresContext->Document()->GetDocumentElement() : nullptr;
Servo_StyleSet_FlushStyleSheets(mRawSet.get(), root);
}
if (MOZ_UNLIKELY(mStylistState & StylistState::XBLStyleSheetsDirty)) {
MOZ_ASSERT(IsMaster(), "Only master styleset can mark XBL stylesets dirty!");
mBindingManager->UpdateBoundContentBindingsForServo(mPresContext);
}
Servo_StyleSet_FlushStyleSheets(mRawSet.get(), root);
mStylistState = StylistState::NotDirty; mStylistState = StylistState::NotDirty;
} }

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

@ -46,22 +46,18 @@ struct TreeMatchContext;
namespace mozilla { namespace mozilla {
// A few flags used to track which kind of stylist state we may need to /**
// update. * A few flags used to track which kind of stylist state we may need to
* update.
*/
enum class StylistState : uint8_t { enum class StylistState : uint8_t {
// The stylist is not dirty, we should do nothing. /** The stylist is not dirty, we should do nothing */
NotDirty = 0, NotDirty = 0,
// The style sheets have changed, so we need to update the style data. /** The style sheets have changed, so we need to update the style data. */
StyleSheetsDirty = 1 << 0, StyleSheetsDirty,
// Some of the style sheets of the bound elements in binding manager have
// changed, so we need to tell the binding manager to update style data.
XBLStyleSheetsDirty = 1 << 1,
}; };
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(StylistState)
// Bitfield type to represent Servo stylesheet origins. // Bitfield type to represent Servo stylesheet origins.
enum class OriginFlags : uint8_t { enum class OriginFlags : uint8_t {
UserAgent = 0x01, UserAgent = 0x01,
@ -137,9 +133,6 @@ public:
nsRestyleHint MediumFeaturesChanged(bool aViewportChanged); nsRestyleHint MediumFeaturesChanged(bool aViewportChanged);
// aViewportChanged outputs whether any viewport units is used.
bool MediumFeaturesChangedRules(bool* aViewportUnitsUsed);
void InvalidateStyleForCSSRuleChanges(); void InvalidateStyleForCSSRuleChanges();
void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const; void AddSizeOfIncludingThis(nsWindowSizes& aSizes) const;
@ -440,11 +433,6 @@ public:
mPresContext = nullptr; mPresContext = nullptr;
} }
// Return whether this is the PresContext that initialized us.
bool IsPresContextChanged(nsPresContext* aPresContext) const {
return aPresContext != mPresContextInitXBLStyleSet;
}
/** /**
* Returns true if a modification to an an attribute with the specified * Returns true if a modification to an an attribute with the specified
* local name might require us to restyle the element. * local name might require us to restyle the element.
@ -537,12 +525,7 @@ private:
*/ */
void SetStylistStyleSheetsDirty() void SetStylistStyleSheetsDirty()
{ {
mStylistState |= StylistState::StyleSheetsDirty; mStylistState = StylistState::StyleSheetsDirty;
}
void SetStylistXBLStyleSheetsDirty()
{
mStylistState |= StylistState::XBLStyleSheetsDirty;
} }
bool StylistNeedsUpdate() const bool StylistNeedsUpdate() const
@ -582,15 +565,7 @@ private:
ServoStyleSheet* aSheet); ServoStyleSheet* aSheet);
const Kind mKind; const Kind mKind;
nsPresContext* mPresContext;
// Nullptr if this is an XBL style set.
nsPresContext* MOZ_NON_OWNING_REF mPresContext = nullptr;
// Because XBL style set could be used by multiple PresContext, we need to
// store the PresContext pointer which initializes this style set for
// computing medium rule changes.
void* MOZ_NON_OWNING_REF mPresContextInitXBLStyleSet = nullptr;
UniquePtr<RawServoStyleSet> mRawSet; UniquePtr<RawServoStyleSet> mRawSet;
EnumeratedArray<SheetType, SheetType::Count, EnumeratedArray<SheetType, SheetType::Count,
nsTArray<RefPtr<ServoStyleSheet>>> mSheets; nsTArray<RefPtr<ServoStyleSheet>>> mSheets;

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

@ -242,6 +242,7 @@ skip-if = !stylo
skip-if = android_version == '18' #debug-only failure; timed out #Android 4.3 aws only; bug 1030419 skip-if = android_version == '18' #debug-only failure; timed out #Android 4.3 aws only; bug 1030419
[test_media_queries_dynamic.html] [test_media_queries_dynamic.html]
[test_media_queries_dynamic_xbl.html] [test_media_queries_dynamic_xbl.html]
fail-if = stylo # bug 1382078
[test_media_query_list.html] [test_media_query_list.html]
[test_media_query_serialization.html] [test_media_query_serialization.html]
[test_moz_device_pixel_ratio.html] [test_moz_device_pixel_ratio.html]