From d43f067572ccfb68c04225dd4a1fd23267c01a8c Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Tue, 11 Sep 2018 23:14:42 +0000 Subject: [PATCH 1/4] Bug 1486198. Be more accepting of empty blob images r=mstange Differential Revision: https://phabricator.services.mozilla.com/D5614 --HG-- extra : moz-landing-system : lando --- gfx/webrender_bindings/Moz2DImageRenderer.cpp | 6 ++- layout/svg/crashtests/crashtests.list | 1 + layout/svg/crashtests/empty-blob-merging.html | 48 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 layout/svg/crashtests/empty-blob-merging.html diff --git a/gfx/webrender_bindings/Moz2DImageRenderer.cpp b/gfx/webrender_bindings/Moz2DImageRenderer.cpp index b6e0cb00ff0a..53308d506ae2 100644 --- a/gfx/webrender_bindings/Moz2DImageRenderer.cpp +++ b/gfx/webrender_bindings/Moz2DImageRenderer.cpp @@ -410,12 +410,14 @@ static bool Moz2DRenderCallback(const Range aBlob, }; - MOZ_RELEASE_ASSERT(aBlob.length() > sizeof(size_t)); + // We try hard to not have empty blobs but we can end up with + // them because of CompositorHitTestInfo and merging. + MOZ_RELEASE_ASSERT(aBlob.length() >= sizeof(size_t)); size_t indexOffset = *(size_t*)(aBlob.end().get()-sizeof(size_t)); MOZ_RELEASE_ASSERT(indexOffset + sizeof(size_t) <= aBlob.length()); Reader reader(aBlob.begin().get()+indexOffset, aBlob.length()-sizeof(size_t)-indexOffset); - bool ret; + bool ret = true; size_t offset = 0; auto absBounds = IntRectAbsolute::FromRect(bounds); while (reader.pos < reader.len) { diff --git a/layout/svg/crashtests/crashtests.list b/layout/svg/crashtests/crashtests.list index 7762edc44160..bf520051d409 100644 --- a/layout/svg/crashtests/crashtests.list +++ b/layout/svg/crashtests/crashtests.list @@ -212,6 +212,7 @@ load 1467552-1.html load conditional-outer-svg-nondirty-reflow-assert.xhtml load extref-test-1.xhtml load blob-merging-and-retained-display-list.html +load empty-blob-merging.html load grouping-empty-bounds.html load 1480275.html load 1480224.html diff --git a/layout/svg/crashtests/empty-blob-merging.html b/layout/svg/crashtests/empty-blob-merging.html new file mode 100644 index 000000000000..4b603c19d9b4 --- /dev/null +++ b/layout/svg/crashtests/empty-blob-merging.html @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + From 164b0593446ab0cb739d53dc7b8cdbe266d5f0c4 Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Tue, 11 Sep 2018 23:40:39 +0000 Subject: [PATCH 2/4] Bug 1490444 - Localization should register its observers. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D5574 --HG-- extra : moz-landing-system : lando --- intl/l10n/DocumentL10n.cpp | 6 ++++++ intl/l10n/mozIDOMLocalization.idl | 1 + intl/l10n/test/test_mozdomlocalization.js | 1 + 3 files changed, 8 insertions(+) diff --git a/intl/l10n/DocumentL10n.cpp b/intl/l10n/DocumentL10n.cpp index 5c6ecd70776e..28b01d24f8a2 100644 --- a/intl/l10n/DocumentL10n.cpp +++ b/intl/l10n/DocumentL10n.cpp @@ -65,6 +65,12 @@ DocumentL10n::Init(nsTArray& aResourceIds) // is ready for localization. uint32_t ret; mDOMLocalization->AddResourceIds(aResourceIds, true, &ret); + + // Register observers for this instance of + // mozDOMLocalization to allow it to retranslate + // the document when locale changes or pseudolocalization + // gets turned on. + mDOMLocalization->RegisterObservers(); return true; } diff --git a/intl/l10n/mozIDOMLocalization.idl b/intl/l10n/mozIDOMLocalization.idl index 59c0b0072574..2d87668f5301 100644 --- a/intl/l10n/mozIDOMLocalization.idl +++ b/intl/l10n/mozIDOMLocalization.idl @@ -14,6 +14,7 @@ interface mozIDOMLocalization : nsISupports { unsigned long addResourceIds(in Array resourceIds, in bool aEager); unsigned long removeResourceIds(in Array resourceIds); + void registerObservers(); Promise formatMessages(in Array aKeys); Promise formatValues(in Array aKeys); diff --git a/intl/l10n/test/test_mozdomlocalization.js b/intl/l10n/test/test_mozdomlocalization.js index 961e12f995a5..5c063558a291 100644 --- a/intl/l10n/test/test_mozdomlocalization.js +++ b/intl/l10n/test/test_mozdomlocalization.js @@ -27,6 +27,7 @@ L10nRegistry.registerSource(source); add_task(function test_methods_presence() { equal(typeof domLocalization.addResourceIds, "function"); equal(typeof domLocalization.removeResourceIds, "function"); + equal(typeof domLocalization.registerObservers, "function"); equal(typeof domLocalization.formatMessages, "function"); equal(typeof domLocalization.formatValues, "function"); From 0bb5316f214ece74417cc1a1649dbc74b8e78c01 Mon Sep 17 00:00:00 2001 From: Belen Albeza Date: Tue, 11 Sep 2018 15:47:09 +0000 Subject: [PATCH 3/4] Bug 1488769 - Slotted nodes not being displayed in Shadow DOM tree if the node is a text. r=jdescottes r=jdescottes Differential Revision: https://phabricator.services.mozilla.com/D5538 --HG-- extra : moz-landing-system : lando --- devtools/server/actors/inspector/walker.js | 10 ++++++++- .../tests/browser/browser_inspector-shadow.js | 22 +++++++++++++++++++ .../tests/browser/inspector-shadow.html | 14 ++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/devtools/server/actors/inspector/walker.js b/devtools/server/actors/inspector/walker.js index 4821d191c7c4..4549e42c4cd7 100644 --- a/devtools/server/actors/inspector/walker.js +++ b/devtools/server/actors/inspector/walker.js @@ -521,10 +521,18 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, { // - more than one child // - unique child is not a text node // - unique child is a text node, but is too long to be inlined + // - we are a slot -> these are always represented on their own lines with + // a link to the original node. + const isAssignedSlot = + !!firstChild && + node.rawNode.nodeName === "SLOT" && + isDirectShadowHostChild(firstChild); + if (!firstChild || walker.nextSibling() || firstChild.nodeType !== Node.TEXT_NODE || - firstChild.nodeValue.length > gValueSummaryLength + firstChild.nodeValue.length > gValueSummaryLength || + isAssignedSlot ) { return undefined; } diff --git a/devtools/server/tests/browser/browser_inspector-shadow.js b/devtools/server/tests/browser/browser_inspector-shadow.js index 8675b3b14d7f..c374732ad894 100644 --- a/devtools/server/tests/browser/browser_inspector-shadow.js +++ b/devtools/server/tests/browser/browser_inspector-shadow.js @@ -115,3 +115,25 @@ add_task(async function() { is(closedShadowRoot.shadowRootMode, "closed", "#mode-closed has a shadow root with closed mode"); }); + +add_task(async function() { + info("Test that slotted inline text nodes appear in the Shadow DOM tree"); + const { walker } = await initInspectorFront(URL); + + const el = await walker.querySelector(walker.rootNode, "#slot-inline-text"); + const hostChildren = await walker.children(el); + const originalSlot = hostChildren.nodes[1]; + is(originalSlot.displayName, "#text", "Shadow host as a text node to be slotted"); + + const shadowRoot = hostChildren.nodes[0]; + const shadowChildren = await walker.children(shadowRoot); + const slot = shadowChildren.nodes[0]; + is(slot.displayName, "slot", "shadow-root has a slot child"); + ok(!slot._form.inlineTextChild, "Slotted node is not an inline text"); + + const slotChildren = await walker.children(slot); + const slotted = slotChildren.nodes[0]; + is(slotted.displayName, "#text", "Slotted node is a text node"); + is(slotted._form.nodeValue, originalSlot._form.nodeValue, + "Slotted content is the same as original's"); +}); diff --git a/devtools/server/tests/browser/inspector-shadow.html b/devtools/server/tests/browser/inspector-shadow.html index 6da30689b143..5d6fa37e5bf9 100644 --- a/devtools/server/tests/browser/inspector-shadow.html +++ b/devtools/server/tests/browser/inspector-shadow.html @@ -53,6 +53,14 @@ `; } }); + + customElements.define("test-simple-slot", class extends HTMLElement { + constructor() { + super(); + this.attachShadow({ mode: "open"}); + this.shadowRoot.innerHTML = ""; + } + }); };