| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights |
| 5 * reserved. | 5 * reserved. |
| 6 * Copyright (C) 2010 Google Inc. All rights reserved. | 6 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "core/html/HTMLImageElement.h" | 24 #include "core/html/HTMLImageElement.h" |
| 25 | 25 |
| 26 #include "bindings/core/v8/ScriptEventListener.h" | 26 #include "bindings/core/v8/ScriptEventListener.h" |
| 27 #include "core/CSSPropertyNames.h" | 27 #include "core/CSSPropertyNames.h" |
| 28 #include "core/HTMLNames.h" | 28 #include "core/HTMLNames.h" |
| 29 #include "core/MediaTypeNames.h" | 29 #include "core/MediaTypeNames.h" |
| 30 #include "core/css/MediaQueryMatcher.h" | 30 #include "core/css/MediaQueryMatcher.h" |
| 31 #include "core/css/MediaValuesDynamic.h" | 31 #include "core/css/MediaValuesDynamic.h" |
| 32 #include "core/css/parser/SizesAttributeParser.h" | 32 #include "core/css/parser/SizesAttributeParser.h" |
| 33 #include "core/dom/Attribute.h" | 33 #include "core/dom/Attribute.h" |
| 34 #include "core/dom/DOMException.h" |
| 34 #include "core/dom/NodeTraversal.h" | 35 #include "core/dom/NodeTraversal.h" |
| 35 #include "core/dom/shadow/ShadowRoot.h" | 36 #include "core/dom/shadow/ShadowRoot.h" |
| 36 #include "core/frame/Deprecation.h" | 37 #include "core/frame/Deprecation.h" |
| 37 #include "core/frame/ImageBitmap.h" | 38 #include "core/frame/ImageBitmap.h" |
| 38 #include "core/frame/LocalDOMWindow.h" | 39 #include "core/frame/LocalDOMWindow.h" |
| 39 #include "core/html/FormAssociated.h" | 40 #include "core/html/FormAssociated.h" |
| 40 #include "core/html/HTMLAnchorElement.h" | 41 #include "core/html/HTMLAnchorElement.h" |
| 41 #include "core/html/HTMLCanvasElement.h" | 42 #include "core/html/HTMLCanvasElement.h" |
| 42 #include "core/html/HTMLFormElement.h" | 43 #include "core/html/HTMLFormElement.h" |
| 43 #include "core/html/HTMLImageFallbackHelper.h" | 44 #include "core/html/HTMLImageFallbackHelper.h" |
| 44 #include "core/html/HTMLPictureElement.h" | 45 #include "core/html/HTMLPictureElement.h" |
| 45 #include "core/html/HTMLSourceElement.h" | 46 #include "core/html/HTMLSourceElement.h" |
| 46 #include "core/html/parser/HTMLParserIdioms.h" | 47 #include "core/html/parser/HTMLParserIdioms.h" |
| 47 #include "core/html/parser/HTMLSrcsetParser.h" | 48 #include "core/html/parser/HTMLSrcsetParser.h" |
| 48 #include "core/imagebitmap/ImageBitmapOptions.h" | 49 #include "core/imagebitmap/ImageBitmapOptions.h" |
| 49 #include "core/inspector/ConsoleMessage.h" | 50 #include "core/inspector/ConsoleMessage.h" |
| 50 #include "core/layout/LayoutBlockFlow.h" | 51 #include "core/layout/LayoutBlockFlow.h" |
| 51 #include "core/layout/LayoutImage.h" | 52 #include "core/layout/LayoutImage.h" |
| 52 #include "core/layout/api/LayoutImageItem.h" | 53 #include "core/layout/api/LayoutImageItem.h" |
| 53 #include "core/loader/resource/ImageResourceContent.h" | 54 #include "core/loader/resource/ImageResourceContent.h" |
| 55 #include "core/page/ChromeClient.h" |
| 54 #include "core/page/Page.h" | 56 #include "core/page/Page.h" |
| 55 #include "core/style/ContentData.h" | 57 #include "core/style/ContentData.h" |
| 56 #include "core/svg/graphics/SVGImageForContainer.h" | 58 #include "core/svg/graphics/SVGImageForContainer.h" |
| 57 #include "platform/EventDispatchForbiddenScope.h" | 59 #include "platform/EventDispatchForbiddenScope.h" |
| 58 #include "platform/network/mime/ContentType.h" | 60 #include "platform/network/mime/ContentType.h" |
| 59 #include "platform/network/mime/MIMETypeRegistry.h" | 61 #include "platform/network/mime/MIMETypeRegistry.h" |
| 60 #include "platform/weborigin/SecurityPolicy.h" | 62 #include "platform/weborigin/SecurityPolicy.h" |
| 61 | 63 |
| 62 namespace blink { | 64 namespace blink { |
| 63 | 65 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 88 | 90 |
| 89 HTMLImageElement::HTMLImageElement(Document& document, bool createdByParser) | 91 HTMLImageElement::HTMLImageElement(Document& document, bool createdByParser) |
| 90 : HTMLElement(imgTag, document), | 92 : HTMLElement(imgTag, document), |
| 91 m_imageLoader(HTMLImageLoader::create(this)), | 93 m_imageLoader(HTMLImageLoader::create(this)), |
| 92 m_imageDevicePixelRatio(1.0f), | 94 m_imageDevicePixelRatio(1.0f), |
| 93 m_source(nullptr), | 95 m_source(nullptr), |
| 94 m_layoutDisposition(LayoutDisposition::PrimaryContent), | 96 m_layoutDisposition(LayoutDisposition::PrimaryContent), |
| 95 m_formWasSetByParser(false), | 97 m_formWasSetByParser(false), |
| 96 m_elementCreatedByParser(createdByParser), | 98 m_elementCreatedByParser(createdByParser), |
| 97 m_isFallbackImage(false), | 99 m_isFallbackImage(false), |
| 98 m_referrerPolicy(ReferrerPolicyDefault) { | 100 m_referrerPolicy(ReferrerPolicyDefault), |
| 101 m_weakPtrFactory(this) { |
| 99 setHasCustomStyleCallbacks(); | 102 setHasCustomStyleCallbacks(); |
| 100 } | 103 } |
| 101 | 104 |
| 102 HTMLImageElement* HTMLImageElement::create(Document& document) { | 105 HTMLImageElement* HTMLImageElement::create(Document& document) { |
| 103 return new HTMLImageElement(document); | 106 return new HTMLImageElement(document); |
| 104 } | 107 } |
| 105 | 108 |
| 106 HTMLImageElement* HTMLImageElement::create(Document& document, | 109 HTMLImageElement* HTMLImageElement::create(Document& document, |
| 107 bool createdByParser) { | 110 bool createdByParser) { |
| 108 return new HTMLImageElement(document, createdByParser); | 111 return new HTMLImageElement(document, createdByParser); |
| 109 } | 112 } |
| 110 | 113 |
| 111 HTMLImageElement::~HTMLImageElement() {} | 114 HTMLImageElement::~HTMLImageElement() { |
| 115 m_weakPtrFactory.revokeAll(); |
| 116 } |
| 112 | 117 |
| 113 DEFINE_TRACE(HTMLImageElement) { | 118 DEFINE_TRACE(HTMLImageElement) { |
| 114 visitor->trace(m_imageLoader); | 119 visitor->trace(m_imageLoader); |
| 115 visitor->trace(m_listener); | 120 visitor->trace(m_listener); |
| 116 visitor->trace(m_form); | 121 visitor->trace(m_form); |
| 117 visitor->trace(m_source); | 122 visitor->trace(m_source); |
| 123 visitor->trace(m_decodePromiseResolvers); |
| 118 HTMLElement::trace(visitor); | 124 HTMLElement::trace(visitor); |
| 119 } | 125 } |
| 120 | 126 |
| 121 void HTMLImageElement::notifyViewportChanged() { | 127 void HTMLImageElement::notifyViewportChanged() { |
| 122 // Re-selecting the source URL in order to pick a more fitting resource | 128 // Re-selecting the source URL in order to pick a more fitting resource |
| 123 // And update the image's intrinsic dimensions when the viewport changes. | 129 // And update the image's intrinsic dimensions when the viewport changes. |
| 124 // Picking of a better fitting resource is UA dependant, not spec required. | 130 // Picking of a better fitting resource is UA dependant, not spec required. |
| 125 selectSourceURL(ImageLoader::UpdateSizeChanged); | 131 selectSourceURL(ImageLoader::UpdateSizeChanged); |
| 126 } | 132 } |
| 127 | 133 |
| 134 void HTMLImageElement::requestDecode() { |
| 135 DCHECK(!m_decodePromiseResolvers.isEmpty()); |
| 136 if (!imageLoader().image() || !imageLoader().image()->getImage()) { |
| 137 didDecode(false); |
| 138 return; |
| 139 } |
| 140 Image* image = imageLoader().image()->getImage(); |
| 141 auto* page = document().page(); |
| 142 if (page) { |
| 143 page->chromeClient().requestDecode( |
| 144 image->imageForCurrentFrame(), |
| 145 WTF::bind(&HTMLImageElement::didDecode, |
| 146 m_weakPtrFactory.createWeakPtr())); |
| 147 } |
| 148 } |
| 149 |
| 150 void HTMLImageElement::didDecode(bool success) { |
| 151 if (m_decodePromiseResolvers.isEmpty()) |
| 152 return; |
| 153 static auto resolve = [](ScriptPromiseResolver* resolver) { |
| 154 resolver->resolve(); |
| 155 }; |
| 156 static auto reject = [](ScriptPromiseResolver* resolver) { |
| 157 resolver->reject(DOMException::create( |
| 158 EncodingError, "The source image cannot be decoded")); |
| 159 }; |
| 160 auto process = success ? resolve : reject; |
| 161 for (auto& resolver : m_decodePromiseResolvers) |
| 162 process(resolver); |
| 163 m_decodePromiseResolvers.clear(); |
| 164 } |
| 165 |
| 128 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document) { | 166 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document) { |
| 129 HTMLImageElement* image = new HTMLImageElement(document); | 167 HTMLImageElement* image = new HTMLImageElement(document); |
| 130 image->m_elementCreatedByParser = false; | 168 image->m_elementCreatedByParser = false; |
| 131 return image; | 169 return image; |
| 132 } | 170 } |
| 133 | 171 |
| 134 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document, | 172 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document, |
| 135 unsigned width) { | 173 unsigned width) { |
| 136 HTMLImageElement* image = new HTMLImageElement(document); | 174 HTMLImageElement* image = new HTMLImageElement(document); |
| 137 image->setWidth(width); | 175 image->setWidth(width); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 const QualifiedName& name = params.name; | 291 const QualifiedName& name = params.name; |
| 254 if (name == altAttr || name == titleAttr) { | 292 if (name == altAttr || name == titleAttr) { |
| 255 if (userAgentShadowRoot()) { | 293 if (userAgentShadowRoot()) { |
| 256 Element* text = userAgentShadowRoot()->getElementById("alttext"); | 294 Element* text = userAgentShadowRoot()->getElementById("alttext"); |
| 257 String value = altText(); | 295 String value = altText(); |
| 258 if (text && text->textContent() != params.newValue) | 296 if (text && text->textContent() != params.newValue) |
| 259 text->setTextContent(altText()); | 297 text->setTextContent(altText()); |
| 260 } | 298 } |
| 261 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { | 299 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { |
| 262 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); | 300 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); |
| 301 // Ensure to fail any pending decodes on possible source changes. |
| 302 if (!m_decodePromiseResolvers.isEmpty() && |
| 303 params.oldValue != params.newValue) { |
| 304 didDecode(false); |
| 305 m_weakPtrFactory.revokeAll(); |
| 306 } |
| 263 } else if (name == usemapAttr) { | 307 } else if (name == usemapAttr) { |
| 264 setIsLink(!params.newValue.isNull()); | 308 setIsLink(!params.newValue.isNull()); |
| 265 } else if (name == referrerpolicyAttr) { | 309 } else if (name == referrerpolicyAttr) { |
| 266 m_referrerPolicy = ReferrerPolicyDefault; | 310 m_referrerPolicy = ReferrerPolicyDefault; |
| 267 if (!params.newValue.isNull()) { | 311 if (!params.newValue.isNull()) { |
| 268 SecurityPolicy::referrerPolicyFromString( | 312 SecurityPolicy::referrerPolicyFromString( |
| 269 params.newValue, SupportReferrerPolicyLegacyKeywords, | 313 params.newValue, SupportReferrerPolicyLegacyKeywords, |
| 270 &m_referrerPolicy); | 314 &m_referrerPolicy); |
| 271 UseCounter::count(document(), | 315 UseCounter::count(document(), |
| 272 UseCounter::HTMLImageElementReferrerPolicyAttribute); | 316 UseCounter::HTMLImageElementReferrerPolicyAttribute); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 // our loader may have not fetched the image, so do it now. | 452 // our loader may have not fetched the image, so do it now. |
| 409 if ((insertionPoint->isConnected() && !imageLoader().image()) || | 453 if ((insertionPoint->isConnected() && !imageLoader().image()) || |
| 410 imageWasModified) | 454 imageWasModified) |
| 411 imageLoader().updateFromElement(ImageLoader::UpdateNormal, | 455 imageLoader().updateFromElement(ImageLoader::UpdateNormal, |
| 412 m_referrerPolicy); | 456 m_referrerPolicy); |
| 413 | 457 |
| 414 return HTMLElement::insertedInto(insertionPoint); | 458 return HTMLElement::insertedInto(insertionPoint); |
| 415 } | 459 } |
| 416 | 460 |
| 417 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) { | 461 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) { |
| 418 if (!m_form || | 462 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != |
| 419 NodeTraversal::highestAncestorOrSelf(*m_form.get()) != | 463 NodeTraversal::highestAncestorOrSelf(*this)) |
| 420 NodeTraversal::highestAncestorOrSelf(*this)) | |
| 421 resetFormOwner(); | 464 resetFormOwner(); |
| 422 if (m_listener) { | 465 if (m_listener) { |
| 423 document().mediaQueryMatcher().removeViewportListener(m_listener); | 466 document().mediaQueryMatcher().removeViewportListener(m_listener); |
| 424 Node* parent = parentNode(); | 467 Node* parent = parentNode(); |
| 425 if (parent && isHTMLPictureElement(*parent)) | 468 if (parent && isHTMLPictureElement(*parent)) |
| 426 toHTMLPictureElement(parent)->removeListenerFromSourceChildren(); | 469 toHTMLPictureElement(parent)->removeListenerFromSourceChildren(); |
| 427 } | 470 } |
| 428 HTMLElement::removedFrom(insertionPoint); | 471 HTMLElement::removedFrom(insertionPoint); |
| 429 } | 472 } |
| 430 | 473 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 } | 560 } |
| 518 | 561 |
| 519 const String& HTMLImageElement::currentSrc() const { | 562 const String& HTMLImageElement::currentSrc() const { |
| 520 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#dom-
img-currentsrc | 563 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#dom-
img-currentsrc |
| 521 // The currentSrc IDL attribute must return the img element's current | 564 // The currentSrc IDL attribute must return the img element's current |
| 522 // request's current URL. | 565 // request's current URL. |
| 523 | 566 |
| 524 // Return the picked URL string in case of load error. | 567 // Return the picked URL string in case of load error. |
| 525 if (imageLoader().hadError()) | 568 if (imageLoader().hadError()) |
| 526 return m_bestFitImageURL; | 569 return m_bestFitImageURL; |
| 527 // Initially, the pending request turns into current request when it is either | 570 // Initially, the pending request turns into current request when it is |
| 528 // available or broken. We use the image's dimensions as a proxy to it being | 571 // either available or broken. We use the image's dimensions as a proxy to |
| 529 // in any of these states. | 572 // it being in any of these states. |
| 530 if (!imageLoader().image() || !imageLoader().image()->getImage() || | 573 if (!imageLoader().image() || !imageLoader().image()->getImage() || |
| 531 !imageLoader().image()->getImage()->width()) | 574 !imageLoader().image()->getImage()->width()) |
| 532 return emptyAtom; | 575 return emptyAtom; |
| 533 | 576 |
| 534 return imageLoader().image()->url().getString(); | 577 return imageLoader().image()->url().getString(); |
| 535 } | 578 } |
| 536 | 579 |
| 537 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const { | 580 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const { |
| 538 return attribute.name() == srcAttr || attribute.name() == lowsrcAttr || | 581 return attribute.name() == srcAttr || attribute.name() == lowsrcAttr || |
| 539 attribute.name() == longdescAttr || | 582 attribute.name() == longdescAttr || |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 628 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 586 LayoutObject* r = layoutObject(); | 629 LayoutObject* r = layoutObject(); |
| 587 if (!r) | 630 if (!r) |
| 588 return 0; | 631 return 0; |
| 589 | 632 |
| 590 // FIXME: This doesn't work correctly with transforms. | 633 // FIXME: This doesn't work correctly with transforms. |
| 591 FloatPoint absPos = r->localToAbsolute(); | 634 FloatPoint absPos = r->localToAbsolute(); |
| 592 return absPos.y(); | 635 return absPos.y(); |
| 593 } | 636 } |
| 594 | 637 |
| 638 ScriptPromise HTMLImageElement::decode(ScriptState* scriptState, |
| 639 ExceptionState& exceptionState) { |
| 640 exceptionState.clearException(); |
| 641 m_decodePromiseResolvers.push_back( |
| 642 ScriptPromiseResolver::create(scriptState)); |
| 643 ScriptPromise promise = m_decodePromiseResolvers.back()->promise(); |
| 644 if (complete()) |
| 645 requestDecode(); |
| 646 return promise; |
| 647 } |
| 648 |
| 595 bool HTMLImageElement::complete() const { | 649 bool HTMLImageElement::complete() const { |
| 596 return imageLoader().imageComplete(); | 650 return imageLoader().imageComplete(); |
| 597 } | 651 } |
| 598 | 652 |
| 599 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument) { | 653 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument) { |
| 600 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); | 654 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); |
| 601 imageLoader().elementDidMoveToNewDocument(); | 655 imageLoader().elementDidMoveToNewDocument(); |
| 602 HTMLElement::didMoveToNewDocument(oldDocument); | 656 HTMLElement::didMoveToNewDocument(oldDocument); |
| 603 } | 657 } |
| 604 | 658 |
| 605 bool HTMLImageElement::isServerMap() const { | 659 bool HTMLImageElement::isServerMap() const { |
| 606 if (!fastHasAttribute(ismapAttr)) | 660 if (!fastHasAttribute(ismapAttr)) |
| 607 return false; | 661 return false; |
| 608 | 662 |
| 609 const AtomicString& usemap = fastGetAttribute(usemapAttr); | 663 const AtomicString& usemap = fastGetAttribute(usemapAttr); |
| 610 | 664 |
| 611 // If the usemap attribute starts with '#', it refers to a map element in the | 665 // If the usemap attribute starts with '#', it refers to a map element in |
| 612 // document. | 666 // the document. |
| 613 if (usemap[0] == '#') | 667 if (usemap[0] == '#') |
| 614 return false; | 668 return false; |
| 615 | 669 |
| 616 return document() | 670 return document() |
| 617 .completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)) | 671 .completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)) |
| 618 .isEmpty(); | 672 .isEmpty(); |
| 619 } | 673 } |
| 620 | 674 |
| 621 Image* HTMLImageElement::imageContents() { | 675 Image* HTMLImageElement::imageContents() { |
| 622 if (!imageLoader().imageComplete()) | 676 if (!imageLoader().imageComplete()) |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 return m_layoutDisposition == LayoutDisposition::Collapsed; | 907 return m_layoutDisposition == LayoutDisposition::Collapsed; |
| 854 } | 908 } |
| 855 | 909 |
| 856 void HTMLImageElement::setLayoutDisposition(LayoutDisposition layoutDisposition, | 910 void HTMLImageElement::setLayoutDisposition(LayoutDisposition layoutDisposition, |
| 857 bool forceReattach) { | 911 bool forceReattach) { |
| 858 if (m_layoutDisposition == layoutDisposition && !forceReattach) | 912 if (m_layoutDisposition == layoutDisposition && !forceReattach) |
| 859 return; | 913 return; |
| 860 | 914 |
| 861 m_layoutDisposition = layoutDisposition; | 915 m_layoutDisposition = layoutDisposition; |
| 862 | 916 |
| 863 // This can happen inside of attachLayoutTree() in the middle of a recalcStyle | 917 // This can happen inside of attachLayoutTree() in the middle of a |
| 864 // so we need to reattach synchronously here. | 918 // recalcStyle so we need to reattach synchronously here. |
| 865 if (document().inStyleRecalc()) { | 919 if (document().inStyleRecalc()) { |
| 866 reattachLayoutTree(); | 920 reattachLayoutTree(); |
| 867 } else { | 921 } else { |
| 868 if (m_layoutDisposition == LayoutDisposition::FallbackContent) { | 922 if (m_layoutDisposition == LayoutDisposition::FallbackContent) { |
| 869 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; | 923 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; |
| 870 ensureUserAgentShadowRoot(); | 924 ensureUserAgentShadowRoot(); |
| 871 } | 925 } |
| 872 lazyReattachIfAttached(); | 926 lazyReattachIfAttached(); |
| 873 } | 927 } |
| 874 } | 928 } |
| 875 | 929 |
| 876 PassRefPtr<ComputedStyle> HTMLImageElement::customStyleForLayoutObject() { | 930 PassRefPtr<ComputedStyle> HTMLImageElement::customStyleForLayoutObject() { |
| 877 switch (m_layoutDisposition) { | 931 switch (m_layoutDisposition) { |
| 878 case LayoutDisposition::PrimaryContent: // Fall through. | 932 case LayoutDisposition::PrimaryContent: // Fall through. |
| 879 case LayoutDisposition::Collapsed: | 933 case LayoutDisposition::Collapsed: |
| 880 return originalStyleForLayoutObject(); | 934 return originalStyleForLayoutObject(); |
| 881 case LayoutDisposition::FallbackContent: | 935 case LayoutDisposition::FallbackContent: |
| 882 return HTMLImageFallbackHelper::customStyleForAltText( | 936 return HTMLImageFallbackHelper::customStyleForAltText( |
| 883 *this, ComputedStyle::clone(*originalStyleForLayoutObject())); | 937 *this, ComputedStyle::clone(*originalStyleForLayoutObject())); |
| 884 default: | 938 default: |
| 885 NOTREACHED(); | 939 NOTREACHED(); |
| 886 return nullptr; | 940 return nullptr; |
| 887 } | 941 } |
| 888 } | 942 } |
| 889 | 943 |
| 944 void HTMLImageElement::defaultEventHandler(Event* event) { |
| 945 HTMLElement::defaultEventHandler(event); |
| 946 if (m_decodePromiseResolvers.isEmpty()) |
| 947 return; |
| 948 |
| 949 if (event->type() == EventTypeNames::load) { |
| 950 requestDecode(); |
| 951 } else if (event->type() == EventTypeNames::error) { |
| 952 didDecode(false); |
| 953 } |
| 954 } |
| 955 |
| 890 bool HTMLImageElement::isOpaque() const { | 956 bool HTMLImageElement::isOpaque() const { |
| 891 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 957 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
| 892 return image && image->currentFrameKnownToBeOpaque(); | 958 return image && image->currentFrameKnownToBeOpaque(); |
| 893 } | 959 } |
| 894 | 960 |
| 895 int HTMLImageElement::sourceWidth() { | 961 int HTMLImageElement::sourceWidth() { |
| 896 SourceImageStatus status; | 962 SourceImageStatus status; |
| 897 FloatSize defaultObjectSize(width(), height()); | 963 FloatSize defaultObjectSize(width(), height()); |
| 898 RefPtr<Image> image = getSourceImageForCanvas( | 964 RefPtr<Image> image = getSourceImageForCanvas( |
| 899 &status, PreferNoAcceleration, SnapshotReasonUnknown, defaultObjectSize); | 965 &status, PreferNoAcceleration, SnapshotReasonUnknown, defaultObjectSize); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 921 void HTMLImageElement::associateWith(HTMLFormElement* form) { | 987 void HTMLImageElement::associateWith(HTMLFormElement* form) { |
| 922 if (form && form->isConnected()) { | 988 if (form && form->isConnected()) { |
| 923 m_form = form; | 989 m_form = form; |
| 924 m_formWasSetByParser = true; | 990 m_formWasSetByParser = true; |
| 925 m_form->associate(*this); | 991 m_form->associate(*this); |
| 926 m_form->didAssociateByParser(); | 992 m_form->didAssociateByParser(); |
| 927 } | 993 } |
| 928 }; | 994 }; |
| 929 | 995 |
| 930 } // namespace blink | 996 } // namespace blink |
| OLD | NEW |