Commit deabbe05 authored by Molnar Sandor's avatar Molnar Sandor
Browse files

Backed out changeset 3855f8235011 (bug 1617948) for causing mochitest plain...

Backed out changeset 3855f8235011 (bug 1617948) for causing mochitest plain failures in test_get_all_style_sheets. CLOSED TREE
parent 3bb8f57d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ void DocumentOrShadowRoot::ClearAdoptedStyleSheets() {

void DocumentOrShadowRoot::CloneAdoptedSheetsFrom(
    const DocumentOrShadowRoot& aSource) {
  if (aSource.mAdoptedStyleSheets.IsEmpty()) {
  if (!aSource.AdoptedSheetCount()) {
    return;
  }

+1 −3
Original line number Diff line number Diff line
@@ -76,9 +76,7 @@ class DocumentOrShadowRoot : public RadioGroupManager {

  size_t SheetCount() const { return mStyleSheets.Length(); }

  const nsTArray<RefPtr<StyleSheet>>& AdoptedStyleSheets() const {
    return mAdoptedStyleSheets;
  }
  size_t AdoptedSheetCount() const { return mAdoptedStyleSheets.Length(); }

  /**
   * Returns an index for the sheet in relative style order.
+5 −8
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ void InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject,
                                       nsTArray<RefPtr<StyleSheet>>& aResult) {
  // Get the agent, then user and finally xbl sheets in the style set.
  PresShell* presShell = aDocument.GetPresShell();
  nsTHashSet<StyleSheet*> sheetSet;

  if (presShell) {
    ServoStyleSet* styleSet = presShell->StyleSet();
@@ -102,8 +101,8 @@ void InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject,
    AutoTArray<StyleSheet*, 32> nonDocumentSheets;
    styleSet->AppendAllNonDocumentAuthorSheets(nonDocumentSheets);

    // The non-document stylesheet array can have duplicates due to adopted
    // stylesheets.
    // The non-document stylesheet array can't have duplicates right now, but it
    // could once we include adopted stylesheets.
    nsTHashSet<StyleSheet*> sheetSet;
    for (StyleSheet* sheet : nonDocumentSheets) {
      if (sheetSet.EnsureInserted(sheet)) {
@@ -117,11 +116,9 @@ void InspectorUtils::GetAllStyleSheets(GlobalObject& aGlobalObject,
    aResult.AppendElement(aDocument.SheetAt(i));
  }

  for (auto& sheet : aDocument.AdoptedStyleSheets()) {
    if (sheetSet.EnsureInserted(sheet)) {
      aResult.AppendElement(sheet);
    }
  }
  // FIXME(emilio, bug 1617948): This doesn't deal with adopted stylesheets, and
  // it should. It should also handle duplicates correctly when it does, see
  // above.
}

bool InspectorUtils::IsIgnorableWhitespace(CharacterData& aDataNode) {
+0 −3
Original line number Diff line number Diff line
@@ -37,9 +37,6 @@ void ServoStyleRuleMap::EnsureTable(ShadowRoot& aShadowRoot) {
  for (auto index : IntegerRange(aShadowRoot.SheetCount())) {
    FillTableFromStyleSheet(*aShadowRoot.SheetAt(index));
  }
  for (auto& sheet : aShadowRoot.AdoptedStyleSheets()) {
    FillTableFromStyleSheet(*sheet);
  }
}

void ServoStyleRuleMap::SheetAdded(StyleSheet& aStyleSheet) {
+7 −14
Original line number Diff line number Diff line
@@ -171,20 +171,9 @@ const tests = [
         "declaration from UA stylesheet html.css");
    },
  },
  {
    title: "Check adopted sheets",
    async run(doc, win) {
      checkRules(doc, [1]);
      let sheet = new win.CSSStyleSheet();
      sheet.replaceSync(`unknowntagname { z-index: 5 }`);
      doc.adoptedStyleSheets.push(sheet);
      checkRules(doc, [1, 5]);
    },
  },
];

add_task(async function runTests() {
  await SpecialPowers.pushPrefEnv({ set: [["layout.css.constructable-stylesheets.enabled", true]] });
async function runTests() {
  for (let i = 0; i < tests.length; i++) {
    let test = tests[i];
    info(`Test ${i}: ${test.title}`);
@@ -195,12 +184,16 @@ add_task(async function runTests() {
    iframe.src = `file_getCSSStyleRules-${test.base}.html`;
    await new Promise(resolve => { iframe.onload = resolve; });
    try {
      await test.run(iframe.contentDocument, iframe.contentWindow);
      await test.run(iframe.contentDocument);
    } catch (e) {
      ok(false, "JavaScript error: " + e);
    }
  }
});
  SimpleTest.finish();
}

runTests();

</script>
</pre>
</body>
Loading