author | Edgar Chen <echen@mozilla.com> |
Sat, 16 Apr 2016 18:07:56 -0400 | |
changeset 316208 | 82d198b87307cbd4c6f2ced19bee980d819877aa |
parent 316153 | d2193462357aa9c9ac3acf6e01501f0dcc3cb749 |
child 316209 | 4f435a5a9ad06c507d79637bcd336cf7f9d3f955 |
push id | 30766 |
push user | philringnalda@gmail.com |
push date | Tue, 04 Oct 2016 03:09:34 +0000 |
treeherder | mozilla-central@c8a660c5f105 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jdm, smaug |
bugs | 1306007 |
milestone | 52.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/base/ResponsiveImageSelector.cpp +++ b/dom/base/ResponsiveImageSelector.cpp @@ -11,20 +11,16 @@ #include "nsPresContext.h" #include "nsCSSParser.h" #include "nsCSSProps.h" #include "nsIMediaList.h" #include "nsRuleNode.h" #include "nsRuleData.h" -// For IsPictureEnabled() -- the candidate parser needs to be aware of sizes -// support being enabled -#include "HTMLPictureElement.h" - using namespace mozilla; using namespace mozilla::dom; namespace mozilla { namespace dom { NS_IMPL_CYCLE_COLLECTION(ResponsiveImageSelector, mOwnerNode) @@ -552,18 +548,17 @@ ResponsiveImageDescriptors::AddDescripto aDescriptor.EndReading(descType); descType--; const nsDependentSubstring& valueStr = Substring(descStart, descType); if (*descType == char16_t('w')) { int32_t possibleWidth; // If the value is not a valid non-negative integer, it doesn't match this // descriptor, fall through. if (ParseInteger(valueStr, possibleWidth) && possibleWidth >= 0) { - if (possibleWidth != 0 && HTMLPictureElement::IsPictureEnabled() && - mWidth.isNothing() && mDensity.isNothing()) { + if (possibleWidth != 0 && mWidth.isNothing() && mDensity.isNothing()) { mWidth.emplace(possibleWidth); } else { // Valid width descriptor, but width or density were already seen, sizes // support isn't enabled, or it parsed to 0, which is an error per spec mInvalid = true; } return;
--- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -45,22 +45,18 @@ #include "nsIDOMHTMLMapElement.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventStates.h" #include "mozilla/net/ReferrerPolicy.h" #include "nsLayoutUtils.h" -#include "mozilla/Preferences.h" - using namespace mozilla::net; -static const char *kPrefSrcsetEnabled = "dom.image.srcset.enabled"; - NS_IMPL_NS_NEW_HTML_ELEMENT(Image) #ifdef DEBUG // Is aSubject a previous sibling of aNode. static bool IsPreviousSibling(nsINode *aSubject, nsINode *aNode) { if (aSubject == aNode) { return false; @@ -165,29 +161,19 @@ NS_IMPL_INT_ATTR(HTMLImageElement, Vspac bool HTMLImageElement::IsInteractiveHTMLContent(bool aIgnoreTabindex) const { return HasAttr(kNameSpaceID_None, nsGkAtoms::usemap) || nsGenericHTMLElement::IsInteractiveHTMLContent(aIgnoreTabindex); } -bool -HTMLImageElement::IsSrcsetEnabled() -{ - return Preferences::GetBool(kPrefSrcsetEnabled, false); -} - nsresult HTMLImageElement::GetCurrentSrc(nsAString& aValue) { - if (!IsSrcsetEnabled()) { - return NS_ERROR_FAILURE; - } - nsCOMPtr<nsIURI> currentURI; GetCurrentURI(getter_AddRefs(currentURI)); if (currentURI) { nsAutoCString spec; currentURI->GetSpec(spec); CopyUTF8toUTF16(spec, aValue); } else { SetDOMStringToNull(aValue); @@ -428,22 +414,20 @@ HTMLImageElement::AfterSetAttr(int32_t a mResponsiveSelector->SetDefaultSource(NullString()); } QueueImageLoadTask(true); } else { // Bug 1076583 - We still behave synchronously in the non-responsive case CancelImageRequests(aNotify); } } else if (aName == nsGkAtoms::srcset && - aNameSpaceID == kNameSpaceID_None && - IsSrcsetEnabled()) { + aNameSpaceID == kNameSpaceID_None) { PictureSourceSrcsetChanged(this, attrVal.String(), aNotify); } else if (aName == nsGkAtoms::sizes && - aNameSpaceID == kNameSpaceID_None && - HTMLPictureElement::IsPictureEnabled()) { + aNameSpaceID == kNameSpaceID_None) { PictureSourceSizesChanged(this, attrVal.String(), aNotify); } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, aNotify); } nsresult @@ -924,24 +908,20 @@ HTMLImageElement::QueueImageLoadTask(boo // queued event, and so earlier tasks are implicitly canceled. mPendingImageLoadTask = task; nsContentUtils::RunInStableState(task.forget()); } bool HTMLImageElement::HaveSrcsetOrInPicture() { - if (IsSrcsetEnabled() && HasAttr(kNameSpaceID_None, nsGkAtoms::srcset)) { + if (HasAttr(kNameSpaceID_None, nsGkAtoms::srcset)) { return true; } - if (!HTMLPictureElement::IsPictureEnabled()) { - return false; - } - Element *parent = nsINode::GetParentElement(); return (parent && parent->IsHTMLElement(nsGkAtoms::picture)); } bool HTMLImageElement::InResponsiveMode() { // When we lose srcset or leave a <picture> element, the fallback to img.src @@ -1022,24 +1002,18 @@ HTMLImageElement::LoadSelectedImage(bool return rv; } void HTMLImageElement::PictureSourceSrcsetChanged(nsIContent *aSourceNode, const nsAString& aNewValue, bool aNotify) { - bool isSelf = aSourceNode == this; - - if (!IsSrcsetEnabled() || - (!isSelf && !HTMLPictureElement::IsPictureEnabled())) { - return; - } - - MOZ_ASSERT(isSelf || IsPreviousSibling(aSourceNode, this), + MOZ_ASSERT(aSourceNode == this || + IsPreviousSibling(aSourceNode, this), "Should not be getting notifications for non-previous-siblings"); nsIContent *currentSrc = mResponsiveSelector ? mResponsiveSelector->Content() : nullptr; if (aSourceNode == currentSrc) { // We're currently using this node as our responsive selector // source. @@ -1059,20 +1033,16 @@ HTMLImageElement::PictureSourceSrcsetCha QueueImageLoadTask(true); } void HTMLImageElement::PictureSourceSizesChanged(nsIContent *aSourceNode, const nsAString& aNewValue, bool aNotify) { - if (!HTMLPictureElement::IsPictureEnabled()) { - return; - } - MOZ_ASSERT(aSourceNode == this || IsPreviousSibling(aSourceNode, this), "Should not be getting notifications for non-previous-siblings"); nsIContent *currentSrc = mResponsiveSelector ? mResponsiveSelector->Content() : nullptr; if (aSourceNode == currentSrc) { @@ -1085,70 +1055,52 @@ HTMLImageElement::PictureSourceSizesChan // we are not using this source. QueueImageLoadTask(true); } void HTMLImageElement::PictureSourceMediaOrTypeChanged(nsIContent *aSourceNode, bool aNotify) { - if (!HTMLPictureElement::IsPictureEnabled()) { - return; - } - MOZ_ASSERT(IsPreviousSibling(aSourceNode, this), "Should not be getting notifications for non-previous-siblings"); // This always triggers the image update steps per the spec, even if // we are not switching to/from this source QueueImageLoadTask(true); } void HTMLImageElement::PictureSourceAdded(nsIContent *aSourceNode) { - if (!HTMLPictureElement::IsPictureEnabled()) { - return; - } - MOZ_ASSERT(aSourceNode == this || IsPreviousSibling(aSourceNode, this), "Should not be getting notifications for non-previous-siblings"); QueueImageLoadTask(true); } void HTMLImageElement::PictureSourceRemoved(nsIContent *aSourceNode) { - if (!HTMLPictureElement::IsPictureEnabled()) { - return; - } - MOZ_ASSERT(aSourceNode == this || IsPreviousSibling(aSourceNode, this), "Should not be getting notifications for non-previous-siblings"); QueueImageLoadTask(true); } bool HTMLImageElement::UpdateResponsiveSource() { bool hadSelector = !!mResponsiveSelector; - if (!IsSrcsetEnabled()) { - mResponsiveSelector = nullptr; - return hadSelector; - } - nsIContent *currentSource = mResponsiveSelector ? mResponsiveSelector->Content() : nullptr; - bool pictureEnabled = HTMLPictureElement::IsPictureEnabled(); - Element *parent = pictureEnabled ? nsINode::GetParentElement() : nullptr; + Element *parent = nsINode::GetParentElement(); nsINode *candidateSource = nullptr; if (parent && parent->IsHTMLElement(nsGkAtoms::picture)) { // Walk source nodes previous to ourselves candidateSource = parent->GetFirstChild(); } else { candidateSource = this; } @@ -1226,17 +1178,16 @@ HTMLImageElement::SupportedPictureSource bool HTMLImageElement::SourceElementMatches(nsIContent* aSourceNode) { MOZ_ASSERT(aSourceNode->IsHTMLElement(nsGkAtoms::source)); DebugOnly<Element *> parent(nsINode::GetParentElement()); MOZ_ASSERT(parent && parent->IsHTMLElement(nsGkAtoms::picture)); MOZ_ASSERT(IsPreviousSibling(aSourceNode, this)); - MOZ_ASSERT(HTMLPictureElement::IsPictureEnabled()); // Check media and type HTMLSourceElement *src = static_cast<HTMLSourceElement*>(aSourceNode); if (!src->MatchesCurrentMedia()) { return false; } nsAutoString type; @@ -1248,21 +1199,16 @@ HTMLImageElement::SourceElementMatches(n return true; } bool HTMLImageElement::TryCreateResponsiveSelector(nsIContent *aSourceNode, const nsAString *aSrcset, const nsAString *aSizes) { - if (!IsSrcsetEnabled()) { - return false; - } - - bool pictureEnabled = HTMLPictureElement::IsPictureEnabled(); // Skip if this is not a <source> with matching media query bool isSourceTag = aSourceNode->IsHTMLElement(nsGkAtoms::source); if (isSourceTag) { if (!SourceElementMatches(aSourceNode)) { return false; } } else if (aSourceNode->IsHTMLElement(nsGkAtoms::img)) { // Otherwise this is the <img> tag itself @@ -1285,19 +1231,19 @@ HTMLImageElement::TryCreateResponsiveSel // Try to parse RefPtr<ResponsiveImageSelector> sel = new ResponsiveImageSelector(aSourceNode); if (!sel->SetCandidatesFromSourceSet(srcset)) { // No possible candidates, don't need to bother parsing sizes return false; } - if (pictureEnabled && aSizes) { + if (aSizes) { sel->SetSizesFromDescriptor(*aSizes); - } else if (pictureEnabled) { + } else { nsAutoString sizes; aSourceNode->GetAttr(kNameSpaceID_None, nsGkAtoms::sizes, sizes); sel->SetSizesFromDescriptor(sizes); } // If this is the <img> tag, also pull in src as the default source if (!isSourceTag) { MOZ_ASSERT(aSourceNode == this); @@ -1321,22 +1267,17 @@ HTMLImageElement::SelectSourceForTagWith const nsAString& aMediaAttr, nsAString& aResult) { MOZ_ASSERT(aIsSourceTag || (aTypeAttr.IsEmpty() && aMediaAttr.IsEmpty()), "Passing type or media attrs makes no sense without aIsSourceTag"); MOZ_ASSERT(!aIsSourceTag || aSrcAttr.IsEmpty(), "Passing aSrcAttr makes no sense with aIsSourceTag set"); - bool pictureEnabled = HTMLPictureElement::IsPictureEnabled(); - if (aIsSourceTag && !pictureEnabled) { - return false; - } - - if (!IsSrcsetEnabled() || aSrcsetAttr.IsEmpty()) { + if (aSrcsetAttr.IsEmpty()) { if (!aIsSourceTag) { // For an <img> with no srcset, we would always select the src attr. aResult.Assign(aSrcAttr); return true; } // Otherwise, a <source> without srcset is never selected return false; } @@ -1350,17 +1291,17 @@ HTMLImageElement::SelectSourceForTagWith return false; } // Using srcset or picture <source>, build a responsive selector for this tag. RefPtr<ResponsiveImageSelector> sel = new ResponsiveImageSelector(aDocument); sel->SetCandidatesFromSourceSet(aSrcsetAttr); - if (pictureEnabled && !aSizesAttr.IsEmpty()) { + if (!aSizesAttr.IsEmpty()) { sel->SetSizesFromDescriptor(aSizesAttr); } if (!aIsSourceTag) { sel->SetDefaultSource(aSrcAttr); } if (sel->GetSelectedImageURLSpec(aResult)) { return true;
--- a/dom/html/HTMLImageElement.h +++ b/dom/html/HTMLImageElement.h @@ -10,19 +10,16 @@ #include "mozilla/Attributes.h" #include "nsGenericHTMLElement.h" #include "nsImageLoadingContent.h" #include "nsIDOMHTMLImageElement.h" #include "imgRequestProxy.h" #include "Units.h" #include "nsCycleCollectionParticipant.h" -// Only needed for IsPictureEnabled() -#include "mozilla/dom/HTMLPictureElement.h" - namespace mozilla { class EventChainPreVisitor; namespace dom { class ImageLoadTask; class ResponsiveImageSelector; class HTMLImageElement final : public nsGenericHTMLElement, @@ -92,18 +89,16 @@ public: virtual EventStates IntrinsicState() const override; virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override; nsresult CopyInnerTo(Element* aDest); void MaybeLoadImage(); - static bool IsSrcsetEnabled(); - bool IsMap() { return GetBoolAttr(nsGkAtoms::ismap); } void SetIsMap(bool aIsMap, ErrorResult& aError) { SetHTMLBoolAttr(nsGkAtoms::ismap, aIsMap, aError); }
--- a/dom/html/HTMLPictureElement.cpp +++ b/dom/html/HTMLPictureElement.cpp @@ -3,28 +3,21 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/HTMLPictureElement.h" #include "mozilla/dom/HTMLPictureElementBinding.h" #include "mozilla/dom/HTMLImageElement.h" -#include "mozilla/Preferences.h" -static const char *kPrefPictureEnabled = "dom.image.picture.enabled"; - // Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Picture) to add pref check. nsGenericHTMLElement* NS_NewHTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, mozilla::dom::FromParser aFromParser) { - if (!mozilla::dom::HTMLPictureElement::IsPictureEnabled()) { - return new mozilla::dom::HTMLUnknownElement(aNodeInfo); - } - return new mozilla::dom::HTMLPictureElement(aNodeInfo); } namespace mozilla { namespace dom { HTMLPictureElement::HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo) : nsGenericHTMLElement(aNodeInfo) @@ -90,23 +83,16 @@ HTMLPictureElement::InsertChildAt(nsICon } } while ( (nextSibling = nextSibling->GetNextSibling()) ); } } return rv; } -bool -HTMLPictureElement::IsPictureEnabled() -{ - return HTMLImageElement::IsSrcsetEnabled() && - Preferences::GetBool(kPrefPictureEnabled, false); -} - JSObject* HTMLPictureElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return HTMLPictureElementBinding::Wrap(aCx, this, aGivenProto); } } // namespace dom } // namespace mozilla
--- a/dom/html/HTMLPictureElement.h +++ b/dom/html/HTMLPictureElement.h @@ -6,18 +6,16 @@ #ifndef mozilla_dom_HTMLPictureElement_h #define mozilla_dom_HTMLPictureElement_h #include "mozilla/Attributes.h" #include "nsIDOMHTMLPictureElement.h" #include "nsGenericHTMLElement.h" -#include "mozilla/dom/HTMLUnknownElement.h" - namespace mozilla { namespace dom { class HTMLPictureElement final : public nsGenericHTMLElement, public nsIDOMHTMLPictureElement { public: explicit HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo); @@ -27,18 +25,16 @@ public: // nsIDOMHTMLPictureElement NS_DECL_NSIDOMHTMLPICTUREELEMENT virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override; virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override; virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify) override; - static bool IsPictureEnabled(); - protected: virtual ~HTMLPictureElement(); virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; }; } // namespace dom } // namespace mozilla
--- a/dom/html/crashtests/crashtests.list +++ b/dom/html/crashtests/crashtests.list @@ -66,14 +66,14 @@ load 837033.html load 838256-1.html load 862084.html load 865147.html load 877910.html load 903106.html load 916322-1.html load 916322-2.html load 1032654.html -pref(dom.image.srcset.enabled,true) load 1141260.html +load 1141260.html load 1228876.html load 1230110.html load 1237633.html load 1281972-1.html load 1282894.html \ No newline at end of file
--- a/dom/html/reftests/reftest-stylo.list +++ b/dom/html/reftests/reftest-stylo.list @@ -43,18 +43,18 @@ random == responsive-image-load-shortcir # (Fuzzy necessary due to pixel-wise comparison of different JPEGs. # The vast majority of the fuzziness comes from Linux and WinXP.) skip == bug917595-iframe-1.html bug917595-iframe-1.html skip == bug917595-exif-rotated.jpg bug917595-exif-rotated.jpg # bug 1060869 # Bug 1150490 disabling on Mulet as on B2G # Test support for SVG-as-image in <picture> elements. -pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-1.html bug1106522-1.html -pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-2.html bug1106522-2.html +== bug1106522-1.html bug1106522-1.html +== bug1106522-2.html bug1106522-2.html == href-attr-change-restyles.html href-attr-change-restyles.html == figure.html figure.html == pre-1.html pre-1.html == table-border-1.html table-border-1.html == table-border-2.html table-border-2.html == table-border-2.html table-border-2.html
--- a/dom/html/reftests/reftest.list +++ b/dom/html/reftests/reftest.list @@ -39,18 +39,18 @@ skip-if(Android||B2G) == 649134-2.html 6 # Test that image documents taken into account CSS properties like # image-orientation when determining the size of the image. # (Fuzzy necessary due to pixel-wise comparison of different JPEGs. # The vast majority of the fuzziness comes from Linux and WinXP.) fuzzy(1,149) == bug917595-iframe-1.html bug917595-1-ref.html skip-if(B2G||Mulet) fuzzy-if((!B2G&&!Mulet),3,640) == bug917595-exif-rotated.jpg bug917595-pixel-rotated.jpg # bug 1060869 # Bug 1150490 disabling on Mulet as on B2G # Test support for SVG-as-image in <picture> elements. -pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-1.html bug1106522-ref.html -pref(dom.image.picture.enabled,true) pref(dom.image.srcset.enabled,true) == bug1106522-2.html bug1106522-ref.html +== bug1106522-1.html bug1106522-ref.html +== bug1106522-2.html bug1106522-ref.html == href-attr-change-restyles.html href-attr-change-restyles-ref.html == figure.html figure-ref.html == pre-1.html pre-1-ref.html == table-border-1.html table-border-1-ref.html == table-border-2.html table-border-2-ref.html != table-border-2.html table-border-2-notref.html
--- a/dom/security/test/mixedcontentblocker/test_main.html +++ b/dom/security/test/mixedcontentblocker/test_main.html @@ -161,26 +161,23 @@ https://bugzilla.mozilla.org/show_bug.cg checkTestsCompleted(); } function startTest() { // Set prefs to use mixed-content before HSTS SpecialPowers.pushPrefEnv({'set': [["security.mixed_content.use_hsts", false], ["security.mixed_content.send_hsts_priming", false]]}); //Set the first set of mixed content settings and increment the counter. - //Enable <picture> and <img srcset> for the test. - changePrefs([[ "dom.image.srcset.enabled", true ], [ "dom.image.picture.enabled", true ]], - function() { - //listen for a messages from the mixed content test harness - window.addEventListener("message", receiveMessage, false); + changePrefs([], function() { + //listen for a messages from the mixed content test harness + window.addEventListener("message", receiveMessage, false); - //Kick off test - reloadFrame(); - } - ); + //Kick off test + reloadFrame(); + }); } SimpleTest.waitForExplicitFinish(); </script> </head> <body onload='startTest()'>
--- a/dom/tests/mochitest/general/mochitest.ini +++ b/dom/tests/mochitest/general/mochitest.ini @@ -95,24 +95,22 @@ skip-if = ((buildapp == 'mulet' || build support-files = test_offsets.js [test_outerHTML.html] [test_outerHTML.xhtml] skip-if = buildapp == 'mulet' [test_paste_selection.html] skip-if = buildapp == 'mulet' [test_performance_timeline.html] [test_picture_mutations.html] -[test_picture_pref.html] skip-if = buildapp == 'b2g' || buildapp == 'mulet' [test_resource_timing.html] skip-if = buildapp == 'b2g' || buildapp == 'mulet' [test_resource_timing_cross_origin.html] skip-if = buildapp == 'b2g' || buildapp == 'mulet' [test_performance_now.html] -[test_srcset_pref.html] [test_showModalDialog.html] skip-if = e10s || buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' #Don't run modal tests on Android # b2g(showmodaldialog) b2g-debug(showmodaldialog) b2g-desktop(showmodaldialog) [test_showModalDialog_e10s.html] run-if = e10s [test_stylesheetPI.html] [test_vibrator.html] [test_windowProperties.html] skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
--- a/dom/tests/mochitest/general/test_img_mutations.html +++ b/dom/tests/mochitest/general/test_img_mutations.html @@ -213,18 +213,17 @@ // causing test failures. img.removeEventListener("load", onImgLoad); img.removeEventListener("error", onImgError); SimpleTest.finish(); } } addEventListener("load", function() { - SpecialPowers.pushPrefEnv({'set': [ ["layout.css.devPixelsPerPx", "1.0"], - [ "dom.image.srcset.enabled", true ]] }, + SpecialPowers.pushPrefEnv({'set': [["layout.css.devPixelsPerPx", "1.0"]] }, function() { // Create this after the pref is set, as it is guarding webIDL attributes img = document.createElement("img"); img.addEventListener("load", onImgLoad); img.addEventListener("error", onImgError); document.body.appendChild(img); setTimeout(nextTest, 0); });
--- a/dom/tests/mochitest/general/test_picture_mutations.html +++ b/dom/tests/mochitest/general/test_picture_mutations.html @@ -288,19 +288,17 @@ // Ignore it all. img.removeEventListener("load", onImgLoad); img.removeEventListener("error", onImgError); SimpleTest.finish(); } } addEventListener("load", function() { - SpecialPowers.pushPrefEnv({'set': [ ["layout.css.devPixelsPerPx", "1.0" ], - [ "dom.image.srcset.enabled", true ], - [ "dom.image.picture.enabled", true ]] }, + SpecialPowers.pushPrefEnv({'set': [["layout.css.devPixelsPerPx", "1.0" ]] }, function() { // Create these after the pref is set, as it is guarding webIDL attributes img = document.createElement("img"); img.addEventListener("load", onImgLoad); img.addEventListener("error", onImgError); picture = document.createElement("picture"); source1 = document.createElement("source"); source2 = document.createElement("source");
deleted file mode 100644 --- a/dom/tests/mochitest/general/test_picture_pref.html +++ /dev/null @@ -1,108 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=870022 ---> -<head> - <title>Test for dom.image.picture.enabled (Bug 870022)</title> - <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body onload="setupTest()"> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870022">Mozilla Bug 870022</a> - -<!-- Tests that the picture pref can still be disabled, accounting - for dom.images.srcset.enabled being flipped on in the mean time. --> - -<!-- these should all load red.png (naturalWidth 1) not big.png (natural - width 3000) regardless of dom.images.srcset.enabled being on or off --> - -<div id="testContainer"> -<picture> - <source srcset="http://example.com/tests/image/test/mochitest/big.png"> - <img id="img1" src="http://example.com/tests/image/test/mochitest/red.png"> -</picture> - -<picture> - <source srcset="http://example.com/tests/image/test/mochitest/big.png 500w" - sizes="500w"> - <img id="img2" - src="http://example.com/tests/image/test/mochitest/red.png" - srcset="http://example.com/tests/image/test/mochitest/big.png 500w" - sizes="50px"> -</picture> - -<!-- Should load red.png with srcset on, otherwise nothing --> -<img id="img-srcset-only" - srcset="http://example.com/tests/image/test/mochitest/big.png 500w, http://example.com/tests/image/test/mochitest/red.png 1x" - sizes="50px"> - -<!-- Should not load regardless of srcset pref --> -<img id="img-never" - srcset="http://example.com/tests/image/test/mochitest/big.png 500w" - sizes="50px"> -</div> - -<script type="application/javascript"> - - const srcsetPref = 'dom.image.srcset.enabled'; - const picturePref = 'dom.image.picture.enabled'; - - SimpleTest.waitForExplicitFinish(); - - var srcsetEnabled = SpecialPowers.getBoolPref(srcsetPref); - var pictureEnabled = SpecialPowers.getBoolPref(picturePref); - - is(pictureEnabled, true, "picture expected to be enabled by default"); - - function setupTest() { - SpecialPowers.pushPrefEnv({'set': [[ "dom.image.picture.enabled", false ]] }, function() { - var container = document.querySelector("#testContainer"); - // We want to re-create the elements with the pref disabled to ensure - // webIDL attributes are not attached - var iframe = document.createElement("iframe"); - iframe.addEventListener("load", function() { - runTest(iframe); - }); - document.body.appendChild(iframe); - iframe.src = "data:text/html;base64," + btoa(container.innerHTML); - }); - } - - function runTest(iframe) { - var doc = iframe.contentDocument; - var win = iframe.contentWindow; - var img = doc.querySelector("img"); - var source = doc.querySelector("source"); - - is(img.sizes, undefined, "sizes should not be visible on <img>"); - is(source.sizes, undefined, "sizes should not be visible on <source>"); - is(source.srcset, undefined, "srcset should not be visible on <source>"); - - var imgSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLImageElement.prototype, "sizes"); - var sourceSizesDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "sizes"); - var sourceSrcsetDesc = Object.getOwnPropertyDescriptor(win.HTMLSourceElement.prototype, "srcset"); - is(imgSizesDesc, undefined, "HTMLImageElement should know nothing of sizes"); - is(sourceSizesDesc, undefined, "HTMLSourceElement should know nothing of sizes"); - is(sourceSrcsetDesc, undefined, "HTMLSourceElement should know nothing of srcset"); - - // Make sure the test images loaded red.png, which is 1x1, not big.png - for (var id of [ 'img1', 'img2' ]) { - var testImg = doc.getElementById(id); - is(testImg.naturalWidth, 1, "Image should have loaded small source"); - } - - var srcsetOnlyImg = doc.getElementById("img-srcset-only"); - is(srcsetOnlyImg.naturalWidth, srcsetEnabled ? 1 : 0, - "srcset image should only load if srcset is enabled, and never the computed width candidate"); - - var neverImg = doc.getElementById("img-never"); - is(neverImg.naturalWidth, 0, "Image should not have loaded"); - - SimpleTest.finish(); - } - -</script> - -</body> -</html>
deleted file mode 100644 --- a/dom/tests/mochitest/general/test_srcset_pref.html +++ /dev/null @@ -1,59 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=870021 ---> -<head> - <title>Test for dom.image.srcset.enabled (Bug 870021)</title> - <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body onload="setupTest()"> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=870021">Mozilla Bug 870021</a> - -<div id="imgContainer"> -</div> - -<script type="application/javascript"> - - const srcsetPref = 'dom.image.srcset.enabled'; - - SimpleTest.waitForExplicitFinish(); - - is(SpecialPowers.getBoolPref(srcsetPref), true, "srcset should be enabled by default"); - - function setupTest() { - // Ensure that disabling the pref works as expected - SpecialPowers.pushPrefEnv({'set': [[ "dom.image.srcset.enabled", false ]] }, function() { - var container = document.querySelector("#imgContainer"); - - var img = document.createElement("img"); - img.setAttribute("src", "http://example.com/tests/image/test/mochitest/blue.png"); - img.setAttribute("srcset", "http://example.com/tests/image/test/mochitest/big.png"); - container.insertBefore(img, container.firstChild); - img.addEventListener("load", function imgLoad() { - img.removeEventListener("load", imgLoad); - runTest(); - }); - }); - } - - function runTest() { - var img = document.querySelector("img"); - is(img.currentSrc, undefined, "currentSrc should not be visible"); - is(img.srcset, undefined, "srcset should not be visible"); - - var currentSrcDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, "currentSrc"); - var srcsetDesc = Object.getOwnPropertyDescriptor(HTMLImageElement.prototype, "srcset"); - is(currentSrcDesc, undefined, "HTMLImageElement should know nothing of currentSrc"); - is(srcsetDesc, undefined, "HTMLImageElement should know nothing of srcset"); - - // Make sure the test image loaded the src image, which is 1x1, not the srcset image - is(img.naturalWidth, 1, "Image should have loaded small source"); - SimpleTest.finish(); - } - -</script> - -</body> -</html>
--- a/dom/webidl/HTMLImageElement.webidl +++ b/dom/webidl/HTMLImageElement.webidl @@ -17,17 +17,17 @@ interface URI; interface nsIStreamListener; [NamedConstructor=Image(optional unsigned long width, optional unsigned long height)] interface HTMLImageElement : HTMLElement { [SetterThrows] attribute DOMString alt; [SetterThrows] attribute DOMString src; - [SetterThrows, Pref="dom.image.srcset.enabled"] + [SetterThrows] attribute DOMString srcset; [SetterThrows] attribute DOMString? crossOrigin; [SetterThrows] attribute DOMString useMap; [SetterThrows, Pref="network.http.enablePerElementReferrer"] attribute DOMString referrerPolicy; [SetterThrows] @@ -55,19 +55,18 @@ partial interface HTMLImageElement { attribute DOMString longDesc; [TreatNullAs=EmptyString,SetterThrows] attribute DOMString border; }; // [Update me: not in whatwg spec yet] // http://picture.responsiveimages.org/#the-img-element partial interface HTMLImageElement { - [SetterThrows, Pref="dom.image.picture.enabled"] + [SetterThrows] attribute DOMString sizes; - [Pref="dom.image.srcset.enabled"] readonly attribute DOMString currentSrc; }; // Mozilla extensions. partial interface HTMLImageElement { attribute DOMString lowsrc; // These attributes are offsets from the closest view (to mimic
--- a/dom/webidl/HTMLPictureElement.webidl +++ b/dom/webidl/HTMLPictureElement.webidl @@ -1,9 +1,8 @@ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -[Pref="dom.image.picture.enabled"] interface HTMLPictureElement : HTMLElement { };
--- a/dom/webidl/HTMLSourceElement.webidl +++ b/dom/webidl/HTMLSourceElement.webidl @@ -14,15 +14,15 @@ interface HTMLSourceElement : HTMLElement { [SetterThrows] attribute DOMString src; [SetterThrows] attribute DOMString type; }; partial interface HTMLSourceElement { - [SetterThrows, Pref="dom.image.picture.enabled"] + [SetterThrows] attribute DOMString srcset; - [SetterThrows, Pref="dom.image.picture.enabled"] + [SetterThrows] attribute DOMString sizes; [SetterThrows] attribute DOMString media; };
--- a/dom/workers/test/serviceworkers/test_request_context.js +++ b/dom/workers/test/serviceworkers/test_request_context.js @@ -61,16 +61,14 @@ function runTest() { SimpleTest.waitForExplicitFinish(); onload = function() { SpecialPowers.pushPrefEnv({"set": [ ["beacon.enabled", true], ["browser.send_pings", true], ["browser.send_pings.max_per_link", -1], ["dom.caches.enabled", true], - ["dom.image.picture.enabled", true], - ["dom.image.srcset.enabled", true], ["dom.requestcontext.enabled", true], ["dom.serviceWorkers.exemptFromPerDomainMax", true], ["dom.serviceWorkers.enabled", true], ["dom.serviceWorkers.testing.enabled", true], ]}, runTest); };
--- a/layout/reftests/image/reftest-stylo.list +++ b/layout/reftests/image/reftest-stylo.list @@ -116,22 +116,22 @@ skip == image-srcset-basic-selection-2x. skip == image-srcset-basic-selection-0.5x.html image-srcset-basic-selection-0.5x.html skip == image-srcset-basic-selection-0.6x.html image-srcset-basic-selection-0.6x.html skip == image-srcset-basic-selection-1.5x.html image-srcset-basic-selection-1.5x.html skip == image-srcset-basic-selection-1x.html image-srcset-basic-selection-1x.html skip == image-srcset-basic-selection-width-0.5x.html image-srcset-basic-selection-width-0.5x.html skip == image-srcset-basic-selection-width-10x.html image-srcset-basic-selection-width-10x.html skip == image-srcset-basic-selection-width-2x.html image-srcset-basic-selection-width-2x.html skip == image-srcset-basic-selection-width-1x.html image-srcset-basic-selection-width-1x.html -pref(dom.image.srcset.enabled,true) == image-srcset-default-2x.html image-srcset-default-2x.html -pref(dom.image.srcset.enabled,true) == image-srcset-default-1x.html image-srcset-default-1x.html -pref(dom.image.srcset.enabled,true) == image-srcset-default-src-2x.html image-srcset-default-src-2x.html -pref(dom.image.srcset.enabled,true) == image-srcset-default-src-1x.html image-srcset-default-src-1x.html -pref(dom.image.srcset.enabled,true) == image-srcset-orientation-2x.html image-srcset-orientation-2x.html -pref(dom.image.srcset.enabled,true) == image-srcset-orientation-1x.html image-srcset-orientation-1x.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-3x.html image-srcset-svg-3x.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-2x.html image-srcset-svg-2x.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-1x.html image-srcset-svg-1x.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-default-2x.html image-srcset-svg-default-2x.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-default-1x.html image-srcset-svg-default-1x.html +== image-srcset-default-2x.html image-srcset-default-2x.html +== image-srcset-default-1x.html image-srcset-default-1x.html +== image-srcset-default-src-2x.html image-srcset-default-src-2x.html +== image-srcset-default-src-1x.html image-srcset-default-src-1x.html +== image-srcset-orientation-2x.html image-srcset-orientation-2x.html +== image-srcset-orientation-1x.html image-srcset-orientation-1x.html +== image-srcset-svg-3x.html image-srcset-svg-3x.html +== image-srcset-svg-2x.html image-srcset-svg-2x.html +== image-srcset-svg-1x.html image-srcset-svg-1x.html +== image-srcset-svg-default-2x.html image-srcset-svg-default-2x.html +== image-srcset-svg-default-1x.html image-srcset-svg-default-1x.html == image-resize-percent-height.html image-resize-percent-height.html == image-resize-percent-width.html image-resize-percent-width.html
--- a/layout/reftests/image/reftest.list +++ b/layout/reftests/image/reftest.list @@ -97,32 +97,32 @@ fuzzy(1,1) == image-orientation-backgrou != image-orientation-generated-content-ref.html?180 image-orientation-generated-content-ref.html?270 != image-orientation-generated-content-ref.html?0 image-orientation-generated-content-ref.html?0&flip != image-orientation-generated-content-ref.html?90 image-orientation-generated-content-ref.html?90&flip != image-orientation-generated-content-ref.html?180 image-orientation-generated-content-ref.html?180&flip != image-orientation-generated-content-ref.html?270 image-orientation-generated-content-ref.html?270&flip == image-orientation-dynamic.html image-orientation-dynamic-ref.html # <img srcset> tests -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-0.1x.html image-srcset-basic-selection-0.1x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-2x.html image-srcset-basic-selection-2x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-0.5x.html image-srcset-basic-selection-0.5x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-0.6x.html image-srcset-basic-selection-0.6x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-1.5x.html image-srcset-basic-selection-1.5x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-1x.html image-srcset-basic-selection-1x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-width-0.5x.html image-srcset-basic-selection-width-0.5x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-width-10x.html image-srcset-basic-selection-width-10x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-width-2x.html image-srcset-basic-selection-width-2x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-basic-selection-width-1x.html image-srcset-basic-selection-width-1x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-default-2x.html image-srcset-default-2x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-default-1x.html image-srcset-default-1x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-default-src-2x.html image-srcset-default-src-2x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-default-src-1x.html image-srcset-default-src-1x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-orientation-2x.html image-srcset-orientation-2x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-orientation-1x.html image-srcset-orientation-1x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-3x.html image-srcset-svg-3x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-2x.html image-srcset-svg-2x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-1x.html image-srcset-svg-1x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-default-2x.html image-srcset-svg-default-2x-ref.html -pref(dom.image.srcset.enabled,true) == image-srcset-svg-default-1x.html image-srcset-svg-default-1x-ref.html +== image-srcset-basic-selection-0.1x.html image-srcset-basic-selection-0.1x-ref.html +== image-srcset-basic-selection-2x.html image-srcset-basic-selection-2x-ref.html +== image-srcset-basic-selection-0.5x.html image-srcset-basic-selection-0.5x-ref.html +== image-srcset-basic-selection-0.6x.html image-srcset-basic-selection-0.6x-ref.html +== image-srcset-basic-selection-1.5x.html image-srcset-basic-selection-1.5x-ref.html +== image-srcset-basic-selection-1x.html image-srcset-basic-selection-1x-ref.html +== image-srcset-basic-selection-width-0.5x.html image-srcset-basic-selection-width-0.5x-ref.html +== image-srcset-basic-selection-width-10x.html image-srcset-basic-selection-width-10x-ref.html +== image-srcset-basic-selection-width-2x.html image-srcset-basic-selection-width-2x-ref.html +== image-srcset-basic-selection-width-1x.html image-srcset-basic-selection-width-1x-ref.html +== image-srcset-default-2x.html image-srcset-default-2x-ref.html +== image-srcset-default-1x.html image-srcset-default-1x-ref.html +== image-srcset-default-src-2x.html image-srcset-default-src-2x-ref.html +== image-srcset-default-src-1x.html image-srcset-default-src-1x-ref.html +== image-srcset-orientation-2x.html image-srcset-orientation-2x-ref.html +== image-srcset-orientation-1x.html image-srcset-orientation-1x-ref.html +== image-srcset-svg-3x.html image-srcset-svg-3x-ref.html +== image-srcset-svg-2x.html image-srcset-svg-2x-ref.html +== image-srcset-svg-1x.html image-srcset-svg-1x-ref.html +== image-srcset-svg-default-2x.html image-srcset-svg-default-2x-ref.html +== image-srcset-svg-default-1x.html image-srcset-svg-default-1x-ref.html == image-resize-percent-height.html image-resize-ref.html == image-resize-percent-width.html image-resize-ref.html
--- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4723,22 +4723,16 @@ pref("layout.animated-image-layers.enabl pref("dom.vibrator.enabled", true); pref("dom.vibrator.max_vibrate_ms", 10000); pref("dom.vibrator.max_vibrate_list_len", 128); // Battery API pref("dom.battery.enabled", true); -// Image srcset -pref("dom.image.srcset.enabled", true); - -// <picture> element and sizes -pref("dom.image.picture.enabled", true); - // WebSMS pref("dom.sms.enabled", false); // Enable Latin characters replacement with corresponding ones in GSM SMS // 7-bit default alphabet. pref("dom.sms.strict7BitEncoding", false); pref("dom.sms.requestStatusReport", true); // Numeric default service id for SMS API calls with |serviceId| parameter // omitted.