| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 document().devicePixelRatio(), sourceSize(*source), | 326 document().devicePixelRatio(), sourceSize(*source), |
| 327 source->fastGetAttribute(srcsetAttr), &document()); | 327 source->fastGetAttribute(srcsetAttr), &document()); |
| 328 if (candidate.isEmpty()) | 328 if (candidate.isEmpty()) |
| 329 continue; | 329 continue; |
| 330 m_source = source; | 330 m_source = source; |
| 331 return candidate; | 331 return candidate; |
| 332 } | 332 } |
| 333 return ImageCandidate(); | 333 return ImageCandidate(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 bool HTMLImageElement::layoutObjectIsNeeded(const ComputedStyle& style) { | |
| 337 return m_layoutDisposition != LayoutDisposition::Collapsed && | |
| 338 HTMLElement::layoutObjectIsNeeded(style); | |
| 339 } | |
| 340 | |
| 341 LayoutObject* HTMLImageElement::createLayoutObject(const ComputedStyle& style) { | 336 LayoutObject* HTMLImageElement::createLayoutObject(const ComputedStyle& style) { |
| 342 const ContentData* contentData = style.contentData(); | 337 const ContentData* contentData = style.contentData(); |
| 343 if (contentData && contentData->isImage()) { | 338 if (contentData && contentData->isImage()) { |
| 344 const StyleImage* contentImage = toImageContentData(contentData)->image(); | 339 const StyleImage* contentImage = toImageContentData(contentData)->image(); |
| 345 bool errorOccurred = contentImage && contentImage->cachedImage() && | 340 bool errorOccurred = contentImage && contentImage->cachedImage() && |
| 346 contentImage->cachedImage()->errorOccurred(); | 341 contentImage->cachedImage()->errorOccurred(); |
| 347 if (!errorOccurred) | 342 if (!errorOccurred) |
| 348 return LayoutObject::createObject(this, style); | 343 return LayoutObject::createObject(this, style); |
| 349 } | 344 } |
| 350 | 345 |
| 351 switch (m_layoutDisposition) { | 346 switch (m_layoutDisposition) { |
| 352 case LayoutDisposition::FallbackContent: | 347 case LayoutDisposition::FallbackContent: |
| 353 return new LayoutBlockFlow(this); | 348 return new LayoutBlockFlow(this); |
| 354 case LayoutDisposition::PrimaryContent: { | 349 case LayoutDisposition::PrimaryContent: { |
| 355 LayoutImage* image = new LayoutImage(this); | 350 LayoutImage* image = new LayoutImage(this); |
| 356 image->setImageResource(LayoutImageResource::create()); | 351 image->setImageResource(LayoutImageResource::create()); |
| 357 image->setImageDevicePixelRatio(m_imageDevicePixelRatio); | 352 image->setImageDevicePixelRatio(m_imageDevicePixelRatio); |
| 358 return image; | 353 return image; |
| 359 } | 354 } |
| 360 case LayoutDisposition::Collapsed: // Falls through. | 355 case LayoutDisposition::Collapsed: // Falls through. |
| 361 default: | 356 default: |
| 362 NOTREACHED(); | 357 NOTREACHED(); |
| 363 return nullptr; | 358 return nullptr; |
| 364 } | 359 } |
| 365 } | 360 } |
| 366 | 361 |
| 367 void HTMLImageElement::attachLayoutTree(const AttachContext& context) { | 362 void HTMLImageElement::attachLayoutTree(const AttachContext& context) { |
| 368 HTMLElement::attachLayoutTree(context); | 363 HTMLElement::attachLayoutTree(context); |
| 369 | |
| 370 if (layoutObject() && layoutObject()->isImage()) { | 364 if (layoutObject() && layoutObject()->isImage()) { |
| 371 LayoutImage* layoutImage = toLayoutImage(layoutObject()); | 365 LayoutImage* layoutImage = toLayoutImage(layoutObject()); |
| 372 LayoutImageResource* layoutImageResource = layoutImage->imageResource(); | 366 LayoutImageResource* layoutImageResource = layoutImage->imageResource(); |
| 373 if (m_isFallbackImage) { | 367 if (m_isFallbackImage) { |
| 374 float deviceScaleFactor = blink::deviceScaleFactor(layoutImage->frame()); | 368 float deviceScaleFactor = blink::deviceScaleFactor(layoutImage->frame()); |
| 375 std::pair<Image*, float> brokenImageAndImageScaleFactor = | 369 std::pair<Image*, float> brokenImageAndImageScaleFactor = |
| 376 ImageResourceContent::brokenImage(deviceScaleFactor); | 370 ImageResourceContent::brokenImage(deviceScaleFactor); |
| 377 ImageResourceContent* newImageResource = | 371 ImageResourceContent* newImageResource = |
| 378 ImageResourceContent::create(brokenImageAndImageScaleFactor.first); | 372 ImageResourceContent::create(brokenImageAndImageScaleFactor.first); |
| 379 layoutImage->imageResource()->setImageResource(newImageResource); | 373 layoutImage->imageResource()->setImageResource(newImageResource); |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 imageLoader().image()->resourceError().shouldCollapseInitiator(); | 839 imageLoader().image()->resourceError().shouldCollapseInitiator(); |
| 846 setLayoutDisposition(resourceErrorIndicatesElementShouldBeCollapsed | 840 setLayoutDisposition(resourceErrorIndicatesElementShouldBeCollapsed |
| 847 ? LayoutDisposition::Collapsed | 841 ? LayoutDisposition::Collapsed |
| 848 : LayoutDisposition::FallbackContent); | 842 : LayoutDisposition::FallbackContent); |
| 849 } | 843 } |
| 850 | 844 |
| 851 void HTMLImageElement::ensurePrimaryContent() { | 845 void HTMLImageElement::ensurePrimaryContent() { |
| 852 setLayoutDisposition(LayoutDisposition::PrimaryContent); | 846 setLayoutDisposition(LayoutDisposition::PrimaryContent); |
| 853 } | 847 } |
| 854 | 848 |
| 849 bool HTMLImageElement::isCollapsed() const { |
| 850 return m_layoutDisposition == LayoutDisposition::Collapsed; |
| 851 } |
| 852 |
| 855 void HTMLImageElement::setLayoutDisposition(LayoutDisposition layoutDisposition, | 853 void HTMLImageElement::setLayoutDisposition(LayoutDisposition layoutDisposition, |
| 856 bool forceReattach) { | 854 bool forceReattach) { |
| 857 if (m_layoutDisposition == layoutDisposition && !forceReattach) | 855 if (m_layoutDisposition == layoutDisposition && !forceReattach) |
| 858 return; | 856 return; |
| 859 | 857 |
| 860 m_layoutDisposition = layoutDisposition; | 858 m_layoutDisposition = layoutDisposition; |
| 861 | 859 |
| 862 // This can happen inside of attachLayoutTree() in the middle of a recalcStyle | 860 // This can happen inside of attachLayoutTree() in the middle of a recalcStyle |
| 863 // so we need to reattach synchronously here. | 861 // so we need to reattach synchronously here. |
| 864 if (document().inStyleRecalc()) { | 862 if (document().inStyleRecalc()) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 void HTMLImageElement::associateWith(HTMLFormElement* form) { | 918 void HTMLImageElement::associateWith(HTMLFormElement* form) { |
| 921 if (form && form->isConnected()) { | 919 if (form && form->isConnected()) { |
| 922 m_form = form; | 920 m_form = form; |
| 923 m_formWasSetByParser = true; | 921 m_formWasSetByParser = true; |
| 924 m_form->associate(*this); | 922 m_form->associate(*this); |
| 925 m_form->didAssociateByParser(); | 923 m_form->didAssociateByParser(); |
| 926 } | 924 } |
| 927 }; | 925 }; |
| 928 | 926 |
| 929 } // namespace blink | 927 } // namespace blink |
| OLD | NEW |