Changeset 195401 in webkit
- Timestamp:
- Jan 20, 2016, 11:16:57 PM (11 years ago)
- Location:
- branches/safari-601.1.46-branch/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
html/HTMLImageElement.cpp (modified) (6 diffs)
-
html/HTMLImageElement.h (modified) (2 diffs)
-
html/HTMLPictureElement.h (modified) (1 diff)
-
html/parser/HTMLConstructionSite.cpp (modified) (2 diffs)
-
html/parser/HTMLPreloadScanner.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-601.1.46-branch/Source/WebCore/ChangeLog
r195400 r195401 1 2016-01-20 Babak Shafiei <bshafiei@apple.com> 2 3 Merge r195132. 4 5 2016-01-15 Dave Hyatt <hyatt@apple.com> 6 7 Avoid downloading the wrong image for <picture> elements. 8 https://bugs.webkit.org/show_bug.cgi?id=153027 9 10 Reviewed by Dean Jackson. 11 12 No tests, since they are always flaky. 13 14 * html/HTMLImageElement.cpp: 15 (WebCore::HTMLImageElement::HTMLImageElement): 16 (WebCore::HTMLImageElement::~HTMLImageElement): 17 (WebCore::HTMLImageElement::createForJSConstructor): 18 (WebCore::HTMLImageElement::bestFitSourceFromPictureElement): 19 (WebCore::HTMLImageElement::insertedInto): 20 (WebCore::HTMLImageElement::removedFrom): 21 (WebCore::HTMLImageElement::pictureElement): 22 (WebCore::HTMLImageElement::setPictureElement): 23 (WebCore::HTMLImageElement::width): 24 * html/HTMLImageElement.h: 25 (WebCore::HTMLImageElement::hasShadowControls): 26 * html/HTMLPictureElement.h: 27 * html/parser/HTMLConstructionSite.cpp: 28 (WebCore::HTMLConstructionSite::createHTMLElement): 29 * html/parser/HTMLPreloadScanner.cpp: 30 (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): 31 32 Images that are built underneath a <picture> element are now connected 33 to that picture element via a setPictureNode call from the parser. This 34 ensures that the correct <source> elements are examined before checking the image. 35 36 This connection between images and their picture owners is handled using a static 37 HashMap in HTMLImageElement. This connection is made both from the parser and from 38 DOM insertions, and the map is queried now instead of looking directly at the 39 image's parentNode(). 40 1 41 2016-01-20 Babak Shafiei <bshafiei@apple.com> 2 42 -
branches/safari-601.1.46-branch/Source/WebCore/html/HTMLImageElement.cpp
r193952 r195401 54 54 using namespace HTMLNames; 55 55 56 typedef HashMap<const HTMLImageElement*, WeakPtr<HTMLPictureElement>> PictureOwnerMap; 57 static PictureOwnerMap* gPictureOwnerMap = nullptr; 58 56 59 HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form) 57 60 : HTMLElement(tagName, document) … … 84 87 if (m_form) 85 88 m_form->removeImgElement(this); 89 setPictureElement(nullptr); 86 90 } 87 91 … … 144 148 ImageCandidate HTMLImageElement::bestFitSourceFromPictureElement() 145 149 { 146 auto* p arent = parentNode();147 if (! is<HTMLPictureElement>(parent))150 auto* picture = pictureElement(); 151 if (!picture) 148 152 return { }; 149 auto* picture = downcast<HTMLPictureElement>(parent);150 153 picture->clearViewportDependentResults(); 151 154 document().removeViewportDependentPicture(*picture); 152 for (Node* child = p arent->firstChild(); child && child != this; child = child->nextSibling()) {155 for (Node* child = picture->firstChild(); child && child != this; child = child->nextSibling()) { 153 156 if (!is<HTMLSourceElement>(*child)) 154 157 continue; … … 167 170 continue; 168 171 } 169 MediaQueryEvaluator evaluator(document().printing() ? "print" : "screen", document().frame(), computedStyle());172 MediaQueryEvaluator evaluator(document().printing() ? "print" : "screen", document().frame(), document().documentElement() ? document().documentElement()->computedStyle() : nullptr); 170 173 bool evaluation = evaluator.evalCheckingViewportDependentResults(source.mediaQuerySet(), picture->viewportDependentResults()); 171 174 if (picture->hasViewportDependentResults()) … … 312 315 document().addImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this); 313 316 314 if (is<HTMLPictureElement>(parentNode())) 317 if (is<HTMLPictureElement>(parentNode())) { 318 setPictureElement(&downcast<HTMLPictureElement>(*parentNode())); 315 319 selectImageSource(); 316 320 } 321 317 322 // If we have been inserted from a renderer-less document, 318 323 // our loader may have not fetched the image, so do it now. … … 330 335 if (insertionPoint.inDocument() && !m_lowercasedUsemap.isNull()) 331 336 document().removeImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this); 332 337 338 if (is<HTMLPictureElement>(parentNode())) 339 setPictureElement(nullptr); 340 333 341 m_form = 0; 334 342 HTMLElement::removedFrom(insertionPoint); 335 343 } 336 344 345 HTMLPictureElement* HTMLImageElement::pictureElement() const 346 { 347 if (!gPictureOwnerMap || !gPictureOwnerMap->contains(this)) 348 return nullptr; 349 HTMLPictureElement* result = gPictureOwnerMap->get(this).get(); 350 if (!result) 351 gPictureOwnerMap->remove(this); 352 return result; 353 } 354 355 void HTMLImageElement::setPictureElement(HTMLPictureElement* pictureElement) 356 { 357 if (!pictureElement) { 358 if (gPictureOwnerMap) 359 gPictureOwnerMap->remove(this); 360 return; 361 } 362 363 if (!gPictureOwnerMap) 364 gPictureOwnerMap = new PictureOwnerMap(); 365 gPictureOwnerMap->add(this, pictureElement->createWeakPtr()); 366 } 367 337 368 int HTMLImageElement::width(bool ignorePendingStylesheets) 338 369 { -
branches/safari-601.1.46-branch/Source/WebCore/html/HTMLImageElement.h
r193565 r195401 90 90 91 91 bool hasShadowControls() const { return m_experimentalImageMenuEnabled; } 92 93 HTMLPictureElement* pictureElement() const; 94 void setPictureElement(HTMLPictureElement*); 92 95 93 96 protected: … … 129 132 HTMLImageLoader m_imageLoader; 130 133 HTMLFormElement* m_form; 134 131 135 CompositeOperator m_compositeOperator; 132 136 AtomicString m_bestFitImageURL; -
branches/safari-601.1.46-branch/Source/WebCore/html/HTMLPictureElement.h
r193952 r195401 47 47 bool viewportChangeAffectedPicture(); 48 48 49 WeakPtr<HTMLPictureElement> createWeakPtr() { return m_weakFactory.createWeakPtr(); } 50 49 51 private: 50 52 HTMLPictureElement(const QualifiedName&, Document&); 51 53 54 WeakPtrFactory<HTMLPictureElement> m_weakFactory { this }; 52 55 Vector<std::unique_ptr<MediaQueryResult>> m_viewportDependentMediaQueryResults; 53 56 -
branches/safari-601.1.46-branch/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r177952 r195401 37 37 #include "HTMLFormElement.h" 38 38 #include "HTMLHtmlElement.h" 39 #include "HTMLImageElement.h" 39 40 #include "HTMLOptGroupElement.h" 40 41 #include "HTMLOptionElement.h" 41 42 #include "HTMLParserIdioms.h" 43 #include "HTMLPictureElement.h" 42 44 #include "HTMLScriptElement.h" 43 45 #include "HTMLTemplateElement.h" … … 642 644 bool insideTemplateElement = !ownerDocument.frame(); 643 645 RefPtr<Element> element = HTMLElementFactory::createElement(tagName, ownerDocument, insideTemplateElement ? nullptr : form(), true); 646 647 // FIXME: This is a hack to connect images to pictures before the image has 648 // been inserted into the document. It can be removed once asynchronous image 649 // loading is working. 650 if (is<HTMLPictureElement>(currentNode()) && is<HTMLImageElement>(*element.get())) 651 downcast<HTMLImageElement>(*element.get()).setPictureElement(&downcast<HTMLPictureElement>(currentNode())); 652 644 653 setAttributes(element.get(), token, m_parserContentPolicy); 645 654 ASSERT(element->isHTMLElement()); -
branches/safari-601.1.46-branch/Source/WebCore/html/parser/HTMLPreloadScanner.cpp
r194992 r195401 209 209 Ref<MediaQuerySet> mediaSet = MediaQuerySet::createAllowingDescriptionSyntax(attributeValue); 210 210 Vector<std::unique_ptr<MediaQueryResult>> viewportDependentMediaQueryResults; 211 MediaQueryEvaluator evaluator(document.printing() ? "print" : "screen", document.frame(), document.documentElement() ->computedStyle());211 MediaQueryEvaluator evaluator(document.printing() ? "print" : "screen", document.frame(), document.documentElement() ? document.documentElement()->computedStyle() : nullptr); 212 212 m_mediaMatched = evaluator.evalCheckingViewportDependentResults(mediaSet.ptr(), viewportDependentMediaQueryResults); 213 213 }
Note:
See TracChangeset
for help on using the changeset viewer.