Changeset 195064 in webkit
- Timestamp:
- Jan 14, 2016 11:13:26 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r195060 r195064 1 2016-01-14 Dave Hyatt <hyatt@apple.com> 2 3 Avoid downloading the wrong image for <picture> elements. 4 https://bugs.webkit.org/show_bug.cgi?id=153027 5 6 Reviewed by Dean Jackson. 7 8 * fast/picture/image-picture-loads-1x-expected.txt: Added. 9 * fast/picture/image-picture-loads-1x.html: Added. 10 1 11 2016-01-14 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 12 -
trunk/LayoutTests/platform/ios-simulator/TestExpectations
r194937 r195064 2840 2840 webkit.org/b/152141 fast/picture/image-picture-invalid.html [ Skip ] 2841 2841 webkit.org/b/152141 fast/picture/image-picture-nested.html [ Skip ] 2842 webkit.org/b/153043 fast/picture/image-picture-loads-1x.html [ Skip ]2843 2842 webkit.org/b/152992 http/tests/loading/preload-picture-invalid.html [ Skip ] 2844 2843 webkit.org/b/152992 http/tests/loading/preload-picture-nested.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r195059 r195064 1 2016-01-14 Dave Hyatt <hyatt@apple.com> 2 3 Avoid downloading the wrong image for <picture> elements. 4 https://bugs.webkit.org/show_bug.cgi?id=153027 5 6 Reviewed by Dean Jackson. 7 8 Added test in fast/picture. 9 10 * html/HTMLImageElement.cpp: 11 (WebCore::HTMLImageElement::HTMLImageElement): 12 (WebCore::HTMLImageElement::~HTMLImageElement): 13 (WebCore::HTMLImageElement::createForJSConstructor): 14 (WebCore::HTMLImageElement::bestFitSourceFromPictureElement): 15 (WebCore::HTMLImageElement::insertedInto): 16 (WebCore::HTMLImageElement::removedFrom): 17 (WebCore::HTMLImageElement::pictureElement): 18 (WebCore::HTMLImageElement::setPictureElement): 19 (WebCore::HTMLImageElement::width): 20 * html/HTMLImageElement.h: 21 (WebCore::HTMLImageElement::hasShadowControls): 22 * html/HTMLPictureElement.h: 23 * html/parser/HTMLConstructionSite.cpp: 24 (WebCore::HTMLConstructionSite::createHTMLElement): 25 * html/parser/HTMLPreloadScanner.cpp: 26 (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): 27 28 Images that are built underneath a <picture> element are now connected 29 to that picture element via a setPictureNode call from the parser. This 30 ensures that the correct <source> elements are examined before checking the image. 31 32 This connection between images and their picture owners is handled using a static 33 HashMap in HTMLImageElement. This connection is made both from the parser and from 34 DOM insertions, and the map is queried now instead of looking directly at the 35 image's parentNode(). 36 1 37 2016-01-14 Commit Queue <commit-queue@webkit.org> 2 38 -
trunk/Source/WebCore/html/HTMLImageElement.cpp
r194934 r195064 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) … … 83 86 if (m_form) 84 87 m_form->removeImgElement(this); 88 setPictureElement(nullptr); 85 89 } 86 90 … … 141 145 ImageCandidate HTMLImageElement::bestFitSourceFromPictureElement() 142 146 { 143 auto* p arent = parentNode();144 if (! is<HTMLPictureElement>(parent))147 auto* picture = pictureElement(); 148 if (!picture) 145 149 return { }; 146 auto* picture = downcast<HTMLPictureElement>(parent);147 150 picture->clearViewportDependentResults(); 148 151 document().removeViewportDependentPicture(*picture); 149 for (Node* child = p arent->firstChild(); child && child != this; child = child->nextSibling()) {152 for (Node* child = picture->firstChild(); child && child != this; child = child->nextSibling()) { 150 153 if (!is<HTMLSourceElement>(*child)) 151 154 continue; … … 164 167 continue; 165 168 } 166 MediaQueryEvaluator evaluator(document().printing() ? "print" : "screen", document().frame(), computedStyle());169 MediaQueryEvaluator evaluator(document().printing() ? "print" : "screen", document().frame(), document().documentElement() ? document().documentElement()->computedStyle() : nullptr); 167 170 bool evaluation = evaluator.evalCheckingViewportDependentResults(source.mediaQuerySet(), picture->viewportDependentResults()); 168 171 if (picture->hasViewportDependentResults()) … … 314 317 document().addImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this); 315 318 316 if (is<HTMLPictureElement>(parentNode())) 319 if (is<HTMLPictureElement>(parentNode())) { 320 setPictureElement(&downcast<HTMLPictureElement>(*parentNode())); 317 321 selectImageSource(); 322 } 318 323 319 324 // If we have been inserted from a renderer-less document, … … 332 337 if (insertionPoint.inDocument() && !m_lowercasedUsemap.isNull()) 333 338 document().removeImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this); 334 339 340 if (is<HTMLPictureElement>(parentNode())) 341 setPictureElement(nullptr); 342 335 343 m_form = nullptr; 336 344 HTMLElement::removedFrom(insertionPoint); 337 345 } 338 346 347 HTMLPictureElement* HTMLImageElement::pictureElement() const 348 { 349 if (!gPictureOwnerMap || !gPictureOwnerMap->contains(this)) 350 return nullptr; 351 HTMLPictureElement* result = gPictureOwnerMap->get(this).get(); 352 if (!result) 353 gPictureOwnerMap->remove(this); 354 return result; 355 } 356 357 void HTMLImageElement::setPictureElement(HTMLPictureElement* pictureElement) 358 { 359 if (!pictureElement) { 360 if (gPictureOwnerMap) 361 gPictureOwnerMap->remove(this); 362 return; 363 } 364 365 if (!gPictureOwnerMap) 366 gPictureOwnerMap = new PictureOwnerMap(); 367 gPictureOwnerMap->add(this, pictureElement->createWeakPtr()); 368 } 369 339 370 int HTMLImageElement::width(bool ignorePendingStylesheets) 340 371 { -
trunk/Source/WebCore/html/HTMLImageElement.h
r194934 r195064 88 88 89 89 bool hasShadowControls() const { return m_experimentalImageMenuEnabled; } 90 91 HTMLPictureElement* pictureElement() const; 92 void setPictureElement(HTMLPictureElement*); 90 93 91 94 protected: … … 128 131 HTMLFormElement* m_form; 129 132 HTMLFormElement* m_formSetByParser; 133 130 134 CompositeOperator m_compositeOperator; 131 135 AtomicString m_bestFitImageURL; -
trunk/Source/WebCore/html/HTMLPictureElement.h
r193859 r195064 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 -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r194934 r195064 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" … … 641 643 bool insideTemplateElement = !ownerDocument.frame(); 642 644 RefPtr<Element> element = HTMLElementFactory::createElement(tagName, ownerDocument, insideTemplateElement ? nullptr : form(), true); 645 646 // FIXME: This is a hack to connect images to pictures before the image has 647 // been inserted into the document. It can be removed once asynchronous image 648 // loading is working. 649 if (is<HTMLPictureElement>(currentNode()) && is<HTMLImageElement>(*element.get())) 650 downcast<HTMLImageElement>(*element.get()).setPictureElement(&downcast<HTMLPictureElement>(currentNode())); 651 643 652 setAttributes(element.get(), token, m_parserContentPolicy); 644 653 ASSERT(element->isHTMLElement()); -
trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp
r194865 r195064 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.