Lines 37-45
a/Source/WebCore/html/HTMLImageElement.cpp_sec1
|
37 |
#include "HTMLDocument.h" |
37 |
#include "HTMLDocument.h" |
38 |
#include "HTMLFormElement.h" |
38 |
#include "HTMLFormElement.h" |
39 |
#include "HTMLImageLoader.h" |
39 |
#include "HTMLImageLoader.h" |
|
|
40 |
#include "HTMLMapElement.h" |
40 |
#include "HTMLParserIdioms.h" |
41 |
#include "HTMLParserIdioms.h" |
41 |
#include "HTMLPictureElement.h" |
42 |
#include "HTMLPictureElement.h" |
42 |
#include "HTMLMapElement.h" |
|
|
43 |
#include "HTMLSourceElement.h" |
43 |
#include "HTMLSourceElement.h" |
44 |
#include "HTMLSrcsetParser.h" |
44 |
#include "HTMLSrcsetParser.h" |
45 |
#include "LazyLoadImageObserver.h" |
45 |
#include "LazyLoadImageObserver.h" |
Lines 117-126
void HTMLImageElement::collectPresentationalHintsForAttribute(const QualifiedNam
a/Source/WebCore/html/HTMLImageElement.cpp_sec2
|
117 |
{ |
117 |
{ |
118 |
if (name == widthAttr) { |
118 |
if (name == widthAttr) { |
119 |
addHTMLMultiLengthToStyle(style, CSSPropertyWidth, value); |
119 |
addHTMLMultiLengthToStyle(style, CSSPropertyWidth, value); |
120 |
applyAspectRatioFromWidthAndHeightAttributesToStyle(style); |
120 |
applyAspectRatioFromWidthAndHeightAttributesToStyle(value, attributeWithoutSynchronization(heightAttr), style); |
121 |
} else if (name == heightAttr) { |
121 |
} else if (name == heightAttr) { |
122 |
addHTMLMultiLengthToStyle(style, CSSPropertyHeight, value); |
122 |
addHTMLMultiLengthToStyle(style, CSSPropertyHeight, value); |
123 |
applyAspectRatioFromWidthAndHeightAttributesToStyle(style); |
123 |
applyAspectRatioFromWidthAndHeightAttributesToStyle(attributeWithoutSynchronization(widthAttr), value, style); |
124 |
} else if (name == borderAttr) |
124 |
} else if (name == borderAttr) |
125 |
applyBorderAttributeToStyle(value, style); |
125 |
applyBorderAttributeToStyle(value, style); |
126 |
else if (name == vspaceAttr) { |
126 |
else if (name == vspaceAttr) { |
Lines 137-142
void HTMLImageElement::collectPresentationalHintsForAttribute(const QualifiedNam
a/Source/WebCore/html/HTMLImageElement.cpp_sec3
|
137 |
HTMLElement::collectPresentationalHintsForAttribute(name, value, style); |
137 |
HTMLElement::collectPresentationalHintsForAttribute(name, value, style); |
138 |
} |
138 |
} |
139 |
|
139 |
|
|
|
140 |
void HTMLImageElement::collectExtraStyleForPresentationalHints(MutableStyleProperties& style) |
141 |
{ |
142 |
if (!sourceElement()) |
143 |
return; |
144 |
auto widthAttrFromSource = sourceElement()->attributeWithoutSynchronization(widthAttr); |
145 |
auto heightAttrFromSource = sourceElement()->attributeWithoutSynchronization(heightAttr); |
146 |
if (widthAttrFromSource.isNull() && heightAttrFromSource.isNull()) |
147 |
return; |
148 |
|
149 |
if (!widthAttrFromSource.isNull()) |
150 |
addHTMLLengthToStyle(style, CSSPropertyWidth, widthAttrFromSource); |
151 |
else |
152 |
addPropertyToPresentationalHintStyle(style, CSSPropertyWidth, CSSValueAuto); |
153 |
|
154 |
if (!heightAttrFromSource.isNull()) |
155 |
addHTMLLengthToStyle(style, CSSPropertyHeight, heightAttrFromSource); |
156 |
else |
157 |
addPropertyToPresentationalHintStyle(style, CSSPropertyHeight, CSSValueAuto); |
158 |
|
159 |
if (!widthAttrFromSource.isNull() && !heightAttrFromSource.isNull()) |
160 |
applyAspectRatioFromWidthAndHeightAttributesToStyle(widthAttrFromSource, heightAttrFromSource, style); |
161 |
else |
162 |
addPropertyToPresentationalHintStyle(style, CSSPropertyAspectRatio, CSSValueAuto); |
163 |
} |
164 |
|
140 |
const AtomString& HTMLImageElement::imageSourceURL() const |
165 |
const AtomString& HTMLImageElement::imageSourceURL() const |
141 |
{ |
166 |
{ |
142 |
return m_bestFitImageURL.isEmpty() ? attributeWithoutSynchronization(srcAttr) : m_bestFitImageURL; |
167 |
return m_bestFitImageURL.isEmpty() ? attributeWithoutSynchronization(srcAttr) : m_bestFitImageURL; |
Lines 191-198
ImageCandidate HTMLImageElement::bestFitSourceFromPictureElement()
a/Source/WebCore/html/HTMLImageElement.cpp_sec4
|
191 |
auto sourceSize = sizesParser.length(); |
216 |
auto sourceSize = sizesParser.length(); |
192 |
|
217 |
|
193 |
candidate = bestFitSourceForImageAttributes(document().deviceScaleFactor(), nullAtom(), srcset, sourceSize); |
218 |
candidate = bestFitSourceForImageAttributes(document().deviceScaleFactor(), nullAtom(), srcset, sourceSize); |
194 |
if (!candidate.isEmpty()) |
219 |
if (!candidate.isEmpty()) { |
|
|
220 |
setSourceElement(&source); |
195 |
break; |
221 |
break; |
|
|
222 |
} |
196 |
} |
223 |
} |
197 |
|
224 |
|
198 |
return candidate; |
225 |
return candidate; |
Lines 217-222
void HTMLImageElement::selectImageSource(RelevantMutation relevantMutation)
a/Source/WebCore/html/HTMLImageElement.cpp_sec5
|
217 |
// First look for the best fit source from our <picture> parent if we have one. |
244 |
// First look for the best fit source from our <picture> parent if we have one. |
218 |
ImageCandidate candidate = bestFitSourceFromPictureElement(); |
245 |
ImageCandidate candidate = bestFitSourceFromPictureElement(); |
219 |
if (candidate.isEmpty()) { |
246 |
if (candidate.isEmpty()) { |
|
|
247 |
setSourceElement(nullptr); |
220 |
// If we don't have a <picture> or didn't find a source, then we use our own attributes. |
248 |
// If we don't have a <picture> or didn't find a source, then we use our own attributes. |
221 |
SizesAttributeParser sizesParser(attributeWithoutSynchronization(sizesAttr).string(), document(), &m_mediaQueryDynamicResults); |
249 |
SizesAttributeParser sizesParser(attributeWithoutSynchronization(sizesAttr).string(), document(), &m_mediaQueryDynamicResults); |
222 |
auto sourceSize = sizesParser.length(); |
250 |
auto sourceSize = sizesParser.length(); |
Lines 799-802
ReferrerPolicy HTMLImageElement::referrerPolicy() const
a/Source/WebCore/html/HTMLImageElement.cpp_sec6
|
799 |
return ReferrerPolicy::EmptyString; |
827 |
return ReferrerPolicy::EmptyString; |
800 |
} |
828 |
} |
801 |
|
829 |
|
|
|
830 |
HTMLSourceElement* HTMLImageElement::sourceElement() const |
831 |
{ |
832 |
return m_sourceElement.get(); |
833 |
} |
834 |
|
835 |
void HTMLImageElement::setSourceElement(HTMLSourceElement* sourceElement) |
836 |
{ |
837 |
if (m_sourceElement.get() == sourceElement) |
838 |
return; |
839 |
m_sourceElement = makeWeakPtr(sourceElement); |
840 |
invalidateAttributeMapping(); |
841 |
} |
842 |
|
843 |
void HTMLImageElement::invalidateAttributeMapping() |
844 |
{ |
845 |
ensureUniqueElementData().setPresentationalHintStyleIsDirty(true); |
846 |
invalidateStyle(); |
847 |
} |
848 |
|
802 |
} |
849 |
} |