Chromium Code Reviews| 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( | |
|
dcheng
2017/04/12 06:53:16
After reading this through, I think it's fine to j
vmpstr
2017/04/17 18:13:11
Done. Let me know if this looks better...
| |
| 144 image->imageForCurrentFrame(), | |
| 145 WTF::bind(&HTMLImageElement::didDecode, | |
| 146 m_weakPtrFactory.createWeakPtr())); | |
|
kouhei (in TOK)
2017/04/07 14:26:28
wrapWeakPersistent(this)?
vmpstr
2017/04/07 20:43:43
Hmm, we have to revoke the weak ptrs if the src of
dcheng
2017/04/12 06:53:16
Other potential options:
- PostCancellableTask, wh
vmpstr
2017/04/17 18:13:11
Done, I used a sequence number here with wrapWeakP
| |
| 147 } | |
| 148 } | |
| 149 | |
| 150 void HTMLImageElement::didDecode(bool success) { | |
| 151 if (m_decodePromiseResolvers.isEmpty()) | |
| 152 return; | |
| 153 if (success) { | |
| 154 for (auto& resolver : m_decodePromiseResolvers) | |
| 155 resolver->resolve(); | |
| 156 } else { | |
| 157 for (auto& resolver : m_decodePromiseResolvers) { | |
| 158 resolver->reject(DOMException::create( | |
| 159 EncodingError, "The source image cannot be decoded")); | |
| 160 } | |
| 161 } | |
| 162 m_decodePromiseResolvers.clear(); | |
| 163 } | |
| 164 | |
| 128 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document) { | 165 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document) { |
| 129 HTMLImageElement* image = new HTMLImageElement(document); | 166 HTMLImageElement* image = new HTMLImageElement(document); |
| 130 image->m_elementCreatedByParser = false; | 167 image->m_elementCreatedByParser = false; |
| 131 return image; | 168 return image; |
| 132 } | 169 } |
| 133 | 170 |
| 134 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document, | 171 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document, |
| 135 unsigned width) { | 172 unsigned width) { |
| 136 HTMLImageElement* image = new HTMLImageElement(document); | 173 HTMLImageElement* image = new HTMLImageElement(document); |
| 137 image->setWidth(width); | 174 image->setWidth(width); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 const QualifiedName& name = params.name; | 290 const QualifiedName& name = params.name; |
| 254 if (name == altAttr || name == titleAttr) { | 291 if (name == altAttr || name == titleAttr) { |
| 255 if (userAgentShadowRoot()) { | 292 if (userAgentShadowRoot()) { |
| 256 Element* text = userAgentShadowRoot()->getElementById("alttext"); | 293 Element* text = userAgentShadowRoot()->getElementById("alttext"); |
| 257 String value = altText(); | 294 String value = altText(); |
| 258 if (text && text->textContent() != params.newValue) | 295 if (text && text->textContent() != params.newValue) |
| 259 text->setTextContent(altText()); | 296 text->setTextContent(altText()); |
| 260 } | 297 } |
| 261 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { | 298 } else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) { |
| 262 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); | 299 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); |
| 300 // Ensure to fail any pending decodes on possible source changes. | |
| 301 if (!m_decodePromiseResolvers.isEmpty() && | |
| 302 params.oldValue != params.newValue) { | |
| 303 didDecode(false); | |
| 304 m_weakPtrFactory.revokeAll(); | |
| 305 } | |
| 263 } else if (name == usemapAttr) { | 306 } else if (name == usemapAttr) { |
| 264 setIsLink(!params.newValue.isNull()); | 307 setIsLink(!params.newValue.isNull()); |
| 265 } else if (name == referrerpolicyAttr) { | 308 } else if (name == referrerpolicyAttr) { |
| 266 m_referrerPolicy = ReferrerPolicyDefault; | 309 m_referrerPolicy = ReferrerPolicyDefault; |
| 267 if (!params.newValue.isNull()) { | 310 if (!params.newValue.isNull()) { |
| 268 SecurityPolicy::referrerPolicyFromString( | 311 SecurityPolicy::referrerPolicyFromString( |
| 269 params.newValue, SupportReferrerPolicyLegacyKeywords, | 312 params.newValue, SupportReferrerPolicyLegacyKeywords, |
| 270 &m_referrerPolicy); | 313 &m_referrerPolicy); |
| 271 UseCounter::count(document(), | 314 UseCounter::count(document(), |
| 272 UseCounter::HTMLImageElementReferrerPolicyAttribute); | 315 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. | 451 // our loader may have not fetched the image, so do it now. |
| 409 if ((insertionPoint->isConnected() && !imageLoader().image()) || | 452 if ((insertionPoint->isConnected() && !imageLoader().image()) || |
| 410 imageWasModified) | 453 imageWasModified) |
| 411 imageLoader().updateFromElement(ImageLoader::UpdateNormal, | 454 imageLoader().updateFromElement(ImageLoader::UpdateNormal, |
| 412 m_referrerPolicy); | 455 m_referrerPolicy); |
| 413 | 456 |
| 414 return HTMLElement::insertedInto(insertionPoint); | 457 return HTMLElement::insertedInto(insertionPoint); |
| 415 } | 458 } |
| 416 | 459 |
| 417 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) { | 460 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) { |
| 418 if (!m_form || | 461 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != |
| 419 NodeTraversal::highestAncestorOrSelf(*m_form.get()) != | 462 NodeTraversal::highestAncestorOrSelf(*this)) |
| 420 NodeTraversal::highestAncestorOrSelf(*this)) | |
| 421 resetFormOwner(); | 463 resetFormOwner(); |
| 422 if (m_listener) { | 464 if (m_listener) { |
| 423 document().mediaQueryMatcher().removeViewportListener(m_listener); | 465 document().mediaQueryMatcher().removeViewportListener(m_listener); |
| 424 Node* parent = parentNode(); | 466 Node* parent = parentNode(); |
| 425 if (parent && isHTMLPictureElement(*parent)) | 467 if (parent && isHTMLPictureElement(*parent)) |
| 426 toHTMLPictureElement(parent)->removeListenerFromSourceChildren(); | 468 toHTMLPictureElement(parent)->removeListenerFromSourceChildren(); |
| 427 } | 469 } |
| 428 HTMLElement::removedFrom(insertionPoint); | 470 HTMLElement::removedFrom(insertionPoint); |
| 429 } | 471 } |
| 430 | 472 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 517 } | 559 } |
| 518 | 560 |
| 519 const String& HTMLImageElement::currentSrc() const { | 561 const String& HTMLImageElement::currentSrc() const { |
| 520 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#dom- img-currentsrc | 562 // 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 | 563 // The currentSrc IDL attribute must return the img element's current |
| 522 // request's current URL. | 564 // request's current URL. |
| 523 | 565 |
| 524 // Return the picked URL string in case of load error. | 566 // Return the picked URL string in case of load error. |
| 525 if (imageLoader().hadError()) | 567 if (imageLoader().hadError()) |
| 526 return m_bestFitImageURL; | 568 return m_bestFitImageURL; |
| 527 // Initially, the pending request turns into current request when it is either | 569 // 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 | 570 // either available or broken. We use the image's dimensions as a proxy to |
| 529 // in any of these states. | 571 // it being in any of these states. |
| 530 if (!imageLoader().image() || !imageLoader().image()->getImage() || | 572 if (!imageLoader().image() || !imageLoader().image()->getImage() || |
| 531 !imageLoader().image()->getImage()->width()) | 573 !imageLoader().image()->getImage()->width()) |
| 532 return emptyAtom; | 574 return emptyAtom; |
| 533 | 575 |
| 534 return imageLoader().image()->url().getString(); | 576 return imageLoader().image()->url().getString(); |
| 535 } | 577 } |
| 536 | 578 |
| 537 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const { | 579 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const { |
| 538 return attribute.name() == srcAttr || attribute.name() == lowsrcAttr || | 580 return attribute.name() == srcAttr || attribute.name() == lowsrcAttr || |
| 539 attribute.name() == longdescAttr || | 581 attribute.name() == longdescAttr || |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 627 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 586 LayoutObject* r = layoutObject(); | 628 LayoutObject* r = layoutObject(); |
| 587 if (!r) | 629 if (!r) |
| 588 return 0; | 630 return 0; |
| 589 | 631 |
| 590 // FIXME: This doesn't work correctly with transforms. | 632 // FIXME: This doesn't work correctly with transforms. |
| 591 FloatPoint absPos = r->localToAbsolute(); | 633 FloatPoint absPos = r->localToAbsolute(); |
| 592 return absPos.y(); | 634 return absPos.y(); |
| 593 } | 635 } |
| 594 | 636 |
| 637 ScriptPromise HTMLImageElement::decode(ScriptState* scriptState, | |
| 638 ExceptionState& exceptionState) { | |
| 639 exceptionState.clearException(); | |
| 640 m_decodePromiseResolvers.push_back( | |
| 641 ScriptPromiseResolver::create(scriptState)); | |
| 642 ScriptPromise promise = m_decodePromiseResolvers.back()->promise(); | |
| 643 if (complete()) | |
| 644 requestDecode(); | |
| 645 return promise; | |
| 646 } | |
| 647 | |
| 595 bool HTMLImageElement::complete() const { | 648 bool HTMLImageElement::complete() const { |
| 596 return imageLoader().imageComplete(); | 649 return imageLoader().imageComplete(); |
| 597 } | 650 } |
| 598 | 651 |
| 599 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument) { | 652 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument) { |
| 600 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); | 653 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); |
| 601 imageLoader().elementDidMoveToNewDocument(); | 654 imageLoader().elementDidMoveToNewDocument(); |
| 602 HTMLElement::didMoveToNewDocument(oldDocument); | 655 HTMLElement::didMoveToNewDocument(oldDocument); |
| 603 } | 656 } |
| 604 | 657 |
| 605 bool HTMLImageElement::isServerMap() const { | 658 bool HTMLImageElement::isServerMap() const { |
| 606 if (!fastHasAttribute(ismapAttr)) | 659 if (!fastHasAttribute(ismapAttr)) |
| 607 return false; | 660 return false; |
| 608 | 661 |
| 609 const AtomicString& usemap = fastGetAttribute(usemapAttr); | 662 const AtomicString& usemap = fastGetAttribute(usemapAttr); |
| 610 | 663 |
| 611 // If the usemap attribute starts with '#', it refers to a map element in the | 664 // If the usemap attribute starts with '#', it refers to a map element in |
| 612 // document. | 665 // the document. |
| 613 if (usemap[0] == '#') | 666 if (usemap[0] == '#') |
| 614 return false; | 667 return false; |
| 615 | 668 |
| 616 return document() | 669 return document() |
| 617 .completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)) | 670 .completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)) |
| 618 .isEmpty(); | 671 .isEmpty(); |
| 619 } | 672 } |
| 620 | 673 |
| 621 Image* HTMLImageElement::imageContents() { | 674 Image* HTMLImageElement::imageContents() { |
| 622 if (!imageLoader().imageComplete()) | 675 if (!imageLoader().imageComplete()) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 return m_layoutDisposition == LayoutDisposition::Collapsed; | 845 return m_layoutDisposition == LayoutDisposition::Collapsed; |
| 793 } | 846 } |
| 794 | 847 |
| 795 void HTMLImageElement::setLayoutDisposition(LayoutDisposition layoutDisposition, | 848 void HTMLImageElement::setLayoutDisposition(LayoutDisposition layoutDisposition, |
| 796 bool forceReattach) { | 849 bool forceReattach) { |
| 797 if (m_layoutDisposition == layoutDisposition && !forceReattach) | 850 if (m_layoutDisposition == layoutDisposition && !forceReattach) |
| 798 return; | 851 return; |
| 799 | 852 |
| 800 m_layoutDisposition = layoutDisposition; | 853 m_layoutDisposition = layoutDisposition; |
| 801 | 854 |
| 802 // This can happen inside of attachLayoutTree() in the middle of a recalcStyle | 855 // This can happen inside of attachLayoutTree() in the middle of a |
| 803 // so we need to reattach synchronously here. | 856 // recalcStyle so we need to reattach synchronously here. |
| 804 if (document().inStyleRecalc()) { | 857 if (document().inStyleRecalc()) { |
| 805 reattachLayoutTree(); | 858 reattachLayoutTree(); |
| 806 } else { | 859 } else { |
| 807 if (m_layoutDisposition == LayoutDisposition::FallbackContent) { | 860 if (m_layoutDisposition == LayoutDisposition::FallbackContent) { |
| 808 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; | 861 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; |
| 809 ensureUserAgentShadowRoot(); | 862 ensureUserAgentShadowRoot(); |
| 810 } | 863 } |
| 811 lazyReattachIfAttached(); | 864 lazyReattachIfAttached(); |
| 812 } | 865 } |
| 813 } | 866 } |
| 814 | 867 |
| 815 PassRefPtr<ComputedStyle> HTMLImageElement::customStyleForLayoutObject() { | 868 PassRefPtr<ComputedStyle> HTMLImageElement::customStyleForLayoutObject() { |
| 816 switch (m_layoutDisposition) { | 869 switch (m_layoutDisposition) { |
| 817 case LayoutDisposition::PrimaryContent: // Fall through. | 870 case LayoutDisposition::PrimaryContent: // Fall through. |
| 818 case LayoutDisposition::Collapsed: | 871 case LayoutDisposition::Collapsed: |
| 819 return originalStyleForLayoutObject(); | 872 return originalStyleForLayoutObject(); |
| 820 case LayoutDisposition::FallbackContent: | 873 case LayoutDisposition::FallbackContent: |
| 821 return HTMLImageFallbackHelper::customStyleForAltText( | 874 return HTMLImageFallbackHelper::customStyleForAltText( |
| 822 *this, ComputedStyle::clone(*originalStyleForLayoutObject())); | 875 *this, ComputedStyle::clone(*originalStyleForLayoutObject())); |
| 823 default: | 876 default: |
| 824 NOTREACHED(); | 877 NOTREACHED(); |
| 825 return nullptr; | 878 return nullptr; |
| 826 } | 879 } |
| 827 } | 880 } |
| 828 | 881 |
| 882 void HTMLImageElement::imageNotifyFinished(bool success) { | |
| 883 if (m_decodePromiseResolvers.isEmpty()) | |
| 884 return; | |
| 885 if (success) | |
| 886 requestDecode(); | |
| 887 else | |
| 888 didDecode(false); | |
| 889 } | |
| 890 | |
| 829 IntSize HTMLImageElement::bitmapSourceSize() const { | 891 IntSize HTMLImageElement::bitmapSourceSize() const { |
| 830 ImageResourceContent* image = cachedImage(); | 892 ImageResourceContent* image = cachedImage(); |
| 831 if (!image) | 893 if (!image) |
| 832 return IntSize(); | 894 return IntSize(); |
| 833 LayoutSize lSize = image->imageSize( | 895 LayoutSize lSize = image->imageSize( |
| 834 LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f); | 896 LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f); |
| 835 DCHECK(lSize.fraction().isZero()); | 897 DCHECK(lSize.fraction().isZero()); |
| 836 return IntSize(lSize.width().toInt(), lSize.height().toInt()); | 898 return IntSize(lSize.width().toInt(), lSize.height().toInt()); |
| 837 } | 899 } |
| 838 | 900 |
| 839 void HTMLImageElement::associateWith(HTMLFormElement* form) { | 901 void HTMLImageElement::associateWith(HTMLFormElement* form) { |
| 840 if (form && form->isConnected()) { | 902 if (form && form->isConnected()) { |
| 841 m_form = form; | 903 m_form = form; |
| 842 m_formWasSetByParser = true; | 904 m_formWasSetByParser = true; |
| 843 m_form->associate(*this); | 905 m_form->associate(*this); |
| 844 m_form->didAssociateByParser(); | 906 m_form->didAssociateByParser(); |
| 845 } | 907 } |
| 846 }; | 908 }; |
| 847 | 909 |
| 848 FloatSize HTMLImageElement::sourceDefaultObjectSize() { | 910 FloatSize HTMLImageElement::sourceDefaultObjectSize() { |
| 849 return FloatSize(width(), height()); | 911 return FloatSize(width(), height()); |
| 850 } | 912 } |
| 851 | 913 |
| 852 } // namespace blink | 914 } // namespace blink |
| OLD | NEW |