Commit 3a0a74e1 authored by yoav@yoav.ws's avatar yoav@yoav.ws

Added a console warning when <picture><source src></picture> is used.

Following a discussion on the lack of support for <picture><source src></picture> 
that happened on https://github.com/ResponsiveImagesCG/picture-element/issues/224 
I would like to add a console warning to guide authors away from this pattern.

BUG=403260

Review URL: https://codereview.chromium.org/466353002

git-svn-id: svn://svn.chromium.org/blink/trunk@180187 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d5d73dee
CONSOLE WARNING: <source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead.
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
<picture>
<source src srcset>
<img>
</picture>
CONSOLE WARNING: <source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead.
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.dumpAsText();
</script>
<picture>
<source src>
<img>
</picture>
main frame - didStartProvisionalLoadForFrame main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame main frame - didCommitLoadForFrame
CONSOLE WARNING: <source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead.
main frame - didFinishDocumentLoadForFrame main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame main frame - didFinishLoadForFrame
main frame - didStartProvisionalLoadForFrame main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame main frame - didCommitLoadForFrame
CONSOLE WARNING: <source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead.
main frame - didFinishDocumentLoadForFrame main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame main frame - didFinishLoadForFrame
......
main frame - didStartProvisionalLoadForFrame main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame main frame - didCommitLoadForFrame
CONSOLE WARNING: <source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead.
main frame - didFinishDocumentLoadForFrame main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame main frame - didFinishLoadForFrame
......
...@@ -785,6 +785,9 @@ String UseCounter::deprecationMessage(Feature feature) ...@@ -785,6 +785,9 @@ String UseCounter::deprecationMessage(Feature feature)
case HTMLTableElementHspace: case HTMLTableElementHspace:
return "The 'hspace' attribute on table is deprecated. Please use CSS instead."; return "The 'hspace' attribute on table is deprecated. Please use CSS instead.";
case PictureSourceSrc:
return "<source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead.";
// Features that aren't deprecated don't have a deprecation message. // Features that aren't deprecated don't have a deprecation message.
default: default:
return String(); return String();
......
...@@ -488,6 +488,7 @@ public: ...@@ -488,6 +488,7 @@ public:
DevToolsConsoleTimeline = 517, DevToolsConsoleTimeline = 517,
DevToolsConsoleProfile = 518, DevToolsConsoleProfile = 518,
SVGStyleElementTitle = 519, SVGStyleElementTitle = 519,
PictureSourceSrc = 520,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
// Also, run update_use_counter_feature_enum.py in chromium/src/tools/metrics/histograms/ // Also, run update_use_counter_feature_enum.py in chromium/src/tools/metrics/histograms/
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "core/html/canvas/CanvasRenderingContext.h" #include "core/html/canvas/CanvasRenderingContext.h"
#include "core/html/parser/HTMLParserIdioms.h" #include "core/html/parser/HTMLParserIdioms.h"
#include "core/html/parser/HTMLSrcsetParser.h" #include "core/html/parser/HTMLSrcsetParser.h"
#include "core/inspector/ConsoleMessage.h"
#include "core/rendering/RenderImage.h" #include "core/rendering/RenderImage.h"
#include "platform/MIMETypeRegistry.h" #include "platform/MIMETypeRegistry.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
...@@ -282,6 +283,8 @@ ImageCandidate HTMLImageElement::findBestFitImageFromPictureParent() ...@@ -282,6 +283,8 @@ ImageCandidate HTMLImageElement::findBestFitImageFromPictureParent()
continue; continue;
HTMLSourceElement* source = toHTMLSourceElement(child); HTMLSourceElement* source = toHTMLSourceElement(child);
if (!source->fastGetAttribute(srcAttr).isNull())
UseCounter::countDeprecation(document(), UseCounter::PictureSourceSrc);
String srcset = source->fastGetAttribute(srcsetAttr); String srcset = source->fastGetAttribute(srcsetAttr);
if (srcset.isEmpty()) if (srcset.isEmpty())
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment