|
Lines 55-60
a/Source/WebCore/html/HTMLImageElement.cpp_sec1
|
| 55 |
#include "Settings.h" |
55 |
#include "Settings.h" |
| 56 |
#include "ShadowRoot.h" |
56 |
#include "ShadowRoot.h" |
| 57 |
#include "SizesAttributeParser.h" |
57 |
#include "SizesAttributeParser.h" |
|
|
58 |
#include "StyleProperties.h" |
| 58 |
#include <wtf/IsoMallocInlines.h> |
59 |
#include <wtf/IsoMallocInlines.h> |
| 59 |
#include <wtf/text/StringBuilder.h> |
60 |
#include <wtf/text/StringBuilder.h> |
| 60 |
|
61 |
|
|
Lines 68-74
WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLImageElement);
a/Source/WebCore/html/HTMLImageElement.cpp_sec2
|
| 68 |
|
69 |
|
| 69 |
using namespace HTMLNames; |
70 |
using namespace HTMLNames; |
| 70 |
|
71 |
|
| 71 |
HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form) |
72 |
HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form, bool createdByParser) |
| 72 |
: HTMLElement(tagName, document) |
73 |
: HTMLElement(tagName, document) |
| 73 |
, m_imageLoader(*this) |
74 |
, m_imageLoader(*this) |
| 74 |
, m_form(nullptr) |
75 |
, m_form(nullptr) |
|
Lines 76-81
HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& docum
a/Source/WebCore/html/HTMLImageElement.cpp_sec3
|
| 76 |
, m_compositeOperator(CompositeSourceOver) |
77 |
, m_compositeOperator(CompositeSourceOver) |
| 77 |
, m_imageDevicePixelRatio(1.0f) |
78 |
, m_imageDevicePixelRatio(1.0f) |
| 78 |
, m_experimentalImageMenuEnabled(false) |
79 |
, m_experimentalImageMenuEnabled(false) |
|
|
80 |
, m_createdByParser(createdByParser) |
| 79 |
{ |
81 |
{ |
| 80 |
ASSERT(hasTagName(imgTag)); |
82 |
ASSERT(hasTagName(imgTag)); |
| 81 |
setHasCustomStyleResolveCallbacks(); |
83 |
setHasCustomStyleResolveCallbacks(); |
|
Lines 83-94
HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& docum
a/Source/WebCore/html/HTMLImageElement.cpp_sec4
|
| 83 |
|
85 |
|
| 84 |
Ref<HTMLImageElement> HTMLImageElement::create(Document& document) |
86 |
Ref<HTMLImageElement> HTMLImageElement::create(Document& document) |
| 85 |
{ |
87 |
{ |
| 86 |
return adoptRef(*new HTMLImageElement(imgTag, document)); |
88 |
return adoptRef(*new HTMLImageElement(imgTag, document, nullptr, false)); |
| 87 |
} |
89 |
} |
| 88 |
|
90 |
|
| 89 |
Ref<HTMLImageElement> HTMLImageElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form) |
91 |
Ref<HTMLImageElement> HTMLImageElement::create(const QualifiedName& tagName, Document& document, HTMLFormElement* form, bool createdByParser) |
| 90 |
{ |
92 |
{ |
| 91 |
return adoptRef(*new HTMLImageElement(tagName, document, form)); |
93 |
return adoptRef(*new HTMLImageElement(tagName, document, form, createdByParser)); |
| 92 |
} |
94 |
} |
| 93 |
|
95 |
|
| 94 |
HTMLImageElement::~HTMLImageElement() |
96 |
HTMLImageElement::~HTMLImageElement() |
|
Lines 100-106
HTMLImageElement::~HTMLImageElement()
a/Source/WebCore/html/HTMLImageElement.cpp_sec5
|
| 100 |
|
102 |
|
| 101 |
Ref<HTMLImageElement> HTMLImageElement::createForJSConstructor(Document& document, Optional<unsigned> width, Optional<unsigned> height) |
103 |
Ref<HTMLImageElement> HTMLImageElement::createForJSConstructor(Document& document, Optional<unsigned> width, Optional<unsigned> height) |
| 102 |
{ |
104 |
{ |
| 103 |
auto image = adoptRef(*new HTMLImageElement(imgTag, document)); |
105 |
auto image = adoptRef(*new HTMLImageElement(imgTag, document, nullptr, false)); |
| 104 |
if (width) |
106 |
if (width) |
| 105 |
image->setWidth(width.value()); |
107 |
image->setWidth(width.value()); |
| 106 |
if (height) |
108 |
if (height) |
|
Lines 240-248
void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
a/Source/WebCore/html/HTMLImageElement.cpp_sec6
|
| 240 |
m_experimentalImageMenuEnabled = !value.isNull(); |
242 |
m_experimentalImageMenuEnabled = !value.isNull(); |
| 241 |
updateImageControls(); |
243 |
updateImageControls(); |
| 242 |
#endif |
244 |
#endif |
| 243 |
} else if (name == x_apple_editable_imageAttr) |
245 |
} else if (name == x_apple_editable_imageAttr) { |
| 244 |
updateEditableImage(); |
246 |
updateEditableImage(); |
| 245 |
else { |
247 |
} else if (name == loadingAttr && equalLettersIgnoringASCIICase(value, "eager")) { |
|
|
248 |
// !GetDocument().IsLazyLoadPolicyEnforced()) { |
| 249 |
loadDeferredImage(); |
| 250 |
} else { |
| 246 |
if (name == nameAttr) { |
251 |
if (name == nameAttr) { |
| 247 |
bool willHaveName = !value.isNull(); |
252 |
bool willHaveName = !value.isNull(); |
| 248 |
if (m_hadNameBeforeAttributeChanged != willHaveName && isConnected() && !isInShadowTree() && is<HTMLDocument>(document())) { |
253 |
if (m_hadNameBeforeAttributeChanged != willHaveName && isConnected() && !isInShadowTree() && is<HTMLDocument>(document())) { |
|
Lines 834-837
void HTMLImageElement::defaultEventHandler(Event& event)
a/Source/WebCore/html/HTMLImageElement.cpp_sec7
|
| 834 |
HTMLElement::defaultEventHandler(event); |
839 |
HTMLElement::defaultEventHandler(event); |
| 835 |
} |
840 |
} |
| 836 |
|
841 |
|
|
|
842 |
void HTMLImageElement::loadDeferredImage() |
| 843 |
{ |
| 844 |
m_imageLoader.loadDeferredImage(); |
| 845 |
} |
| 846 |
|
| 847 |
// Minimum height or width of the image to start lazyloading. |
| 848 |
constexpr int kMinDimensionToLazyLoad = 10; |
| 849 |
|
| 850 |
bool HTMLImageElement::isDimensionSmallAndAbsoluteForLazyLoad(const AtomicString& attributeValue) |
| 851 |
{ |
| 852 |
auto optionalDimension = parseValidHTMLNonNegativeInteger(attributeValue); |
| 853 |
return optionalDimension && optionalDimension.value() <= kMinDimensionToLazyLoad; |
| 854 |
} |
| 855 |
|
| 856 |
bool HTMLImageElement::isInlineStyleDimensionsSmall(const StyleProperties* propertySet) |
| 857 |
{ |
| 858 |
if (!propertySet) |
| 859 |
return false; |
| 860 |
auto height = propertySet->getPropertyCSSValue(CSSPropertyHeight); |
| 861 |
auto width = propertySet->getPropertyCSSValue(CSSPropertyWidth); |
| 862 |
if (!height || !height->isPrimitiveValue() || !width || !width->isPrimitiveValue()) |
| 863 |
return false; |
| 864 |
const auto& widthPrim = downcast<CSSPrimitiveValue>(*width); |
| 865 |
const auto& heightPrim = downcast<CSSPrimitiveValue>(*height); |
| 866 |
return heightPrim.isPx() && (heightPrim.doubleValue() <= kMinDimensionToLazyLoad) |
| 867 |
&& widthPrim.isPx() && (widthPrim.doubleValue() <= kMinDimensionToLazyLoad); |
| 868 |
} |
| 869 |
|
| 837 |
} |
870 |
} |