author | Emilio Cobos Álvarez <emilio@crisal.io> |
Mon, 16 Apr 2018 19:10:57 +0200 | |
changeset 414079 | 8c85b98829b26bf386ab01b60ce3ae3e565d2ed0 |
parent 414078 | 3f214ca585db301f1c1f284b9a63dd5c98c15f8b |
child 414080 | fabc60b735a660d3972c9ebbbd08abc93572acd0 |
push id | 33858 |
push user | ncsoregi@mozilla.com |
push date | Tue, 17 Apr 2018 21:55:44 +0000 |
treeherder | mozilla-central@d6eb5597d744 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bholley |
bugs | 1452143 |
milestone | 61.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/chrome-webidl/InspectorUtils.webidl +++ b/dom/chrome-webidl/InspectorUtils.webidl @@ -6,17 +6,18 @@ /** * A collection of utility methods for use by devtools. * * See InspectorUtils.h for documentation on these methods. */ [ChromeOnly] namespace InspectorUtils { - sequence<StyleSheet> getAllStyleSheets(Document document); + // documentOnly tells whether user and UA sheets should get included. + sequence<StyleSheet> getAllStyleSheets(Document document, optional boolean documentOnly = false); sequence<CSSRule> getCSSStyleRules( Element element, [TreatNullAs=EmptyString] optional DOMString pseudo = ""); unsigned long getRuleLine(CSSRule rule); unsigned long getRuleColumn(CSSRule rule); unsigned long getRelativeRuleLine(CSSRule rule); boolean hasRulesModifiedByCSSOM(CSSStyleSheet sheet); [NewObject] CSSLexer getCSSLexer(DOMString text);
--- a/layout/inspector/InspectorUtils.cpp +++ b/layout/inspector/InspectorUtils.cpp @@ -56,36 +56,42 @@ using namespace mozilla::dom; extern const char* const kCSSRawProperties[]; namespace mozilla { namespace dom { /* static */ void InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject, nsIDocument& aDocument, + bool aDocumentOnly, nsTArray<RefPtr<StyleSheet>>& aResult) { // Get the agent, then user and finally xbl sheets in the style set. nsIPresShell* presShell = aDocument.GetShell(); if (presShell) { ServoStyleSet* styleSet = presShell->StyleSet(); - SheetType sheetType = SheetType::Agent; - for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) { - aResult.AppendElement(styleSet->StyleSheetAt(sheetType, i)); - } - sheetType = SheetType::User; - for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) { - aResult.AppendElement(styleSet->StyleSheetAt(sheetType, i)); + + if (!aDocumentOnly) { + SheetType sheetType = SheetType::Agent; + for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) { + aResult.AppendElement(styleSet->StyleSheetAt(sheetType, i)); + } + sheetType = SheetType::User; + for (int32_t i = 0; i < styleSet->SheetCount(sheetType); i++) { + aResult.AppendElement(styleSet->StyleSheetAt(sheetType, i)); + } } AutoTArray<StyleSheet*, 32> xblSheetArray; - styleSet->AppendAllXBLStyleSheets(xblSheetArray); + styleSet->AppendAllNonDocumentAuthorSheets(xblSheetArray); // The XBL stylesheet array will quite often be full of duplicates. Cope: + // + // FIXME(emilio, bug 1454467): I think this is not true since bug 1452525. nsTHashtable<nsPtrHashKey<StyleSheet>> sheetSet; for (StyleSheet* sheet : xblSheetArray) { if (!sheetSet.Contains(sheet)) { sheetSet.PutEntry(sheet); aResult.AppendElement(sheet); } } } @@ -1043,26 +1049,18 @@ InspectorUtils::ClearPseudoClassLocks(Gl /* static */ void InspectorUtils::ParseStyleSheet(GlobalObject& aGlobalObject, StyleSheet& aSheet, const nsAString& aInput, ErrorResult& aRv) { - RefPtr<ServoStyleSheet> servoSheet = do_QueryObject(&aSheet); - if (servoSheet) { - nsresult rv = servoSheet->ReparseSheet(aInput); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - } - return; - } - - aRv.Throw(NS_ERROR_INVALID_POINTER); + RefPtr<ServoStyleSheet> servoSheet = aSheet.AsServo(); + aRv = servoSheet->ReparseSheet(aInput); } void InspectorUtils::ScrollElementIntoView(GlobalObject& aGlobalObject, Element& aElement) { nsIPresShell* presShell = aElement.OwnerDoc()->GetShell(); if (!presShell) {
--- a/layout/inspector/InspectorUtils.h +++ b/layout/inspector/InspectorUtils.h @@ -32,16 +32,17 @@ namespace dom { /** * A collection of utility methods for use by devtools. */ class InspectorUtils { public: static void GetAllStyleSheets(GlobalObject& aGlobal, nsIDocument& aDocument, + bool aDocumentOnly, nsTArray<RefPtr<StyleSheet>>& aResult); static void GetCSSStyleRules(GlobalObject& aGlobal, Element& aElement, const nsAString& aPseudo, nsTArray<RefPtr<css::Rule>>& aResult); /** * Get the line number of a rule.
--- a/layout/style/ErrorReporter.cpp +++ b/layout/style/ErrorReporter.cpp @@ -141,16 +141,17 @@ ErrorReporter::ErrorReporter(const Style , mErrorLineNumber(0) , mPrevErrorLineNumber(0) , mErrorColNumber(0) { } ErrorReporter::~ErrorReporter() { + MOZ_ASSERT(NS_IsMainThread()); // Schedule deferred cleanup for cached data. We want to strike a // balance between performance and memory usage, so we only allow // short-term caching. if (sSpecCache && sSpecCache->IsInUse() && !sSpecCache->IsPending()) { nsCOMPtr<nsIRunnable> runnable(sSpecCache); nsresult rv = SystemGroup::Dispatch(TaskCategory::Other, runnable.forget()); if (NS_FAILED(rv)) {
--- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -864,20 +864,25 @@ ServoStyleSet::SheetCount(SheetType aTyp ServoStyleSheet* ServoStyleSet::StyleSheetAt(SheetType aType, int32_t aIndex) const { MOZ_ASSERT(IsCSSSheetType(aType)); return mSheets[aType][aIndex]; } void -ServoStyleSet::AppendAllXBLStyleSheets(nsTArray<StyleSheet*>& aArray) const +ServoStyleSet::AppendAllNonDocumentAuthorSheets(nsTArray<StyleSheet*>& aArray) const { if (mDocument) { mDocument->BindingManager()->AppendAllSheets(aArray); + EnumerateShadowRoots(*mDocument, [&](ShadowRoot& aShadowRoot) { + for (auto index : IntegerRange(aShadowRoot.SheetCount())) { + aArray.AppendElement(aShadowRoot.SheetAt(index)); + } + }); } } nsresult ServoStyleSet::RemoveDocStyleSheet(ServoStyleSheet* aSheet) { return RemoveStyleSheet(SheetType::Doc, aSheet); }
--- a/layout/style/ServoStyleSet.h +++ b/layout/style/ServoStyleSet.h @@ -239,17 +239,17 @@ public: const nsTArray<RefPtr<ServoStyleSheet>>& aNewSheets); nsresult InsertStyleSheetBefore(SheetType aType, ServoStyleSheet* aNewSheet, ServoStyleSheet* aReferenceSheet); int32_t SheetCount(SheetType aType) const; ServoStyleSheet* StyleSheetAt(SheetType aType, int32_t aIndex) const; - void AppendAllXBLStyleSheets(nsTArray<StyleSheet*>& aArray) const; + void AppendAllNonDocumentAuthorSheets(nsTArray<StyleSheet*>& aArray) const; template<typename Func> void EnumerateStyleSheetArrays(Func aCallback) const { for (const auto& sheetArray : mSheets) { aCallback(sheetArray); } }