Index: Source/core/html/HTMLImageElement.cpp |
diff --git a/Source/core/html/HTMLImageElement.cpp b/Source/core/html/HTMLImageElement.cpp |
index b1711c31f765bcbafc2543faf088d02f6e1c868e..088f5dd4627b4896b03d7a84b3fff6749e40b224 100644 |
--- a/Source/core/html/HTMLImageElement.cpp |
+++ b/Source/core/html/HTMLImageElement.cpp |
@@ -32,20 +32,16 @@ |
#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" |
@@ -88,10 +84,7 @@ |
, 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; |
@@ -242,13 +235,9 @@ |
void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicString& value) |
{ |
- if (name == altAttr || name == titleAttr) { |
- if (userAgentShadowRoot()) { |
- Element* text = userAgentShadowRoot()->getElementById("alttext"); |
- String value = altText(); |
- if (text && text->textContent() != value) |
- text->setTextContent(altText()); |
- } |
+ if (name == altAttr) { |
+ if (renderer() && renderer()->isImage()) |
+ toRenderImage(renderer())->updateAltText(); |
} else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { |
selectSourceURL(ImageLoader::UpdateIgnorePreviousError); |
} else if (name == usemapAttr) { |
@@ -258,7 +247,7 @@ |
} |
} |
-String HTMLImageElement::altText() const |
+const AtomicString& HTMLImageElement::altText() const |
{ |
// lets figure out the alt text.. magic stuff |
// http://www.w3.org/TR/1998/REC-html40-19980424/appendix/notes.html#altgen |
@@ -324,9 +313,6 @@ |
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); |
@@ -348,18 +334,16 @@ |
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); |
- ResourcePtr<ImageResource> newImageResource = new ImageResource(brokenImageAndImageScaleFactor.first); |
- renderImage->imageResource()->setImageResource(newImageResource.get()); |
- } |
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()) |
- return; |
- renderImageResource->setImageResource(imageLoader().image()); |
+ renderImage->setImageSizeForAltText(); |
+ else |
+ renderImageResource->setImageResource(imageLoader().image()); |
+ |
} |
} |
@@ -382,7 +366,7 @@ |
// 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); |
+ imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_elementCreatedByParser ? ImageLoader::ForceLoadImmediately : ImageLoader::LoadNormally); |
return HTMLElement::insertedInto(insertionPoint); |
} |
@@ -659,11 +643,6 @@ |
document().mediaQueryMatcher().addViewportListener(m_listener); |
} |
imageLoader().updateFromElement(behavior); |
- |
- if (imageLoader().image() || (imageLoader().hasPendingActivity() && !imageSourceURL().isEmpty())) |
- ensurePrimaryContent(); |
- else |
- ensureFallbackContent(); |
} |
const KURL& HTMLImageElement::sourceURL() const |
@@ -671,51 +650,4 @@ |
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(); |
-} |
-} |
+} |