Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLImageElement.cpp

Issue 2256533002: Remove MediaQueryList listener from removed HTMLSourceElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 reserv ed. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed.
5 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 22 matching lines...) Expand all
33 #include "core/dom/NodeTraversal.h" 33 #include "core/dom/NodeTraversal.h"
34 #include "core/dom/shadow/ShadowRoot.h" 34 #include "core/dom/shadow/ShadowRoot.h"
35 #include "core/fetch/ImageResource.h" 35 #include "core/fetch/ImageResource.h"
36 #include "core/frame/Deprecation.h" 36 #include "core/frame/Deprecation.h"
37 #include "core/frame/ImageBitmap.h" 37 #include "core/frame/ImageBitmap.h"
38 #include "core/frame/LocalDOMWindow.h" 38 #include "core/frame/LocalDOMWindow.h"
39 #include "core/html/HTMLAnchorElement.h" 39 #include "core/html/HTMLAnchorElement.h"
40 #include "core/html/HTMLCanvasElement.h" 40 #include "core/html/HTMLCanvasElement.h"
41 #include "core/html/HTMLFormElement.h" 41 #include "core/html/HTMLFormElement.h"
42 #include "core/html/HTMLImageFallbackHelper.h" 42 #include "core/html/HTMLImageFallbackHelper.h"
43 #include "core/html/HTMLPictureElement.h"
43 #include "core/html/HTMLSourceElement.h" 44 #include "core/html/HTMLSourceElement.h"
44 #include "core/html/parser/HTMLParserIdioms.h" 45 #include "core/html/parser/HTMLParserIdioms.h"
45 #include "core/html/parser/HTMLSrcsetParser.h" 46 #include "core/html/parser/HTMLSrcsetParser.h"
46 #include "core/imagebitmap/ImageBitmapOptions.h" 47 #include "core/imagebitmap/ImageBitmapOptions.h"
47 #include "core/inspector/ConsoleMessage.h" 48 #include "core/inspector/ConsoleMessage.h"
48 #include "core/layout/LayoutBlockFlow.h" 49 #include "core/layout/LayoutBlockFlow.h"
49 #include "core/layout/LayoutImage.h" 50 #include "core/layout/LayoutImage.h"
50 #include "core/layout/api/LayoutImageItem.h" 51 #include "core/layout/api/LayoutImageItem.h"
51 #include "core/page/Page.h" 52 #include "core/page/Page.h"
52 #include "core/style/ContentData.h" 53 #include "core/style/ContentData.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 layoutImageResource->setImageResource(imageLoader().image()); 371 layoutImageResource->setImageResource(imageLoader().image());
371 } 372 }
372 } 373 }
373 374
374 Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode* insertionPoint) 375 Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode* insertionPoint)
375 { 376 {
376 if (!m_formWasSetByParser || NodeTraversal::highestAncestorOrSelf(*insertion Point) != NodeTraversal::highestAncestorOrSelf(*m_form.get())) 377 if (!m_formWasSetByParser || NodeTraversal::highestAncestorOrSelf(*insertion Point) != NodeTraversal::highestAncestorOrSelf(*m_form.get()))
377 resetFormOwner(); 378 resetFormOwner();
378 if (m_listener) 379 if (m_listener)
379 document().mediaQueryMatcher().addViewportListener(m_listener); 380 document().mediaQueryMatcher().addViewportListener(m_listener);
381 Node* parent = parentNode();
382 if (parent && isHTMLPictureElement(*parent))
383 toHTMLPictureElement(parent)->addListenerToSourceChildren();
380 384
381 bool imageWasModified = false; 385 bool imageWasModified = false;
382 if (document().isActive()) { 386 if (document().isActive()) {
383 ImageCandidate candidate = findBestFitImageFromPictureParent(); 387 ImageCandidate candidate = findBestFitImageFromPictureParent();
384 if (!candidate.isEmpty()) { 388 if (!candidate.isEmpty()) {
385 setBestFitURLAndDPRFromImageCandidate(candidate); 389 setBestFitURLAndDPRFromImageCandidate(candidate);
386 imageWasModified = true; 390 imageWasModified = true;
387 } 391 }
388 } 392 }
389 393
390 // If we have been inserted from a layoutObject-less document, 394 // If we have been inserted from a layoutObject-less document,
391 // our loader may have not fetched the image, so do it now. 395 // our loader may have not fetched the image, so do it now.
392 if ((insertionPoint->isConnected() && !imageLoader().image()) || imageWasMod ified) 396 if ((insertionPoint->isConnected() && !imageLoader().image()) || imageWasMod ified)
393 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_referrerPol icy); 397 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_referrerPol icy);
394 398
395 return HTMLElement::insertedInto(insertionPoint); 399 return HTMLElement::insertedInto(insertionPoint);
396 } 400 }
397 401
398 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) 402 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint)
399 { 403 {
400 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this)) 404 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this))
401 resetFormOwner(); 405 resetFormOwner();
402 if (m_listener) 406 if (m_listener) {
403 document().mediaQueryMatcher().removeViewportListener(m_listener); 407 document().mediaQueryMatcher().removeViewportListener(m_listener);
408 Node* parent = parentNode();
409 if (parent && isHTMLPictureElement(*parent))
410 toHTMLPictureElement(parent)->removeListenerFromSourceChildren();
411 }
404 HTMLElement::removedFrom(insertionPoint); 412 HTMLElement::removedFrom(insertionPoint);
405 } 413 }
406 414
407 int HTMLImageElement::width() 415 int HTMLImageElement::width()
408 { 416 {
409 if (inActiveDocument()) 417 if (inActiveDocument())
410 document().updateStyleAndLayoutIgnorePendingStylesheets(); 418 document().updateStyleAndLayoutIgnorePendingStylesheets();
411 419
412 if (!layoutObject()) { 420 if (!layoutObject()) {
413 // check the attribute first for an explicit pixel value 421 // check the attribute first for an explicit pixel value
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 { 835 {
828 ImageResource* image = cachedImage(); 836 ImageResource* image = cachedImage();
829 if (!image) 837 if (!image)
830 return IntSize(); 838 return IntSize();
831 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f); 839 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f);
832 DCHECK(lSize.fraction().isZero()); 840 DCHECK(lSize.fraction().isZero());
833 return IntSize(lSize.width().toInt(), lSize.height().toInt()); 841 return IntSize(lSize.width().toInt(), lSize.height().toInt());
834 } 842 }
835 843
836 } // namespace blink 844 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698