summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobhogan@gmail.com <robhogan@gmail.com>2014-12-09 19:37:55 +0000
committerrobhogan@gmail.com <robhogan@gmail.com>2014-12-09 19:37:55 +0000
commit1717cf4bfefc8504ff6971d2e8fab1e14ea462bb (patch)
treeb46ada8f6f287ee74240b9e08e52c3e9256f3172
parentf7ccb9ee30e9f3186e58c3ecae3eb6387baf7eae (diff)
downloadchromium_src-1717cf4bfefc8504ff6971d2e8fab1e14ea462bb.zip
chromium_src-1717cf4bfefc8504ff6971d2e8fab1e14ea462bb.tar.gz
chromium_src-1717cf4bfefc8504ff6971d2e8fab1e14ea462bb.tar.bz2
Use Shadow DOM to display fallback content for images
This replaces the use of painting in RenderImage to display an image's alt text with an implementation in shadow DOM. This initial implementation is close in appearance to the legacy display of alt-text but will ultimately move closer to the one seen in Firefox and described in http://hixie.ch/specs/alttext. The alt-text and broken-image icon is now rendered as: <style> #alttext-container { overflow: hidden; border: 1px solid silver; padding: 1px; display: inline-block; } #alttext { display: none; overflow: hidden;} </style> <div id="alttext-container"> <img src="data:png, [broken-image-icon]" width="16" height="16" align="left" style="margin: 0px"> <div id="alt-text">Alt text in here</div> </div> Some notes on the way the fallback content is now rendered: - The fallback content is rendered inside an inline-block so it does not calculate its dimensions the way a replaced element (i.e. an image) would (as defined by http://www.w3.org/TR/CSS2/visudet.html#inline-replaced-width). So where one of width or height is auto but the other is not, the fallback content will not exactly match the dimensions calculated by RenderImage in error mode currently. We do a modest imitation of the logic in quirks mode, but in strict mode it will behave exactly like an inline-block. - Where the image has no src attribute and no alt attribute RenderImage.cpp still looks after the painting of the element - no fallback content is generated and no broken image is displayed. This is consistent with existing behaviour. - The only image resource requests that still use the synchronous load path are those where the item is cached (and didn't error out), where its the fallback image for an object element, or where it's the image for a main resource load. All other image loads are now asynchronous so that fallback content can be loaded outside the style recalc phase. - Instead of aborting an image resource request when the src element is empty (i.e. src='') we now allow the request to go through so that it can fail and invoke the fallback content in HTMLImageLoader.cpp. - As you can see in the new result for fast/borders/rtl-border-05.html, since the alt-text is displayed as an inline-block it no longer artificially shrinks any border on the element to the broken-image icon. Some notes on the rebaselined test results: - I've modified inspector/network/network-image-404.html to output the state of both the resource requests, i.e. the failed one and the resource request for the data:png to display the broken image icon. - I've added a missing support file for fast/css/counters/complex-before.html - its absence meant that the result was polluted by the behaviour of broken image rendering. - Likewise for fast/images/imagemap-polygon* tests - our new rendering of failed image loads was interfering with an assumption in the tests that a broken image still painted a RenderImage. So I've removed the src attribute to allow the assumption hold (img elements without a src attribute are painted by RenderImage). - I have altered fast/forms/state-restore-to-non-edited-controls.html to wait 100ms before submitting the form as the image load in the input element is now asynchronous. Likewise for fast/forms/basic-buttons.html. - I did the same to svg/canvas/canvas-draw-image-globalalpha.html and fast/canvas/canvas-drawImage-out-of-bounds-src.html. Since all image loads that might need alt content are performed asynchronously canvas.drawImage() now needs to ensure the content has loaded before drawing. - http/tests/security/local-image-from-remote-whitelisted.html has been masking a bug - blink does not load the image even though it is whitelisted. I am rebaselining the test to reflect the failure revealed by this CL and tracking a fix under crbug.com/410949. - As the alt text is now always exposed if the image doesn't load, any input elements that use an image will show the default alt title 'Submit'. This shows up in the accessibility unit tests in content_browsertests. I plan to rebaseline these in a separate CL. Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=185847 Review URL: https://codereview.chromium.org/481753002 git-svn-id: svn://svn.chromium.org/blink/trunk@186800 bbb929c8-8fbe-4397-9dbb-9b2b20218538
-rw-r--r--third_party/WebKit/LayoutTests/TestExpectations151
-rw-r--r--third_party/WebKit/LayoutTests/fast/css/counters/support/square-outline-32x32.pngbin0 -> 96 bytes
-rw-r--r--third_party/WebKit/LayoutTests/fast/forms/state-restore-to-non-edited-controls.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/alt-text-wrapping.html1
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-circle-focus-ring.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-explicitly-inherited-from-map.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-not-inherited-from-map.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style-expected.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-nested-area.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-circle-focus-ring.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-polygon-focus-ring.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/images/imagemap-polygon-focus-ring.html2
-rw-r--r--third_party/WebKit/LayoutTests/http/tests/inspector/network/network-image-404.html10
-rw-r--r--third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/image-blocked-alt-content-expected.txt17
-rw-r--r--third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/image-blocked-alt-content.html10
-rw-r--r--third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-icon-hidpi-expected.pngbin0 -> 20335 bytes
-rw-r--r--third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-icon-hidpi-expected.txt5
-rw-r--r--third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-with-size-hidpi-expected.pngbin0 -> 19949 bytes
-rw-r--r--third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-with-size-hidpi-expected.txt5
-rw-r--r--third_party/WebKit/LayoutTests/platform/linux/fast/images/alt-text-wrapping-expected.pngbin0 -> 7392 bytes
-rw-r--r--third_party/WebKit/LayoutTests/platform/linux/fast/images/alt-text-wrapping-expected.txt18
-rw-r--r--third_party/WebKit/LayoutTests/platform/linux/http/tests/security/contentSecurityPolicy/image-blocked-alt-content-expected.pngbin0 -> 8299 bytes
-rw-r--r--third_party/WebKit/Source/core/core.gypi2
-rw-r--r--third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp6
-rw-r--r--third_party/WebKit/Source/core/editing/TextIterator.cpp9
-rw-r--r--third_party/WebKit/Source/core/fetch/ImageResource.cpp3
-rw-r--r--third_party/WebKit/Source/core/html/HTMLElement.h2
-rw-r--r--third_party/WebKit/Source/core/html/HTMLImageElement.cpp90
-rw-r--r--third_party/WebKit/Source/core/html/HTMLImageElement.h14
-rw-r--r--third_party/WebKit/Source/core/html/HTMLImageFallbackHelper.cpp112
-rw-r--r--third_party/WebKit/Source/core/html/HTMLImageFallbackHelper.h23
-rw-r--r--third_party/WebKit/Source/core/html/HTMLImageLoader.cpp49
-rw-r--r--third_party/WebKit/Source/core/html/HTMLImageLoader.h4
-rw-r--r--third_party/WebKit/Source/core/html/HTMLInputElement.cpp18
-rw-r--r--third_party/WebKit/Source/core/html/HTMLInputElement.h7
-rw-r--r--third_party/WebKit/Source/core/html/forms/BaseButtonInputType.h2
-rw-r--r--third_party/WebKit/Source/core/html/forms/ImageInputType.cpp91
-rw-r--r--third_party/WebKit/Source/core/html/forms/ImageInputType.h10
-rw-r--r--third_party/WebKit/Source/core/html/forms/InputTypeView.h3
-rw-r--r--third_party/WebKit/Source/core/loader/ImageLoader.cpp33
-rw-r--r--third_party/WebKit/Source/core/loader/ImageLoader.h11
-rw-r--r--third_party/WebKit/Source/core/paint/ImagePainter.cpp68
-rw-r--r--third_party/WebKit/Source/core/rendering/RenderBox.cpp2
-rw-r--r--third_party/WebKit/Source/core/rendering/RenderImage.cpp79
-rw-r--r--third_party/WebKit/Source/core/rendering/RenderImage.h10
-rw-r--r--third_party/WebKit/Source/modules/accessibility/AXRenderObject.cpp15
50 files changed, 673 insertions, 233 deletions
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index f87211c8..d910139 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -848,7 +848,7 @@ crbug.com/393523 [ Mac Release ] http/tests/misc/submit-post-keygen.html [ Pass
crbug.com/362047 [ Mac Linux ] mhtml/mhtml_in_iframe.html [ Crash Pass ]
crbug.com/362073 [ Mac Debug ] fast/dom/shadow/input-color-in-content.html [ Crash Pass ]
-crbug.com/365400 [ Mac ] compositing/images/direct-pdf-image.html [ Pass ImageOnlyFailure ]
+crbug.com/365400 [ Mac ] compositing/images/direct-pdf-image.html [ Failure ]
crbug.com/306222 fast/hidpi/image-srcset-relative-svg-canvas.html [ Skip ]
crbug.com/306222 fast/hidpi/image-srcset-relative-svg-canvas-2x.html [ Skip ]
@@ -1021,6 +1021,155 @@ crbug.com/350853 fast/multicol/widows2.html [ Skip ]
crbug.com/350853 fast/pagination/auto-height.html [ Skip ]
crbug.com/350853 fast/pagination/auto-height-with-break.html [ Skip ]
+crbug.com/419101 http/tests/security/contentSecurityPolicy/report-and-enforce.html [ NeedsRebaseline ]
+crbug.com/419101 [ Mac Linux ] http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies.html [ NeedsRebaseline ]
+crbug.com/419101 [ Win Debug ] http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/mixedContent/preload-insecure-image-in-main-frame-blocked.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/table/007.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/table/008.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/alt-text-wrapping.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/alt-text-wrapping.html [ NeedsRebaseline ]
+crbug.com/419101 compositing/color-matching/pdf-image-match.html [ NeedsRebaseline ]
+crbug.com/419101 css1/box_properties/float_elements_in_series.html [ NeedsRebaseline ]
+crbug.com/419101 editing/execCommand/insertImage.html [ NeedsRebaseline ]
+crbug.com/419101 editing/pasteboard/drag-image-to-contenteditable-in-iframe.html [ NeedsRebaseline ]
+crbug.com/419101 editing/selection/select-missing-image.html [ NeedsRebaseline ]
+crbug.com/419101 fast/block/float/002.html [ NeedsRebaseline ]
+crbug.com/419101 fast/block/float/017.html [ NeedsRebaseline ]
+crbug.com/419101 fast/block/positioning/001.html [ NeedsRebaseline ]
+crbug.com/419101 fast/block/positioning/058.html [ NeedsRebaseline ]
+crbug.com/419101 fast/block/positioning/061.html [ NeedsRebaseline ]
+crbug.com/419101 fast/borders/rtl-border-05.html [ NeedsRebaseline ]
+crbug.com/419101 fast/dom/34176.html [ NeedsRebaseline ]
+crbug.com/419101 fast/dom/HTMLAnchorElement/anchor-ismap-crash.html [ NeedsRebaseline ]
+crbug.com/419101 fast/dom/HTMLImageElement/image-alt-text.html [ NeedsRebaseline ]
+crbug.com/419101 fast/dom/HTMLImageElement/image-sizes-js-change.html [ NeedsRebaseline ]
+crbug.com/419101 fast/dom/HTMLInputElement/input-image-alt-text.html [ NeedsRebaseline ]
+crbug.com/419101 fast/dom/HTMLLinkElement/link-and-subresource-test-nonexistent.html [ NeedsRebaseline ]
+crbug.com/419101 fast/dom/Range/range-clone-contents.html [ NeedsRebaseline ]
+crbug.com/419101 fast/dom/inner-text.html [ NeedsRebaseline ]
+crbug.com/419101 fast/dynamic/float-from-empty-line.html [ NeedsRebaseline ]
+crbug.com/419101 fast/encoding/utf-16-big-endian.html [ NeedsRebaseline ]
+crbug.com/419101 fast/encoding/utf-16-little-endian.html [ NeedsRebaseline ]
+crbug.com/419101 fast/events/domactivate-sets-underlying-click-event-as-handled.html [ NeedsRebaseline ]
+crbug.com/419101 fast/flexbox/023.html [ NeedsRebaseline ]
+crbug.com/419101 fast/flexbox/024.html [ NeedsRebaseline ]
+crbug.com/419101 fast/forms/002.html [ NeedsRebaseline ]
+crbug.com/419101 fast/forms/005.html [ NeedsRebaseline ]
+crbug.com/419101 fast/forms/input-value.html [ NeedsRebaseline ]
+crbug.com/419101 fast/hidpi/broken-image-icon-hidpi.html [ NeedsRebaseline ]
+crbug.com/419101 fast/hidpi/broken-image-with-size-hidpi.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/55.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/image-error-event-not-firing.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/image-in-map.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-circle-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-focus-ring-outline-color-explicitly-inherited-from-map.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-focus-ring-outline-color-not-inherited-from-map.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-focus-ring-outline-color.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-focus-ring-zoom.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-nested-area.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-overflowing-circle-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-overflowing-polygon-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 fast/images/imagemap-polygon-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 fast/invalid/012.html [ NeedsRebaseline ]
+crbug.com/419101 fast/invalid/016.html [ NeedsRebaseline ]
+crbug.com/419101 fast/lists/inlineBoxWrapperNullCheck.html [ NeedsRebaseline ]
+crbug.com/419101 fast/loader/resource-request-callbacks.html [ NeedsRebaseline ]
+crbug.com/419101 fast/media/media-svg-crash.html [ NeedsRebaseline ]
+crbug.com/419101 fast/overflow/infiniteRecursion.html [ NeedsRebaseline ]
+crbug.com/419101 fast/parser/comment-in-script.html [ NeedsRebaseline ]
+crbug.com/419101 fast/table/007.html [ NeedsRebaseline ]
+crbug.com/419101 fast/table/008.html [ NeedsRebaseline ]
+crbug.com/419101 fast/text-autosizing/tables/nested-tables.html [ NeedsRebaseline ]
+crbug.com/419101 fast/text/bidi-img-alt-text.html [ NeedsRebaseline ]
+crbug.com/419101 fast/text/whitespace/normal-after-nowrap-breaking.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/inspector/network/network-image-404.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/inspector/network/network-initiator.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/loading/preload-picture-invalid.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/loading/preload-picture-nested.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/misc/image-blocked-src-no-change.html [ NeedsRebaseline ]
+crbug.com/419101 [ Mac ] http/tests/misc/image-blocked-src-change.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/misc/xslt-bad-import.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/contentSecurityPolicy/image-blocked.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/contentSecurityPolicy/report-multiple-violations-01.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/contentSecurityPolicy/xsl-img-blocked.php [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/contentTypeOptions/nosniff-script-without-content-type-blocked.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/local-image-from-remote-whitelisted.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/mixedContent/insecure-empty-srcset-in-main-frame-blocked.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/mixedContent/insecure-image-in-iframe.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/mixedContent/insecure-image-in-main-frame-allowed.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/mixedContent/insecure-image-in-main-frame-blocked.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/mixedContent/insecure-image-in-main-frame.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/mixedContent/insecure-picture-in-main-frame-blocked.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/mixedContent/insecure-srcset-in-main-frame-blocked.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/serviceworker/fetch-csp.html [ NeedsRebaseline ]
+crbug.com/419101 inspector/extensions/extensions-network.html [ NeedsRebaseline ]
+crbug.com/419101 security/block-test-no-port.html [ NeedsRebaseline ]
+crbug.com/419101 security/block-test.html [ NeedsRebaseline ]
+crbug.com/419101 svg/as-image/svg-invalid-image-1.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug11026.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug12268.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug17587.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug215629.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug24661.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug2479-1.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug2962.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug2997.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug3977.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug4527.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug4576.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug5538.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug56201.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug60804.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug60807.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/bugs/bug9123-1.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla/collapsing_borders/bug41262-3.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla_expected_failures/bugs/bug10140.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla_expected_failures/bugs/bug23847.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla_expected_failures/bugs/bug32205-4.html [ NeedsRebaseline ]
+crbug.com/419101 tables/mozilla_expected_failures/bugs/bug72393.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/55.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/image-in-map.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/imagemap-circle-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/imagemap-focus-ring-outline-color-explicitly-inherited-from-map.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/imagemap-focus-ring-outline-color-not-inherited-from-map.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/imagemap-focus-ring-outline-color.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/imagemap-overflowing-circle-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/imagemap-overflowing-polygon-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/imagemap-polygon-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/png-suite/test.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/implsidepainting/inspector/tracing/paint-command-log-nodes.html [ NeedsRebaseline ]
+crbug.com/419101 [ Linux Mac Win ] fast/images/png-suite/test.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/textblob/fast/text/whitespace/normal-after-nowrap-breaking.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/antialiasedtext/fast/text/whitespace/normal-after-nowrap-breaking.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/textblob/fast/text/bidi-img-alt-text.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/antialiasedtext/fast/text/bidi-img-alt-text.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/deferred/fast/images/image-error-event-not-firing.html [ NeedsRebaseline ]
+crbug.com/419101 [ Mac Win ] virtual/deferred/fast/images/imagemap-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 [ Mac Win ] virtual/deferred/fast/images/imagemap-focus-ring-zoom.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/loading/promote-img-in-viewport-priority.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/block/float/017.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/block/positioning/061.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/block/float/002.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/block/positioning/058.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/block/positioning/001.html [ NeedsRebaseline ]
+crbug.com/419101 http/tests/security/contentSecurityPolicy/image-blocked-alt-content.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/imagemap-circle-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/imagemap-focus-ring-outline-color.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/imagemap-overflowing-circle-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/imagemap-focus-ring-outline-color-explicitly-inherited-from-map.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/alt-text-wrapping.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/imagemap-polygon-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/imagemap-overflowing-polygon-focus-ring.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/image-in-map.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/imagemap-focus-ring-zoom.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/imagemap-focus-ring-outline-color-not-inherited-from-map.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/text/bidi-img-alt-text.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/text/whitespace/normal-after-nowrap-breaking.html [ NeedsRebaseline ]
+crbug.com/419101 virtual/slimmingpaint/fast/images/imagemap-focus-ring.html [ NeedsRebaseline ]
+
crbug.com/374572 svg/filters/feImage-target-reappend-to-document.svg [ Pass Failure ]
crbug.com/374572 svg/dynamic-updates/SVGImageElement-svgdom-preserveAspectRatio-prop.html [ Pass ImageOnlyFailure ]
diff --git a/third_party/WebKit/LayoutTests/fast/css/counters/support/square-outline-32x32.png b/third_party/WebKit/LayoutTests/fast/css/counters/support/square-outline-32x32.png
new file mode 100644
index 0000000..917163f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/css/counters/support/square-outline-32x32.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/fast/forms/state-restore-to-non-edited-controls.html b/third_party/WebKit/LayoutTests/fast/forms/state-restore-to-non-edited-controls.html
index 6aebc58..a2f3867 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/state-restore-to-non-edited-controls.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/state-restore-to-non-edited-controls.html
@@ -40,7 +40,7 @@ function runTest()
document.getElementById('text1').value = 'edit';
// Submit form in a timeout to make sure that we create a new back/forward list item.
- setTimeout(function() {document.getElementById('form1').submit();}, 0);
+ setTimeout(function() {document.getElementById('form1').submit();}, 100);
} else {
// Second visit.
makeForm(parent, '2', '2', '2', '2', '2', '2', '2', '2', '2');
diff --git a/third_party/WebKit/LayoutTests/fast/images/alt-text-wrapping.html b/third_party/WebKit/LayoutTests/fast/images/alt-text-wrapping.html
new file mode 100644
index 0000000..9b55ba0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/images/alt-text-wrapping.html
@@ -0,0 +1 @@
+<img src="none.jpg" width="100px" height="100px" alt="This text should wrap inside the fallback content."></img>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-circle-focus-ring.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-circle-focus-ring.html
index 832bcd53..20a9c42 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-circle-focus-ring.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-circle-focus-ring.html
@@ -4,7 +4,7 @@
<map name="imagemap">
<area id="area" shape="circle" coords="64,64,61" href="#dummy" />
</map>
-<img src="dummy.gif" width="128" height="128" usemap="#imagemap" />
+<img width="128" height="128" usemap="#imagemap" />
<script>document.getElementById("area").focus()</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-explicitly-inherited-from-map.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-explicitly-inherited-from-map.html
index de9103d..9c3e190 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-explicitly-inherited-from-map.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-explicitly-inherited-from-map.html
@@ -16,7 +16,7 @@ window.onload = function()
<map name="imagemap">
<area id="area" shape="rect" coords="0,0,128,128" href="#dummy"/>
</map>
-<img src="imagemap.jpg" width="128" height="128" usemap="#imagemap" />
+<img width="128" height="128" usemap="#imagemap" />
</body>
</head>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-not-inherited-from-map.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-not-inherited-from-map.html
index e3bd236..5213ae7 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-not-inherited-from-map.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color-not-inherited-from-map.html
@@ -15,7 +15,7 @@ window.onload = function()
<map name="imagemap">
<area id="area" shape="rect" coords="0,0,128,128" href="#dummy"/>
</map>
-<img src="imagemap.jpg" width="128" height="128" usemap="#imagemap" />
+<img width="128" height="128" usemap="#imagemap" />
</body>
</head>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color.html
index d513be2..427ebf2 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-outline-color.html
@@ -15,7 +15,7 @@ window.onload = function()
<map name="imagemap">
<area id="area" shape="rect" coords="0,0,128,128" href="#dummy"/>
</map>
-<img src="imagemap.jpg" width="128" height="128" usemap="#imagemap" />
+<img width="128" height="128" usemap="#imagemap" />
</body>
</head>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style-expected.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style-expected.html
index a26579d..c13a01e 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style-expected.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style-expected.html
@@ -12,7 +12,7 @@ window.onload = function()
<map name="imagemap">
<area id="area" shape="rect" coords="0,0,256,256" href="#dummy" />
</map>
-<img src="imagemap.jpg" width="256" height="256" usemap="#imagemap" ismap />
+<img width="256" height="256" usemap="#imagemap" ismap />
</body>
</head>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style.html
index 6d6666b..021e313 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom-style.html
@@ -15,7 +15,7 @@ img { zoom: 2.0; }
<map name="imagemap">
<area id="area" shape="rect" coords="0,0,128,128" href="#dummy" />
</map>
-<img src="imagemap.jpg" width="128" height="128" usemap="#imagemap" ismap />
+<img width="128" height="128" usemap="#imagemap" ismap />
</body>
</head>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom.html
index b8aee15..55c22b1 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring-zoom.html
@@ -18,7 +18,7 @@ This test can be used to ensure that a focus ring is drawn correctly for an imag
<map name="imagemap">
<area id="area" shape="rect" coords="0,0,128,128" href="#dummy" />
</map>
-<img src="imagemap.jpg" width="128" height="128" usemap="#imagemap" ismap />
+<img width="128" height="128" usemap="#imagemap" ismap />
</body>
</head>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring.html
index 5759cc4..34036d3 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-focus-ring.html
@@ -12,7 +12,7 @@ window.onload = function()
<map name="imagemap">
<area id="area" shape="rect" coords="0,0,128,128" href="#dummy" />
</map>
-<img src="imagemap.jpg" width="128" height="128" usemap="#imagemap" ismap />
+<img width="128" height="128" usemap="#imagemap" ismap />
</body>
</head>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-nested-area.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-nested-area.html
index 0682fe2..642e4e8 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-nested-area.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-nested-area.html
@@ -36,7 +36,7 @@
<area id="area" shape="rect" coords="0,0,128,128" href="#dummy" />
</div>
</map>
- <img src="imagemap.jpg" width="128" height="128" usemap="#imagemap" ismap />
+ <img width="128" height="128" usemap="#imagemap" ismap />
</div>
<div id="after" tabIndex=0 />
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-circle-focus-ring.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-circle-focus-ring.html
index 464cccd..a2d6d06 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-circle-focus-ring.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-circle-focus-ring.html
@@ -4,7 +4,7 @@
<map name="imagemap">
<area id="area" shape="circle" coords="128,64,61" href="#dummy" />
</map>
-<img src="dummy.gif" width="128" height="128" usemap="#imagemap" />
+<img width="128" height="128" usemap="#imagemap" />
<script>document.getElementById("area").focus()</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-polygon-focus-ring.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-polygon-focus-ring.html
index a55a3dad..7456f63 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-polygon-focus-ring.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-overflowing-polygon-focus-ring.html
@@ -4,7 +4,7 @@
<map name="imagemap">
<area id="area" shape="polygon" coords="60,-10,0,160,150,40,-30,40,120,160" href="#dummy" />
</map>
-<img src="dummy.gif" width="128" height="128" usemap="#imagemap" />
+<img width="128" height="128" usemap="#imagemap" />
<script>document.getElementById("area").focus()</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/fast/images/imagemap-polygon-focus-ring.html b/third_party/WebKit/LayoutTests/fast/images/imagemap-polygon-focus-ring.html
index b60694a..401ce20 100644
--- a/third_party/WebKit/LayoutTests/fast/images/imagemap-polygon-focus-ring.html
+++ b/third_party/WebKit/LayoutTests/fast/images/imagemap-polygon-focus-ring.html
@@ -4,7 +4,7 @@
<map name="imagemap">
<area id="area" shape="polygon" coords="44,4,84,4,84,44,124,44,124,84,84,84,84,124,44,124,44,84,4,84,4,44,44,44" href="#dummy" />
</map>
-<img src="dummy.gif" width="128" height="128" usemap="#imagemap" />
+<img width="128" height="128" usemap="#imagemap" />
<script>document.getElementById("area").focus()</script>
</body>
</html>
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/network/network-image-404.html b/third_party/WebKit/LayoutTests/http/tests/inspector/network/network-image-404.html
index f2cbdf1..5d19d1a 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector/network/network-image-404.html
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector/network/network-image-404.html
@@ -40,8 +40,14 @@ function test()
function step3()
{
- var request1 = InspectorTest.networkRequests().pop();
- InspectorTest.addResult("resource.content after requesting content: " + request1.content);
+ var requests = InspectorTest.networkRequests();
+ requests.sort(function(a, b) {return a.url.localeCompare(b.url);});
+ InspectorTest.addResult("resources count = " + requests.length);
+ for (i = 0; i < requests.length; i++) {
+ InspectorTest.addResult(requests[i].url);
+ InspectorTest.addResult("resource.content after requesting content: " + requests[i].content);
+ }
+
InspectorTest.completeTest();
}
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/image-blocked-alt-content-expected.txt b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/image-blocked-alt-content-expected.txt
new file mode 100644
index 0000000..bce9ddb
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/image-blocked-alt-content-expected.txt
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x91
+ RenderBlock {HTML} at (0,0) size 800x91
+ RenderBody {BODY} at (8,8) size 784x75
+ RenderText {#text} at (0,0) size 758x19
+ text run at (0,0) width 758: "This test shows what alt content looks like when an image errors out on a page with a CSP that blocks data: URIs for images. "
+ RenderBlock {IMG} at (0,20) size 50x50
+ RenderText {#text} at (0,0) size 0x0
+layer at (8,28) size 50x50 clip at (9,29) size 48x48
+ RenderBlock {DIV} at (0,0) size 50x50 [border: (1px solid #C0C0C0)]
+ RenderImage {IMG} at (2,2) size 16x16
+layer at (26,30) size 30x40
+ RenderBlock {DIV} at (18,2) size 30x40
+ RenderText {#text} at (0,0) size 22x39
+ text run at (0,0) width 14: "alt"
+ text run at (0,20) width 22: "text"
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/image-blocked-alt-content.html b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/image-blocked-alt-content.html
new file mode 100644
index 0000000..de590c1
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/image-blocked-alt-content.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Security-Policy" content="img-src 'self'; script-src 'unsafe-inline'">
+</head>
+<body>
+This test shows what alt content looks like when an image errors out on a page with a CSP that blocks data: URIs for images.
+<img src="../resources/ab.png" width="50px;" height="50px;" alt="alt text">
+</body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-icon-hidpi-expected.png b/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-icon-hidpi-expected.png
new file mode 100644
index 0000000..0c0b537
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-icon-hidpi-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-icon-hidpi-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-icon-hidpi-expected.txt
index 8a0a90b7e..fba4c0a 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-icon-hidpi-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-icon-hidpi-expected.txt
@@ -7,5 +7,8 @@ layer at (0,0) size 800x600
RenderText {#text} at (0,0) size 700x19
text run at (0,0) width 700: "This test passes if the broken image icon appears high-resolution in HiDPI and if the outline is of the appropriate size."
RenderBlock (anonymous) at (0,20) size 784x20
- RenderImage {IMG} at (0,0) size 20x20
+ RenderBlock {IMG} at (0,0) size 20x20
RenderText {#text} at (0,0) size 0x0
+layer at (8,28) size 20x20 clip at (9,29) size 18x18
+ RenderBlock {DIV} at (0,0) size 20x20 [border: (1px solid #C0C0C0)]
+ RenderImage {IMG} at (2,2) size 16x16
diff --git a/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-with-size-hidpi-expected.png b/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-with-size-hidpi-expected.png
new file mode 100644
index 0000000..b0219ca
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-with-size-hidpi-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-with-size-hidpi-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-with-size-hidpi-expected.txt
index 0d24013..3b997c4 100644
--- a/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-with-size-hidpi-expected.txt
+++ b/third_party/WebKit/LayoutTests/platform/linux/fast/hidpi/broken-image-with-size-hidpi-expected.txt
@@ -7,5 +7,8 @@ layer at (0,0) size 800x600
RenderText {#text} at (0,0) size 608x19
text run at (0,0) width 608: "This test passes if the broken image icon appears high-resolution in HiDPI and is the appropriate size."
RenderBlock (anonymous) at (0,20) size 784x150
- RenderImage {IMG} at (0,0) size 300x150
+ RenderBlock {IMG} at (0,0) size 300x150
RenderText {#text} at (0,0) size 0x0
+layer at (8,28) size 300x150 clip at (9,29) size 298x148
+ RenderBlock {DIV} at (0,0) size 300x150 [border: (1px solid #C0C0C0)]
+ RenderImage {IMG} at (2,2) size 16x16
diff --git a/third_party/WebKit/LayoutTests/platform/linux/fast/images/alt-text-wrapping-expected.png b/third_party/WebKit/LayoutTests/platform/linux/fast/images/alt-text-wrapping-expected.png
new file mode 100644
index 0000000..02d1845
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/platform/linux/fast/images/alt-text-wrapping-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/linux/fast/images/alt-text-wrapping-expected.txt b/third_party/WebKit/LayoutTests/platform/linux/fast/images/alt-text-wrapping-expected.txt
new file mode 100644
index 0000000..d1f09118
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/platform/linux/fast/images/alt-text-wrapping-expected.txt
@@ -0,0 +1,18 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {IMG} at (0,0) size 100x100
+ RenderText {#text} at (0,0) size 0x0
+layer at (8,8) size 100x100 clip at (9,9) size 98x98 scrollHeight 102
+ RenderBlock {DIV} at (0,0) size 100x100 [border: (1px solid #C0C0C0)]
+ RenderImage {IMG} at (2,2) size 16x16
+layer at (26,10) size 80x100 backgroundClip at (26,10) size 80x97 clip at (26,10) size 80x97 outlineClip at (9,9) size 98x98
+ RenderBlock {DIV} at (18,2) size 80x100
+ RenderText {#text} at (0,0) size 74x99
+ text run at (0,0) width 51: "This text"
+ text run at (0,20) width 74: "should wrap"
+ text run at (0,40) width 56: "inside the"
+ text run at (0,60) width 47: "fallback"
+ text run at (0,80) width 48: "content."
diff --git a/third_party/WebKit/LayoutTests/platform/linux/http/tests/security/contentSecurityPolicy/image-blocked-alt-content-expected.png b/third_party/WebKit/LayoutTests/platform/linux/http/tests/security/contentSecurityPolicy/image-blocked-alt-content-expected.png
new file mode 100644
index 0000000..5f1c1a4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/platform/linux/http/tests/security/contentSecurityPolicy/image-blocked-alt-content-expected.png
Binary files differ
diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi
index 594d9f2..6bd3505 100644
--- a/third_party/WebKit/Source/core/core.gypi
+++ b/third_party/WebKit/Source/core/core.gypi
@@ -2459,6 +2459,8 @@
'html/HTMLIFrameElement.cpp',
'html/HTMLImageElement.cpp',
'html/HTMLImageElement.h',
+ 'html/HTMLImageFallbackHelper.h',
+ 'html/HTMLImageFallbackHelper.cpp',
'html/HTMLImageLoader.cpp',
'html/HTMLImageLoader.h',
'html/HTMLInputElement.cpp',
diff --git a/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp b/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp
index 25d018a..a3ecc48 100644
--- a/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp
+++ b/third_party/WebKit/Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp
@@ -138,7 +138,11 @@ static bool ruleAdditionMightRequireDocumentStyleRecalc(StyleRuleBase* rule)
void StyleSheetInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* styleSheetContents)
{
- ASSERT(!styleSheetContents->isLoading());
+ // Updating the style on the shadow DOM for image fallback content can bring us here when imports
+ // are still getting loaded in the main document. Just need to exit early as we will return here
+ // when the imports finish loading.
+ if (styleSheetContents->isLoading())
+ return;
// See if all rules on the sheet are scoped to some specific ids or classes.
// Then test if we actually have any of those in the tree at the moment.
diff --git a/third_party/WebKit/Source/core/editing/TextIterator.cpp b/third_party/WebKit/Source/core/editing/TextIterator.cpp
index 7baf1c4..0ec60e7 100644
--- a/third_party/WebKit/Source/core/editing/TextIterator.cpp
+++ b/third_party/WebKit/Source/core/editing/TextIterator.cpp
@@ -38,6 +38,8 @@
#include "core/editing/htmlediting.h"
#include "core/frame/FrameView.h"
#include "core/html/HTMLElement.h"
+#include "core/html/HTMLImageElement.h"
+#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLTextFormControlElement.h"
#include "core/rendering/InlineTextBox.h"
#include "core/rendering/RenderImage.h"
@@ -470,6 +472,7 @@ void TextIterator::advance()
|| (m_node && m_node->isHTMLElement()
&& (isHTMLFormControlElement(toHTMLElement(*m_node))
|| isHTMLLegendElement(toHTMLElement(*m_node))
+ || isHTMLImageElement(toElement(*m_node))
|| isHTMLMeterElement(toHTMLElement(*m_node))
|| isHTMLProgressElement(toHTMLElement(*m_node)))))) {
handledNode = handleReplacedElement();
@@ -829,8 +832,8 @@ bool TextIterator::handleReplacedElement()
m_positionEndOffset = 1;
m_singleCharacterBuffer = 0;
- if (m_emitsImageAltText && renderer->isImage() && renderer->isRenderImage()) {
- m_text = toRenderImage(renderer)->altText();
+ if (m_emitsImageAltText) {
+ m_text = toHTMLElement(m_node)->altText();
if (!m_text.isEmpty()) {
m_textLength = m_text.length();
m_lastCharacter = m_text[m_textLength - 1];
@@ -1411,7 +1414,7 @@ void SimplifiedBackwardsTextIterator::advance()
// FIXME: What about CDATA_SECTION_NODE?
if (renderer->style()->visibility() == VISIBLE && m_offset > 0)
m_handledNode = handleTextNode();
- } else if (renderer && (renderer->isImage() || renderer->isRenderPart())) {
+ } else if (renderer && (isHTMLImageElement(toElement(*m_node)) || isHTMLInputElement(toElement(*m_node)) || renderer->isRenderPart())) {
if (renderer->style()->visibility() == VISIBLE && m_offset > 0)
m_handledNode = handleReplacedElement();
} else {
diff --git a/third_party/WebKit/Source/core/fetch/ImageResource.cpp b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
index fe3a1a1..c38e62d 100644
--- a/third_party/WebKit/Source/core/fetch/ImageResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
@@ -56,7 +56,10 @@ ImageResource::ImageResource(const ResourceRequest& resourceRequest)
ImageResource::ImageResource(blink::Image* image)
: Resource(ResourceRequest(""), Image)
+ , m_devicePixelRatioHeaderValue(1.0)
, m_image(image)
+ , m_loadingMultipartContent(false)
+ , m_hasDevicePixelRatioHeaderValue(false)
{
WTF_LOG(Timers, "new ImageResource(Image) %p", this);
setStatus(Cached);
diff --git a/third_party/WebKit/Source/core/html/HTMLElement.h b/third_party/WebKit/Source/core/html/HTMLElement.h
index 14553f5..87f98d3 100644
--- a/third_party/WebKit/Source/core/html/HTMLElement.h
+++ b/third_party/WebKit/Source/core/html/HTMLElement.h
@@ -100,6 +100,8 @@ public:
HTMLMenuElement* contextMenu() const;
void setContextMenu(HTMLMenuElement*);
+ virtual String altText() const { return String(); }
+
protected:
HTMLElement(const QualifiedName& tagName, Document&, ConstructionType);
diff --git a/third_party/WebKit/Source/core/html/HTMLImageElement.cpp b/third_party/WebKit/Source/core/html/HTMLImageElement.cpp
index 088f5dd..7ca6d67 100644
--- a/third_party/WebKit/Source/core/html/HTMLImageElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLImageElement.cpp
@@ -32,16 +32,20 @@
#include "core/css/parser/SizesAttributeParser.h"
#include "core/dom/Attribute.h"
#include "core/dom/NodeTraversal.h"
+#include "core/dom/shadow/ShadowRoot.h"
#include "core/fetch/ImageResource.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLAnchorElement.h"
#include "core/html/HTMLCanvasElement.h"
#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLImageFallbackHelper.h"
#include "core/html/HTMLSourceElement.h"
#include "core/html/canvas/CanvasRenderingContext.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/html/parser/HTMLSrcsetParser.h"
#include "core/inspector/ConsoleMessage.h"
+#include "core/page/Page.h"
+#include "core/rendering/RenderBlockFlow.h"
#include "core/rendering/RenderImage.h"
#include "platform/ContentType.h"
#include "platform/MIMETypeRegistry.h"
@@ -84,7 +88,10 @@ HTMLImageElement::HTMLImageElement(Document& document, HTMLFormElement* form, bo
, m_formWasSetByParser(false)
, m_elementCreatedByParser(createdByParser)
, m_intrinsicSizingViewportDependant(false)
+ , m_useFallbackContent(false)
+ , m_isFallbackImage(false)
{
+ setHasCustomStyleCallbacks();
if (form && form->inDocument()) {
#if ENABLE(OILPAN)
m_form = form;
@@ -235,9 +242,13 @@ void HTMLImageElement::setBestFitURLAndDPRFromImageCandidate(const ImageCandidat
void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- if (name == altAttr) {
- if (renderer() && renderer()->isImage())
- toRenderImage(renderer())->updateAltText();
+ if (name == altAttr || name == titleAttr) {
+ if (userAgentShadowRoot()) {
+ Element* text = userAgentShadowRoot()->getElementById("alttext");
+ String value = altText();
+ if (text && text->textContent() != value)
+ text->setTextContent(altText());
+ }
} else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) {
selectSourceURL(ImageLoader::UpdateIgnorePreviousError);
} else if (name == usemapAttr) {
@@ -247,7 +258,7 @@ void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
}
}
-const AtomicString& HTMLImageElement::altText() const
+String HTMLImageElement::altText() const
{
// lets figure out the alt text.. magic stuff
// http://www.w3.org/TR/1998/REC-html40-19980424/appendix/notes.html#altgen
@@ -313,6 +324,9 @@ RenderObject* HTMLImageElement::createRenderer(RenderStyle* style)
if (style->hasContent())
return RenderObject::createObject(this, style);
+ if (m_useFallbackContent)
+ return new RenderBlockFlow(this);
+
RenderImage* image = new RenderImage(this);
image->setImageResource(RenderImageResource::create());
image->setImageDevicePixelRatio(m_imageDevicePixelRatio);
@@ -334,16 +348,18 @@ void HTMLImageElement::attach(const AttachContext& context)
if (renderer() && renderer()->isImage()) {
RenderImage* renderImage = toRenderImage(renderer());
RenderImageResource* renderImageResource = renderImage->imageResource();
+ if (m_isFallbackImage) {
+ float deviceScaleFactor = blink::deviceScaleFactor(renderImage->frame());
+ pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource::brokenImage(deviceScaleFactor);
+ ImageResource* newImageResource = new ImageResource(brokenImageAndImageScaleFactor.first);
+ renderImage->imageResource()->setImageResource(newImageResource);
+ }
if (renderImageResource->hasImage())
return;
- // If we have no image at all because we have no src attribute, set
- // image height and width for the alt text instead.
if (!imageLoader().image() && !renderImageResource->cachedImage())
- renderImage->setImageSizeForAltText();
- else
- renderImageResource->setImageResource(imageLoader().image());
-
+ return;
+ renderImageResource->setImageResource(imageLoader().image());
}
}
@@ -366,7 +382,7 @@ Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode*
// If we have been inserted from a renderer-less document,
// our loader may have not fetched the image, so do it now.
if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModified)
- imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_elementCreatedByParser ? ImageLoader::ForceLoadImmediately : ImageLoader::LoadNormally);
+ imageLoader().updateFromElement(ImageLoader::UpdateNormal);
return HTMLElement::insertedInto(insertionPoint);
}
@@ -643,6 +659,11 @@ void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
document().mediaQueryMatcher().addViewportListener(m_listener);
}
imageLoader().updateFromElement(behavior);
+
+ if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSourceURL().isEmpty()))
+ ensurePrimaryContent();
+ else
+ ensureFallbackContent();
}
const KURL& HTMLImageElement::sourceURL() const
@@ -650,4 +671,51 @@ const KURL& HTMLImageElement::sourceURL() const
return cachedImage()->response().url();
}
+void HTMLImageElement::didAddUserAgentShadowRoot(ShadowRoot&)
+{
+ HTMLImageFallbackHelper::createAltTextShadowTree(*this);
+}
+
+void HTMLImageElement::ensureFallbackContent()
+{
+ if (m_useFallbackContent || m_isFallbackImage)
+ return;
+ setUseFallbackContent();
+ reattachFallbackContent();
+}
+
+void HTMLImageElement::ensurePrimaryContent()
+{
+ if (!m_useFallbackContent)
+ return;
+ m_useFallbackContent = false;
+ reattachFallbackContent();
+}
+
+void HTMLImageElement::reattachFallbackContent()
+{
+ // This can happen inside of attach() in the middle of a recalcStyle so we need to
+ // reattach synchronously here.
+ if (document().inStyleRecalc())
+ reattach();
+ else
+ lazyReattachIfAttached();
+}
+
+PassRefPtr<RenderStyle> HTMLImageElement::customStyleForRenderer()
+{
+ RefPtr<RenderStyle> newStyle = originalStyleForRenderer();
+
+ if (!m_useFallbackContent)
+ return newStyle;
+ return HTMLImageFallbackHelper::customStyleForAltText(*this, newStyle);
+}
+
+void HTMLImageElement::setUseFallbackContent()
+{
+ m_useFallbackContent = true;
+ if (document().inStyleRecalc())
+ return;
+ ensureUserAgentShadowRoot();
+}
}
diff --git a/third_party/WebKit/Source/core/html/HTMLImageElement.h b/third_party/WebKit/Source/core/html/HTMLImageElement.h
index 1fceb3d..1c9972a 100644
--- a/third_party/WebKit/Source/core/html/HTMLImageElement.h
+++ b/third_party/WebKit/Source/core/html/HTMLImageElement.h
@@ -34,6 +34,7 @@ namespace blink {
class HTMLFormElement;
class ImageCandidate;
+class ShadowRoot;
class HTMLImageElement final : public HTMLElement, public CanvasImageSource {
DEFINE_WRAPPERTYPEINFO();
@@ -56,7 +57,7 @@ public:
bool isServerMap() const;
- const AtomicString& altText() const;
+ virtual String altText() const override final;
ImageResource* cachedImage() const { return imageLoader().image(); }
void setImageResource(ImageResource* i) { imageLoader().setImage(i); };
@@ -86,6 +87,8 @@ public:
virtual HTMLFormElement* formOwner() const override;
void formRemovedFromTree(const Node& formRoot);
+ virtual void ensureFallbackContent();
+ virtual void ensurePrimaryContent();
// CanvasImageSourceImplementations
virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceImageStatus*) const override;
@@ -96,11 +99,18 @@ public:
// public so that HTMLPictureElement can call this as well.
void selectSourceURL(ImageLoader::UpdateFromElementBehavior);
+ void reattachFallbackContent();
+ void setUseFallbackContent();
+ void setIsFallbackImage() { m_isFallbackImage = true; }
+
protected:
explicit HTMLImageElement(Document&, HTMLFormElement* = 0, bool createdByParser = false);
virtual void didMoveToNewDocument(Document& oldDocument) override;
+ virtual bool useFallbackContent() const { return m_useFallbackContent; }
+ virtual void didAddUserAgentShadowRoot(ShadowRoot&) override;
+ virtual PassRefPtr<RenderStyle> customStyleForRenderer() override;
private:
virtual bool areAuthorShadowsAllowed() const override { return false; }
@@ -146,6 +156,8 @@ private:
unsigned m_elementCreatedByParser : 1;
// Intrinsic sizing is viewport dependant if the 'w' descriptor was used for the picked resource.
unsigned m_intrinsicSizingViewportDependant : 1;
+ unsigned m_useFallbackContent : 1;
+ unsigned m_isFallbackImage : 1;
};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/html/HTMLImageFallbackHelper.cpp b/third_party/WebKit/Source/core/html/HTMLImageFallbackHelper.cpp
new file mode 100644
index 0000000..b487c28
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/HTMLImageFallbackHelper.cpp
@@ -0,0 +1,112 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/html/HTMLImageFallbackHelper.h"
+
+#include "core/HTMLNames.h"
+#include "core/InputTypeNames.h"
+#include "core/dom/ElementRareData.h"
+#include "core/dom/Text.h"
+#include "core/dom/shadow/ShadowRoot.h"
+#include "core/fetch/ImageResource.h"
+#include "core/html/FormDataList.h"
+#include "core/html/HTMLDivElement.h"
+#include "core/html/HTMLElement.h"
+#include "core/html/HTMLImageElement.h"
+#include "core/html/HTMLImageLoader.h"
+#include "core/html/HTMLInputElement.h"
+#include "core/html/HTMLStyleElement.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/StringBuilder.h"
+
+namespace blink {
+
+using namespace HTMLNames;
+
+static bool noImageSourceSpecified(const Element& element)
+{
+ bool noSrcSpecified = !element.hasAttribute(srcAttr) || element.getAttribute(srcAttr).isNull() || element.getAttribute(srcAttr).isEmpty();
+ bool noSrcsetSpecified = !element.hasAttribute(srcsetAttr) || element.getAttribute(srcsetAttr).isNull() || element.getAttribute(srcsetAttr).isEmpty();
+ return noSrcSpecified && noSrcsetSpecified;
+}
+
+void HTMLImageFallbackHelper::createAltTextShadowTree(Element& element)
+{
+ ShadowRoot& root = element.ensureUserAgentShadowRoot();
+
+ RefPtrWillBeRawPtr<HTMLDivElement> container = HTMLDivElement::create(element.document());
+ root.appendChild(container);
+ container->setAttribute(idAttr, AtomicString("alttext-container", AtomicString::ConstructFromLiteral));
+ container->setInlineStyleProperty(CSSPropertyOverflow, CSSValueHidden);
+ container->setInlineStyleProperty(CSSPropertyBorderWidth, 1, CSSPrimitiveValue::CSS_PX);
+ container->setInlineStyleProperty(CSSPropertyBorderStyle, CSSValueSolid);
+ container->setInlineStyleProperty(CSSPropertyBorderColor, CSSValueSilver);
+ container->setInlineStyleProperty(CSSPropertyDisplay, CSSValueInlineBlock);
+ container->setInlineStyleProperty(CSSPropertyBoxSizing, CSSValueBorderBox);
+ container->setInlineStyleProperty(CSSPropertyPadding, 1, CSSPrimitiveValue::CSS_PX);
+
+ RefPtrWillBeRawPtr<HTMLImageElement> brokenImage = HTMLImageElement::create(element.document());
+ container->appendChild(brokenImage);
+ brokenImage->setIsFallbackImage();
+ brokenImage->setAttribute(idAttr, AtomicString("alttext-image", AtomicString::ConstructFromLiteral));
+ brokenImage->setAttribute(widthAttr, AtomicString("16", AtomicString::ConstructFromLiteral));
+ brokenImage->setAttribute(heightAttr, AtomicString("16", AtomicString::ConstructFromLiteral));
+ brokenImage->setAttribute(alignAttr, AtomicString("left", AtomicString::ConstructFromLiteral));
+ brokenImage->setInlineStyleProperty(CSSPropertyMargin, 0, CSSPrimitiveValue::CSS_PX);
+
+ RefPtrWillBeRawPtr<HTMLDivElement> altText = HTMLDivElement::create(element.document());
+ container->appendChild(altText);
+ altText->setInlineStyleProperty(CSSPropertyOverflow, CSSValueHidden);
+ altText->setInlineStyleProperty(CSSPropertyDisplay, CSSValueBlock);
+
+ RefPtrWillBeRawPtr<Text> text = Text::create(element.document(), toHTMLElement(element).altText());
+ altText->appendChild(text);
+}
+
+PassRefPtr<RenderStyle> HTMLImageFallbackHelper::customStyleForAltText(Element& element, PassRefPtr<RenderStyle> newStyle)
+{
+ // If we have an author shadow root or have not created the UA shadow root yet, bail early. We can't
+ // use ensureUserAgentShadowRoot() here because that would alter the DOM tree during style recalc.
+ if (element.shadowRoot() || !element.userAgentShadowRoot())
+ return newStyle;
+
+ Element* placeHolder = element.userAgentShadowRoot()->getElementById("alttext-container");
+ Element* brokenImage = element.userAgentShadowRoot()->getElementById("alttext-image");
+
+ if (element.document().inQuirksMode()) {
+ // Mimic the behaviour of the image host by setting symmetric dimensions if only one dimension is specified.
+ if (newStyle->width().isSpecifiedOrIntrinsic() && newStyle->height().isAuto())
+ newStyle->setHeight(newStyle->width());
+ else if (newStyle->height().isSpecifiedOrIntrinsic() && newStyle->width().isAuto())
+ newStyle->setWidth(newStyle->height());
+ if (newStyle->width().isSpecifiedOrIntrinsic() && newStyle->height().isSpecifiedOrIntrinsic()) {
+ placeHolder->setInlineStyleProperty(CSSPropertyVerticalAlign, CSSValueBaseline);
+ }
+ }
+
+ // If the image has specified dimensions allow the alt-text container expand to fill them.
+ if (newStyle->width().isSpecifiedOrIntrinsic() && newStyle->height().isSpecifiedOrIntrinsic()) {
+ placeHolder->setInlineStyleProperty(CSSPropertyWidth, 100, CSSPrimitiveValue::CSS_PERCENTAGE);
+ placeHolder->setInlineStyleProperty(CSSPropertyHeight, 100, CSSPrimitiveValue::CSS_PERCENTAGE);
+ }
+
+ // Make sure the broken image icon appears on the appropriate side of the image for the element's writing direction.
+ brokenImage->setInlineStyleProperty(CSSPropertyFloat, AtomicString(newStyle->direction() == LTR ? "left" : "right"));
+
+ // This is an <img> with no attributes, so don't display anything.
+ if (noImageSourceSpecified(element) && !newStyle->width().isSpecifiedOrIntrinsic() && !newStyle->height().isSpecifiedOrIntrinsic() && toHTMLElement(element).altText().isEmpty())
+ newStyle->setDisplay(NONE);
+
+ // This preserves legacy behaviour originally defined when alt-text was managed by RenderImage.
+ if (noImageSourceSpecified(element))
+ brokenImage->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
+ else
+ brokenImage->setInlineStyleProperty(CSSPropertyDisplay, CSSValueInline);
+
+ return newStyle;
+}
+
+} // namespace blink
+
diff --git a/third_party/WebKit/Source/core/html/HTMLImageFallbackHelper.h b/third_party/WebKit/Source/core/html/HTMLImageFallbackHelper.h
new file mode 100644
index 0000000..f73a304
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/HTMLImageFallbackHelper.h
@@ -0,0 +1,23 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef HTMLImageFallbackHelper_h
+#define HTMLImageFallbackHelper_h
+
+#include "wtf/PassRefPtr.h"
+
+namespace blink {
+
+class Element;
+class RenderStyle;
+
+class HTMLImageFallbackHelper {
+public:
+ static void createAltTextShadowTree(Element&);
+ static PassRefPtr<RenderStyle> customStyleForAltText(Element&, PassRefPtr<RenderStyle> newStyle);
+};
+
+} // namespace blink
+
+#endif // HTMLImageFallbackHelper_h
diff --git a/third_party/WebKit/Source/core/html/HTMLImageLoader.cpp b/third_party/WebKit/Source/core/html/HTMLImageLoader.cpp
index 44fc879..7847940 100644
--- a/third_party/WebKit/Source/core/html/HTMLImageLoader.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLImageLoader.cpp
@@ -27,14 +27,18 @@
#include "core/events/Event.h"
#include "core/fetch/ImageResource.h"
#include "core/html/HTMLImageElement.h"
+#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLObjectElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "platform/Logging.h"
namespace blink {
-HTMLImageLoader::HTMLImageLoader(Element* node)
- : ImageLoader(node)
+using namespace HTMLNames;
+
+HTMLImageLoader::HTMLImageLoader(Element* element)
+ : ImageLoader(element)
+ , m_loadFallbackContentTimer(this, &HTMLImageLoader::timerFired)
{
}
@@ -61,17 +65,56 @@ String HTMLImageLoader::sourceURI(const AtomicString& attr) const
return stripLeadingAndTrailingHTMLSpaces(attr);
}
+static void loadFallbackContentForElement(Element* element)
+{
+ if (isHTMLImageElement(element))
+ toHTMLImageElement(element)->ensureFallbackContent();
+ else if (isHTMLInputElement(element))
+ toHTMLInputElement(element)->ensureFallbackContent();
+}
+
+void HTMLImageLoader::noImageResourceToLoad()
+{
+ // FIXME: Use fallback content even when there is no alt-text. The only blocker is the large amount of rebaselining it requires.
+ if (!toHTMLElement(element())->altText().isEmpty())
+ loadFallbackContentForElement(element());
+}
+
void HTMLImageLoader::notifyFinished(Resource*)
{
ImageResource* cachedImage = image();
-
RefPtrWillBeRawPtr<Element> element = this->element();
ImageLoader::notifyFinished(cachedImage);
bool loadError = cachedImage->errorOccurred() || cachedImage->response().httpStatusCode() >= 400;
+ if (isHTMLImageElement(*element)) {
+ if (loadError)
+ ensureFallbackContent();
+ else
+ toHTMLImageElement(element)->ensurePrimaryContent();
+ }
+
+ if (isHTMLInputElement(*element)) {
+ if (loadError)
+ ensureFallbackContent();
+ else
+ toHTMLInputElement(element)->ensurePrimaryContent();
+ }
if (loadError && isHTMLObjectElement(*element))
toHTMLObjectElement(element)->renderFallbackContent();
}
+void HTMLImageLoader::ensureFallbackContent()
+{
+ if (image()->url().protocolIsData())
+ m_loadFallbackContentTimer.startOneShot(0, FROM_HERE);
+ else
+ loadFallbackContentForElement(element());
+}
+
+void HTMLImageLoader::timerFired(Timer<HTMLImageLoader>*)
+{
+ loadFallbackContentForElement(element());
+}
}
diff --git a/third_party/WebKit/Source/core/html/HTMLImageLoader.h b/third_party/WebKit/Source/core/html/HTMLImageLoader.h
index 22e08ed..a2d11be 100644
--- a/third_party/WebKit/Source/core/html/HTMLImageLoader.h
+++ b/third_party/WebKit/Source/core/html/HTMLImageLoader.h
@@ -41,7 +41,11 @@ public:
virtual void notifyFinished(Resource*) override;
private:
+ Timer<HTMLImageLoader> m_loadFallbackContentTimer;
+ void timerFired(Timer<HTMLImageLoader>*);
explicit HTMLImageLoader(Element*);
+ virtual void noImageResourceToLoad() override;
+ void ensureFallbackContent();
};
}
diff --git a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
index e5a7d3d..9eef155 100644
--- a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
@@ -132,9 +132,7 @@ HTMLInputElement::HTMLInputElement(Document& document, HTMLFormElement* form, bo
, m_inputType(createdByParser ? nullptr : InputType::createText(*this))
, m_inputTypeView(m_inputType)
{
-#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
setHasCustomStyleCallbacks();
-#endif
}
PassRefPtrWillBeRawPtr<HTMLInputElement> HTMLInputElement::create(Document& document, HTMLFormElement* form, bool createdByParser)
@@ -1876,12 +1874,10 @@ bool HTMLInputElement::supportsAutofocus() const
return m_inputType->isInteractiveContent();
}
-#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
{
return m_inputTypeView->customStyleForRenderer(originalStyleForRenderer());
}
-#endif
bool HTMLInputElement::shouldDispatchFormControlChangeEvent(String& oldValue, String& newValue)
{
@@ -1898,4 +1894,18 @@ AXObject* HTMLInputElement::popupRootAXObject()
return m_inputTypeView->popupRootAXObject();
}
+void HTMLInputElement::ensureFallbackContent()
+{
+ m_inputTypeView->ensureFallbackContent();
+}
+
+void HTMLInputElement::ensurePrimaryContent()
+{
+ m_inputTypeView->ensurePrimaryContent();
+}
+
+bool HTMLInputElement::hasFallbackContent() const
+{
+ return m_inputTypeView->hasFallbackContent();
+}
} // namespace
diff --git a/third_party/WebKit/Source/core/html/HTMLInputElement.h b/third_party/WebKit/Source/core/html/HTMLInputElement.h
index 707baf4..0033aa1 100644
--- a/third_party/WebKit/Source/core/html/HTMLInputElement.h
+++ b/third_party/WebKit/Source/core/html/HTMLInputElement.h
@@ -154,7 +154,7 @@ public:
virtual bool isActivatedSubmit() const override final;
virtual void setActivatedSubmit(bool flag) override final;
- String altText() const;
+ virtual String altText() const override final;
int maxResults() const { return m_maxResults; }
@@ -252,6 +252,9 @@ public:
AXObject* popupRootAXObject();
virtual void didNotifySubtreeInsertionsToDocument() override;
+ virtual void ensureFallbackContent();
+ virtual void ensurePrimaryContent();
+ bool hasFallbackContent() const;
protected:
HTMLInputElement(Document&, HTMLFormElement*, bool createdByParser);
@@ -351,9 +354,7 @@ private:
RadioButtonGroupScope* radioButtonGroupScope() const;
void addToRadioButtonGroup();
void removeFromRadioButtonGroup();
-#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
virtual PassRefPtr<RenderStyle> customStyleForRenderer() override;
-#endif
virtual bool shouldDispatchFormControlChangeEvent(String&, String&) override;
diff --git a/third_party/WebKit/Source/core/html/forms/BaseButtonInputType.h b/third_party/WebKit/Source/core/html/forms/BaseButtonInputType.h
index c40ec05..63a335a 100644
--- a/third_party/WebKit/Source/core/html/forms/BaseButtonInputType.h
+++ b/third_party/WebKit/Source/core/html/forms/BaseButtonInputType.h
@@ -40,9 +40,9 @@ class BaseButtonInputType : public BaseClickableWithKeyInputType {
protected:
BaseButtonInputType(HTMLInputElement& element) : BaseClickableWithKeyInputType(element) { }
virtual void valueAttributeChanged() override;
+ virtual void createShadowSubtree() override;
private:
- virtual void createShadowSubtree() override;
virtual bool shouldSaveAndRestoreFormControlState() const override;
virtual bool appendFormData(FormDataList&, bool) const override;
virtual RenderObject* createRenderer(RenderStyle*) const override;
diff --git a/third_party/WebKit/Source/core/html/forms/ImageInputType.cpp b/third_party/WebKit/Source/core/html/forms/ImageInputType.cpp
index e4c64d8..6c6f624 100644
--- a/third_party/WebKit/Source/core/html/forms/ImageInputType.cpp
+++ b/third_party/WebKit/Source/core/html/forms/ImageInputType.cpp
@@ -25,13 +25,16 @@
#include "core/HTMLNames.h"
#include "core/InputTypeNames.h"
+#include "core/dom/shadow/ShadowRoot.h"
#include "core/events/MouseEvent.h"
#include "core/fetch/ImageResource.h"
#include "core/html/FormDataList.h"
#include "core/html/HTMLFormElement.h"
+#include "core/html/HTMLImageFallbackHelper.h"
#include "core/html/HTMLImageLoader.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
+#include "core/rendering/RenderBlockFlow.h"
#include "core/rendering/RenderImage.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/text/StringBuilder.h"
@@ -42,6 +45,7 @@ using namespace HTMLNames;
inline ImageInputType::ImageInputType(HTMLInputElement& element)
: BaseButtonInputType(element)
+ , m_useFallbackContent(false)
{
}
@@ -117,8 +121,10 @@ void ImageInputType::handleDOMActivateEvent(Event* event)
event->setDefaultHandled();
}
-RenderObject* ImageInputType::createRenderer(RenderStyle*) const
+RenderObject* ImageInputType::createRenderer(RenderStyle* style) const
{
+ if (m_useFallbackContent)
+ return new RenderBlockFlow(&element());
RenderImage* image = new RenderImage(&element());
image->setImageResource(RenderImageResource::create());
return image;
@@ -126,10 +132,12 @@ RenderObject* ImageInputType::createRenderer(RenderStyle*) const
void ImageInputType::altAttributeChanged()
{
- RenderImage* image = toRenderImage(element().renderer());
- if (!image)
- return;
- image->updateAltText();
+ if (element().userAgentShadowRoot()) {
+ Element* text = element().userAgentShadowRoot()->getElementById("alttext");
+ String value = element().altText();
+ if (text && text->textContent() != value)
+ text->setTextContent(element().altText());
+ }
}
void ImageInputType::srcAttributeChanged()
@@ -139,6 +147,13 @@ void ImageInputType::srcAttributeChanged()
element().ensureImageLoader().updateFromElement(ImageLoader::UpdateIgnorePreviousError);
}
+void ImageInputType::valueAttributeChanged()
+{
+ if (m_useFallbackContent)
+ return;
+ BaseButtonInputType::valueAttributeChanged();
+}
+
void ImageInputType::startResourceLoading()
{
BaseButtonInputType::startResourceLoading();
@@ -146,17 +161,12 @@ void ImageInputType::startResourceLoading()
HTMLImageLoader& imageLoader = element().ensureImageLoader();
imageLoader.updateFromElement();
- RenderImage* renderer = toRenderImage(element().renderer());
- if (!renderer)
+ RenderObject* renderer = element().renderer();
+ if (!renderer || !renderer->isRenderImage())
return;
- RenderImageResource* imageResource = renderer->imageResource();
+ RenderImageResource* imageResource = toRenderImage(renderer)->imageResource();
imageResource->setImageResource(imageLoader.image());
-
- // If we have no image at all because we have no src attribute, set
- // image height and width for the alt text instead.
- if (!imageLoader.image() && !imageResource->cachedImage())
- renderer->setImageSizeForAltText();
}
bool ImageInputType::shouldRespectAlignAttribute()
@@ -233,4 +243,59 @@ const QualifiedName& ImageInputType::subResourceAttributeName() const
return srcAttr;
}
+void ImageInputType::ensureFallbackContent()
+{
+ if (m_useFallbackContent)
+ return;
+ setUseFallbackContent();
+ reattachFallbackContent();
+}
+
+void ImageInputType::setUseFallbackContent()
+{
+ if (m_useFallbackContent)
+ return;
+ m_useFallbackContent = true;
+ if (element().document().inStyleRecalc())
+ return;
+ if (ShadowRoot* root = element().userAgentShadowRoot())
+ root->removeChildren();
+ createShadowSubtree();
+}
+
+void ImageInputType::ensurePrimaryContent()
+{
+ if (!m_useFallbackContent)
+ return;
+ m_useFallbackContent = false;
+ reattachFallbackContent();
+}
+
+void ImageInputType::reattachFallbackContent()
+{
+ // This can happen inside of attach() in the middle of a recalcStyle so we need to
+ // reattach synchronously here.
+ if (element().document().inStyleRecalc())
+ element().reattach();
+ else
+ element().lazyReattachIfAttached();
+}
+
+void ImageInputType::createShadowSubtree()
+{
+ if (!m_useFallbackContent) {
+ BaseButtonInputType::createShadowSubtree();
+ return;
+ }
+ HTMLImageFallbackHelper::createAltTextShadowTree(element());
+}
+
+PassRefPtr<RenderStyle> ImageInputType::customStyleForRenderer(PassRefPtr<RenderStyle> newStyle)
+{
+ if (!m_useFallbackContent)
+ return newStyle;
+
+ return HTMLImageFallbackHelper::customStyleForAltText(element(), newStyle);
+}
+
} // namespace blink
diff --git a/third_party/WebKit/Source/core/html/forms/ImageInputType.h b/third_party/WebKit/Source/core/html/forms/ImageInputType.h
index 9d53891..4c240d8 100644
--- a/third_party/WebKit/Source/core/html/forms/ImageInputType.h
+++ b/third_party/WebKit/Source/core/html/forms/ImageInputType.h
@@ -41,6 +41,7 @@ namespace blink {
class ImageInputType final : public BaseButtonInputType {
public:
static PassRefPtrWillBeRawPtr<InputType> create(HTMLInputElement&);
+ virtual PassRefPtr<RenderStyle> customStyleForRenderer(PassRefPtr<RenderStyle>);
private:
ImageInputType(HTMLInputElement&);
@@ -53,6 +54,7 @@ private:
virtual void handleDOMActivateEvent(Event*) override;
virtual void altAttributeChanged() override;
virtual void srcAttributeChanged() override;
+ virtual void valueAttributeChanged() override;
virtual void startResourceLoading() override;
virtual bool shouldRespectAlignAttribute() override;
virtual bool canBeSuccessfulSubmitButton() override;
@@ -62,8 +64,16 @@ private:
virtual unsigned width() const override;
virtual bool hasLegalLinkAttribute(const QualifiedName&) const override;
virtual const QualifiedName& subResourceAttributeName() const override;
+ virtual void ensureFallbackContent() override;
+ virtual void ensurePrimaryContent() override;
+ virtual void createShadowSubtree() override;
+
+ void reattachFallbackContent();
+ void setUseFallbackContent();
+ bool hasFallbackContent() const { return m_useFallbackContent; }
IntPoint m_clickLocation; // Valid only during HTMLFormElement::prepareForSubmission().
+ bool m_useFallbackContent;
};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/html/forms/InputTypeView.h b/third_party/WebKit/Source/core/html/forms/InputTypeView.h
index 9296078..901a496 100644
--- a/third_party/WebKit/Source/core/html/forms/InputTypeView.h
+++ b/third_party/WebKit/Source/core/html/forms/InputTypeView.h
@@ -119,6 +119,9 @@ public:
virtual void updateClearButtonVisibility();
virtual void updatePlaceholderText();
virtual AXObject* popupRootAXObject();
+ virtual void ensureFallbackContent() { };
+ virtual void ensurePrimaryContent() { };
+ virtual bool hasFallbackContent() const { return false; };
protected:
InputTypeView(HTMLInputElement& element) : m_element(&element) { }
diff --git a/third_party/WebKit/Source/core/loader/ImageLoader.cpp b/third_party/WebKit/Source/core/loader/ImageLoader.cpp
index 47a80b0..3235914 100644
--- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp
@@ -66,8 +66,7 @@ static ImageLoader::BypassMainWorldBehavior shouldBypassMainWorldCSP(ImageLoader
{
ASSERT(loader);
ASSERT(loader->element());
- ASSERT(loader->element()->document().frame());
- if (loader->element()->document().frame()->script().shouldBypassMainWorldCSP())
+ if (loader->element()->document().frame() && loader->element()->document().frame()->script().shouldBypassMainWorldCSP())
return ImageLoader::BypassMainWorldCSP;
return ImageLoader::DoNotBypassMainWorldCSP;
}
@@ -276,9 +275,12 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up
} else {
clearFailedLoadURL();
}
- } else if (!imageSourceURL.isNull()) {
- // Fire an error event if the url string is not empty, but the KURL is.
- dispatchErrorEvent();
+ } else {
+ if (!imageSourceURL.isNull()) {
+ // Fire an error event if the url string is not empty, but the KURL is.
+ dispatchErrorEvent();
+ }
+ noImageResourceToLoad();
}
ImageResource* oldImage = m_image.get();
@@ -323,7 +325,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up
updatedHasPendingEvent();
}
-void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, LoadType loadType)
+void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior)
{
AtomicString imageSourceURL = m_element->imageSourceURL();
m_suppressErrorEvents = (updateBehavior == UpdateSizeChanged);
@@ -342,7 +344,7 @@ void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, Lo
}
KURL url = imageSourceToKURL(imageSourceURL);
- if (imageSourceURL.isNull() || url.isNull() || shouldLoadImmediately(url, loadType)) {
+ if (shouldLoadImmediately(url)) {
doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior);
return;
}
@@ -366,14 +368,16 @@ KURL ImageLoader::imageSourceToKURL(AtomicString imageSourceURL) const
return url;
}
-bool ImageLoader::shouldLoadImmediately(const KURL& url, LoadType loadType) const
+bool ImageLoader::shouldLoadImmediately(const KURL& url) const
{
- return (m_loadingImageDocument
- || isHTMLObjectElement(m_element)
- || isHTMLEmbedElement(m_element)
- || url.protocolIsData()
- || memoryCache()->resourceForURL(url, m_element->document().fetcher()->getCacheIdentifier())
- || loadType == ForceLoadImmediately);
+ // We force any image loads which might require alt content through the asynchronous path so that we can add the shadow DOM
+ // for the alt-text content when style recalc is over and DOM mutation is allowed again.
+ if (!url.isNull()) {
+ Resource* resource = memoryCache()->resourceForURL(url, m_element->document().fetcher()->getCacheIdentifier());
+ if (resource && !resource->errorOccurred())
+ return true;
+ }
+ return (m_loadingImageDocument || isHTMLObjectElement(m_element) || isHTMLEmbedElement(m_element) || url.protocolIsData());
}
void ImageLoader::notifyFinished(Resource* resource)
@@ -589,5 +593,4 @@ ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover()
m_loader.willRemoveClient(m_client);
}
#endif
-
}
diff --git a/third_party/WebKit/Source/core/loader/ImageLoader.h b/third_party/WebKit/Source/core/loader/ImageLoader.h
index 67754b9..4264da3 100644
--- a/third_party/WebKit/Source/core/loader/ImageLoader.h
+++ b/third_party/WebKit/Source/core/loader/ImageLoader.h
@@ -63,11 +63,6 @@ public:
virtual ~ImageLoader();
void trace(Visitor*);
- enum LoadType {
- LoadNormally,
- ForceLoadImmediately
- };
-
enum UpdateFromElementBehavior {
// This should be the update behavior when the element is attached to a document, or when DOM mutations trigger a new load.
// Starts loading if a load hasn't already been started.
@@ -85,7 +80,7 @@ public:
DoNotBypassMainWorldCSP
};
- void updateFromElement(UpdateFromElementBehavior = UpdateNormal, LoadType = LoadNormally);
+ void updateFromElement(UpdateFromElementBehavior = UpdateNormal);
void elementDidMoveToNewDocument();
@@ -112,7 +107,6 @@ public:
void addClient(ImageLoaderClient*);
void removeClient(ImageLoaderClient*);
-
protected:
virtual void notifyFinished(Resource*) override;
@@ -124,6 +118,7 @@ private:
virtual void dispatchLoadEvent() = 0;
virtual String sourceURI(const AtomicString&) const = 0;
+ virtual void noImageResourceToLoad() { };
void updatedHasPendingEvent();
@@ -147,7 +142,7 @@ private:
// Used to determine whether to immediately initiate the load
// or to schedule a microtask.
- bool shouldLoadImmediately(const KURL&, LoadType) const;
+ bool shouldLoadImmediately(const KURL&) const;
void willRemoveClient(ImageLoaderClient&);
diff --git a/third_party/WebKit/Source/core/paint/ImagePainter.cpp b/third_party/WebKit/Source/core/paint/ImagePainter.cpp
index 6ff4abc..f438825 100644
--- a/third_party/WebKit/Source/core/paint/ImagePainter.cpp
+++ b/third_party/WebKit/Source/core/paint/ImagePainter.cpp
@@ -78,82 +78,20 @@ void ImagePainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint&
GraphicsContext* context = paintInfo.context;
- if (!m_renderImage.imageResource()->hasImage() || m_renderImage.imageResource()->errorOccurred()) {
+ if (!m_renderImage.imageResource()->hasImage()) {
if (paintInfo.phase == PaintPhaseSelection)
return;
if (cWidth > 2 && cHeight > 2) {
- const int borderWidth = 1;
-
- LayoutUnit leftBorder = m_renderImage.borderLeft();
- LayoutUnit topBorder = m_renderImage.borderTop();
- LayoutUnit leftPad = m_renderImage.paddingLeft();
- LayoutUnit topPad = m_renderImage.paddingTop();
-
// Draw an outline rect where the image should be.
- IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset.x() + leftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight));
+ IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset.x() + m_renderImage.borderLeft() + m_renderImage.paddingLeft(), paintOffset.y() + m_renderImage.borderTop() + m_renderImage.paddingTop(), cWidth, cHeight));
RenderDrawingRecorder recorder(context, &m_renderImage, paintInfo.phase, paintRect);
context->setStrokeStyle(SolidStroke);
context->setStrokeColor(Color::lightGray);
context->setFillColor(Color::transparent);
context->drawRect(paintRect);
-
- bool errorPictureDrawn = false;
- LayoutSize imageOffset;
- // When calculating the usable dimensions, exclude the pixels of
- // the ouline rect so the error image/alt text doesn't draw on it.
- LayoutUnit usableWidth = cWidth - 2 * borderWidth;
- LayoutUnit usableHeight = cHeight - 2 * borderWidth;
-
- RefPtr<Image> image = m_renderImage.imageResource()->image();
-
- if (m_renderImage.imageResource()->errorOccurred() && !image->isNull() && usableWidth >= image->width() && usableHeight >= image->height()) {
- float deviceScaleFactor = blink::deviceScaleFactor(m_renderImage.frame());
- // Call brokenImage() explicitly to ensure we get the broken image icon at the appropriate resolution.
- pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource::brokenImage(deviceScaleFactor);
- image = brokenImageAndImageScaleFactor.first;
- IntSize imageSize = image->size();
- imageSize.scale(1 / brokenImageAndImageScaleFactor.second);
- // Center the error image, accounting for border and padding.
- LayoutUnit centerX = (usableWidth - imageSize.width()) / 2;
- if (centerX < 0)
- centerX = 0;
- LayoutUnit centerY = (usableHeight - imageSize.height()) / 2;
- if (centerY < 0)
- centerY = 0;
- imageOffset = LayoutSize(leftBorder + leftPad + centerX + borderWidth, topBorder + topPad + centerY + borderWidth);
- context->drawImage(image.get(), pixelSnappedIntRect(LayoutRect(paintOffset + imageOffset, LayoutSize(imageSize))), CompositeSourceOver, m_renderImage.shouldRespectImageOrientation());
- errorPictureDrawn = true;
- }
-
- if (!m_renderImage.altText().isEmpty()) {
- const Font& font = m_renderImage.style()->font();
- const FontMetrics& fontMetrics = font.fontMetrics();
- LayoutUnit ascent = fontMetrics.ascent();
- LayoutPoint textRectOrigin = paintOffset;
- textRectOrigin.move(leftBorder + leftPad + (RenderImage::paddingWidth / 2) - borderWidth, topBorder + topPad + (RenderImage::paddingHeight / 2) - borderWidth);
- FloatPoint textOrigin(textRectOrigin.x().toFloat(), (textRectOrigin.y() + ascent).toFloat());
-
- // Only draw the alt text if it'll fit within the content box,
- // and only if it fits above the error image.
- TextRun textRun = constructTextRun(&m_renderImage, font, m_renderImage.altText(), m_renderImage.style(), TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion, DefaultTextRunFlags | RespectDirection);
- float textWidth = font.width(textRun);
- TextRunPaintInfo textRunPaintInfo(textRun);
- textRunPaintInfo.bounds = FloatRect(FloatPoint(textRectOrigin), FloatSize(textWidth, fontMetrics.height()));
- context->setFillColor(m_renderImage.resolveColor(CSSPropertyColor));
- if (textRun.direction() == RTL) {
- int availableWidth = cWidth - static_cast<int>(RenderImage::paddingWidth);
- textOrigin.move(availableWidth - ceilf(textWidth), 0);
- }
- if (errorPictureDrawn) {
- if (usableWidth >= textWidth && fontMetrics.height() <= imageOffset.height())
- context->drawBidiText(font, textRunPaintInfo, textOrigin);
- } else if (usableWidth >= textWidth && usableHeight >= fontMetrics.height()) {
- context->drawBidiText(font, textRunPaintInfo, textOrigin);
- }
- }
}
- } else if (m_renderImage.imageResource()->hasImage() && cWidth > 0 && cHeight > 0) {
+ } else if (cWidth > 0 && cHeight > 0) {
LayoutRect contentRect = m_renderImage.contentBoxRect();
contentRect.moveBy(paintOffset);
LayoutRect paintRect = m_renderImage.replacedContentRect();
diff --git a/third_party/WebKit/Source/core/rendering/RenderBox.cpp b/third_party/WebKit/Source/core/rendering/RenderBox.cpp
index 63b3f97..e74f881 100644
--- a/third_party/WebKit/Source/core/rendering/RenderBox.cpp
+++ b/third_party/WebKit/Source/core/rendering/RenderBox.cpp
@@ -3791,7 +3791,7 @@ bool RenderBox::shrinkToAvoidFloats() const
static bool isReplacedElement(Node* node)
{
// Checkboxes and radioboxes are not isReplaced() nor do they have their own renderer in which to override avoidFloats().
- return node && node->isElementNode() && toElement(node)->isFormControlElement();
+ return node && node->isElementNode() && (toElement(node)->isFormControlElement() || isHTMLImageElement(toElement(node)));
}
bool RenderBox::avoidsFloats() const
diff --git a/third_party/WebKit/Source/core/rendering/RenderImage.cpp b/third_party/WebKit/Source/core/rendering/RenderImage.cpp
index e36c6f7..8e79299 100644
--- a/third_party/WebKit/Source/core/rendering/RenderImage.cpp
+++ b/third_party/WebKit/Source/core/rendering/RenderImage.cpp
@@ -59,7 +59,6 @@ RenderImage::RenderImage(Element* element)
, m_isGeneratedContent(false)
, m_imageDevicePixelRatio(1.0f)
{
- updateAltText();
ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->addRenderObject(this);
}
@@ -88,59 +87,6 @@ void RenderImage::setImageResource(PassOwnPtr<RenderImageResource> imageResource
m_imageResource->initialize(this);
}
-// Alt text is restricted to this maximum size, in pixels. These are
-// signed integers because they are compared with other signed values.
-static const float maxAltTextWidth = 1024;
-static const int maxAltTextHeight = 256;
-
-IntSize RenderImage::imageSizeForError(ImageResource* newImage) const
-{
- ASSERT_ARG(newImage, newImage);
- ASSERT_ARG(newImage, newImage->imageForRenderer(this));
-
- IntSize imageSize;
- if (newImage->willPaintBrokenImage()) {
- float deviceScaleFactor = blink::deviceScaleFactor(frame());
- pair<Image*, float> brokenImageAndImageScaleFactor = ImageResource::brokenImage(deviceScaleFactor);
- imageSize = brokenImageAndImageScaleFactor.first->size();
- imageSize.scale(1 / brokenImageAndImageScaleFactor.second);
- } else {
- imageSize = newImage->imageForRenderer(this)->size();
- }
-
- // imageSize() returns 0 for the error image. We need the true size of the
- // error image, so we have to get it by grabbing image() directly.
- return IntSize(paddingWidth + imageSize.width() * style()->effectiveZoom(), paddingHeight + imageSize.height() * style()->effectiveZoom());
-}
-
-// Sets the image height and width to fit the alt text. Returns true if the
-// image size changed.
-bool RenderImage::setImageSizeForAltText(ImageResource* newImage /* = 0 */)
-{
- LayoutSize imageSize;
- if (newImage && newImage->imageForRenderer(this)) {
- imageSize = LayoutSize(imageSizeForError(newImage));
- } else if (!m_altText.isEmpty() || newImage) {
- // If we'll be displaying either text or an image, add a little padding.
- imageSize = LayoutSize(paddingWidth, paddingHeight);
- }
-
- // we have an alt and the user meant it (its not a text we invented)
- if (!m_altText.isEmpty()) {
- FontCachePurgePreventer fontCachePurgePreventer;
-
- const Font& font = style()->font();
- LayoutSize paddedTextSize(paddingWidth + std::min(ceilf(font.width(constructTextRun(this, font, m_altText, style()))), maxAltTextWidth), paddingHeight + std::min(font.fontMetrics().height(), maxAltTextHeight));
- imageSize = imageSize.expandedTo(paddedTextSize);
- }
-
- if (imageSize == intrinsicSize())
- return false;
-
- setIntrinsicSize(imageSize);
- return true;
-}
-
void RenderImage::imageChanged(WrappedImagePtr newImage, const IntRect* rect)
{
if (documentBeingDestroyed())
@@ -166,13 +112,7 @@ void RenderImage::imageChanged(WrappedImagePtr newImage, const IntRect* rect)
m_didIncrementVisuallyNonEmptyPixelCount = true;
}
- bool imageSizeChanged = false;
-
- // Set image dimensions, taking into account the size of the alt text.
- if (m_imageResource->errorOccurred() || !newImage)
- imageSizeChanged = setImageSizeForAltText(m_imageResource->cachedImage());
-
- paintInvalidationOrMarkForLayout(imageSizeChanged, rect);
+ repaintOrMarkForLayout(rect);
}
void RenderImage::updateIntrinsicSizeIfNeeded(const LayoutSize& newSize)
@@ -191,7 +131,7 @@ void RenderImage::updateInnerContentRect()
m_imageResource->setContainerSizeForRenderer(containerSize);
}
-void RenderImage::paintInvalidationOrMarkForLayout(bool imageSizeChangedToAccomodateAltText, const IntRect* rect)
+void RenderImage::repaintOrMarkForLayout(const IntRect* rect)
{
LayoutSize oldIntrinsicSize = intrinsicSize();
LayoutSize newIntrinsicSize = m_imageResource->intrinsicSize(style()->effectiveZoom());
@@ -204,7 +144,7 @@ void RenderImage::paintInvalidationOrMarkForLayout(bool imageSizeChangedToAccomo
if (!containingBlock())
return;
- bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize || imageSizeChangedToAccomodateAltText;
+ bool imageSourceHasChangedSize = oldIntrinsicSize != newIntrinsicSize;
if (imageSourceHasChangedSize)
setPreferredLogicalWidthsDirty();
@@ -295,7 +235,7 @@ void RenderImage::areaElementFocusChanged(HTMLAreaElement* areaElement)
paintInvalidationRect.moveBy(-IntPoint(absoluteContentBoxOffset()));
paintInvalidationRect.inflate(outlineWidth);
- paintInvalidationOrMarkForLayout(false, &paintInvalidationRect);
+ repaintOrMarkForLayout(&paintInvalidationRect);
}
bool RenderImage::boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox*) const
@@ -378,17 +318,6 @@ bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
return inside;
}
-void RenderImage::updateAltText()
-{
- if (!node())
- return;
-
- if (isHTMLInputElement(*node()))
- m_altText = toHTMLInputElement(node())->altText();
- else if (isHTMLImageElement(*node()))
- m_altText = toHTMLImageElement(node())->altText();
-}
-
void RenderImage::layout()
{
RenderReplaced::layout();
diff --git a/third_party/WebKit/Source/core/rendering/RenderImage.h b/third_party/WebKit/Source/core/rendering/RenderImage.h
index 0ed41ea..99b81d3 100644
--- a/third_party/WebKit/Source/core/rendering/RenderImage.h
+++ b/third_party/WebKit/Source/core/rendering/RenderImage.h
@@ -51,10 +51,6 @@ public:
const RenderImageResource* imageResource() const { return m_imageResource.get(); }
ImageResource* cachedImage() const { return m_imageResource ? m_imageResource->cachedImage() : 0; }
- bool setImageSizeForAltText(ImageResource* newImage = 0);
-
- void updateAltText();
-
HTMLMapElement* imageMap() const;
void areaElementFocusChanged(HTMLAreaElement*);
@@ -62,8 +58,6 @@ public:
bool isGeneratedContent() const { return m_isGeneratedContent; }
- String altText() const { return m_altText; }
-
inline void setImageDevicePixelRatio(float factor) { m_imageDevicePixelRatio = factor; }
float imageDevicePixelRatio() const { return m_imageDevicePixelRatio; }
@@ -106,14 +100,12 @@ private:
virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, InlineFlowBox*) const override final;
- IntSize imageSizeForError(ImageResource*) const;
- void paintInvalidationOrMarkForLayout(bool imageSizeChanged, const IntRect* = 0);
+ void repaintOrMarkForLayout(const IntRect* = 0);
void updateIntrinsicSizeIfNeeded(const LayoutSize&);
// Update the size of the image to be rendered. Object-fit may cause this to be different from the CSS box's content rect.
void updateInnerContentRect();
// Text to display as long as the image isn't available.
- String m_altText;
OwnPtr<RenderImageResource> m_imageResource;
bool m_didIncrementVisuallyNonEmptyPixelCount;
bool m_isGeneratedContent;
diff --git a/third_party/WebKit/Source/modules/accessibility/AXRenderObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXRenderObject.cpp
index e9a15a9..8195422 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXRenderObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXRenderObject.cpp
@@ -253,6 +253,17 @@ ScrollableArea* AXRenderObject::getScrollableAreaIfScrollable() const
return box->scrollableArea();
}
+static bool isImageOrAltText(RenderBoxModelObject* box, Node* node)
+{
+ if (box && box->isImage())
+ return true;
+ if (isHTMLImageElement(node))
+ return true;
+ if (isHTMLInputElement(node) && toHTMLInputElement(node)->hasFallbackContent())
+ return true;
+ return false;
+}
+
AccessibilityRole AXRenderObject::determineAccessibilityRole()
{
if (!m_renderer)
@@ -272,7 +283,7 @@ AccessibilityRole AXRenderObject::determineAccessibilityRole()
return LegendRole;
if (m_renderer->isText())
return StaticTextRole;
- if (cssBox && cssBox->isImage()) {
+ if (cssBox && isImageOrAltText(cssBox, node)) {
if (node && node->isLink())
return ImageMapRole;
if (isHTMLInputElement(node))
@@ -683,7 +694,7 @@ bool AXRenderObject::computeAccessibilityIsIgnored() const
return true;
}
- if (isNativeImage() && m_renderer->isImage()) {
+ if (isNativeImage() && isImageOrAltText(toRenderBoxModelObject(m_renderer), node)) {
// check for one-dimensional image
RenderImage* image = toRenderImage(m_renderer);
if (image->size().height() <= 1 || image->size().width() <= 1)