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

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

Issue 425383002: Move highestAncestorOrSelf() from Node to NodeTraversal (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLFormElement.cpp ('k') | Source/core/inspector/PageConsoleAgent.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 #include "core/html/HTMLImageElement.h" 24 #include "core/html/HTMLImageElement.h"
25 25
26 #include "bindings/core/v8/ScriptEventListener.h" 26 #include "bindings/core/v8/ScriptEventListener.h"
27 #include "core/CSSPropertyNames.h" 27 #include "core/CSSPropertyNames.h"
28 #include "core/HTMLNames.h" 28 #include "core/HTMLNames.h"
29 #include "core/MediaTypeNames.h" 29 #include "core/MediaTypeNames.h"
30 #include "core/css/MediaQueryMatcher.h" 30 #include "core/css/MediaQueryMatcher.h"
31 #include "core/css/MediaValuesDynamic.h" 31 #include "core/css/MediaValuesDynamic.h"
32 #include "core/css/parser/SizesAttributeParser.h" 32 #include "core/css/parser/SizesAttributeParser.h"
33 #include "core/dom/Attribute.h" 33 #include "core/dom/Attribute.h"
34 #include "core/dom/NodeTraversal.h"
34 #include "core/fetch/ImageResource.h" 35 #include "core/fetch/ImageResource.h"
35 #include "core/html/HTMLAnchorElement.h" 36 #include "core/html/HTMLAnchorElement.h"
36 #include "core/html/HTMLCanvasElement.h" 37 #include "core/html/HTMLCanvasElement.h"
37 #include "core/html/HTMLFormElement.h" 38 #include "core/html/HTMLFormElement.h"
38 #include "core/html/HTMLSourceElement.h" 39 #include "core/html/HTMLSourceElement.h"
39 #include "core/html/canvas/CanvasRenderingContext.h" 40 #include "core/html/canvas/CanvasRenderingContext.h"
40 #include "core/html/parser/HTMLParserIdioms.h" 41 #include "core/html/parser/HTMLParserIdioms.h"
41 #include "core/html/parser/HTMLSrcsetParser.h" 42 #include "core/html/parser/HTMLSrcsetParser.h"
42 #include "core/rendering/RenderImage.h" 43 #include "core/rendering/RenderImage.h"
43 #include "platform/MIMETypeRegistry.h" 44 #include "platform/MIMETypeRegistry.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 140 }
140 141
141 HTMLFormElement* HTMLImageElement::formOwner() const 142 HTMLFormElement* HTMLImageElement::formOwner() const
142 { 143 {
143 return m_form.get(); 144 return m_form.get();
144 } 145 }
145 146
146 void HTMLImageElement::formRemovedFromTree(const Node& formRoot) 147 void HTMLImageElement::formRemovedFromTree(const Node& formRoot)
147 { 148 {
148 ASSERT(m_form); 149 ASSERT(m_form);
149 if (highestAncestorOrSelf() != formRoot) 150 if (NodeTraversal::highestAncestorOrSelf(*this) != formRoot)
150 resetFormOwner(); 151 resetFormOwner();
151 } 152 }
152 153
153 void HTMLImageElement::resetFormOwner() 154 void HTMLImageElement::resetFormOwner()
154 { 155 {
155 m_formWasSetByParser = false; 156 m_formWasSetByParser = false;
156 HTMLFormElement* nearestForm = findFormAncestor(); 157 HTMLFormElement* nearestForm = findFormAncestor();
157 if (m_form) { 158 if (m_form) {
158 if (nearestForm == m_form.get()) 159 if (nearestForm == m_form.get())
159 return; 160 return;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (!imageLoader().image() && !renderImageResource->cachedImage()) 290 if (!imageLoader().image() && !renderImageResource->cachedImage())
290 renderImage->setImageSizeForAltText(); 291 renderImage->setImageSizeForAltText();
291 else 292 else
292 renderImageResource->setImageResource(imageLoader().image()); 293 renderImageResource->setImageResource(imageLoader().image());
293 294
294 } 295 }
295 } 296 }
296 297
297 Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode* insertionPoint) 298 Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode* insertionPoint)
298 { 299 {
299 if (!m_formWasSetByParser || insertionPoint->highestAncestorOrSelf() != m_fo rm->highestAncestorOrSelf()) 300 if (!m_formWasSetByParser || NodeTraversal::highestAncestorOrSelf(*insertion Point) != NodeTraversal::highestAncestorOrSelf(*m_form.get()))
300 resetFormOwner(); 301 resetFormOwner();
301 302
302 bool imageWasModified = false; 303 bool imageWasModified = false;
303 if (RuntimeEnabledFeatures::pictureEnabled()) { 304 if (RuntimeEnabledFeatures::pictureEnabled()) {
304 ImageCandidate candidate = findBestFitImageFromPictureParent(); 305 ImageCandidate candidate = findBestFitImageFromPictureParent();
305 if (!candidate.isEmpty()) { 306 if (!candidate.isEmpty()) {
306 setBestFitURLAndDPRFromImageCandidate(candidate); 307 setBestFitURLAndDPRFromImageCandidate(candidate);
307 imageWasModified = true; 308 imageWasModified = true;
308 } 309 }
309 } 310 }
310 311
311 // If we have been inserted from a renderer-less document, 312 // If we have been inserted from a renderer-less document,
312 // our loader may have not fetched the image, so do it now. 313 // our loader may have not fetched the image, so do it now.
313 if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModi fied) 314 if ((insertionPoint->inDocument() && !imageLoader().image()) || imageWasModi fied)
314 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_elementCrea tedByParser ? ImageLoader::ForceLoadImmediately : ImageLoader::LoadNormally); 315 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_elementCrea tedByParser ? ImageLoader::ForceLoadImmediately : ImageLoader::LoadNormally);
315 316
316 return HTMLElement::insertedInto(insertionPoint); 317 return HTMLElement::insertedInto(insertionPoint);
317 } 318 }
318 319
319 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) 320 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint)
320 { 321 {
321 if (!m_form || m_form->highestAncestorOrSelf() != highestAncestorOrSelf()) 322 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this))
322 resetFormOwner(); 323 resetFormOwner();
323 HTMLElement::removedFrom(insertionPoint); 324 HTMLElement::removedFrom(insertionPoint);
324 } 325 }
325 326
326 int HTMLImageElement::width(bool ignorePendingStylesheets) 327 int HTMLImageElement::width(bool ignorePendingStylesheets)
327 { 328 {
328 if (!renderer()) { 329 if (!renderer()) {
329 // check the attribute first for an explicit pixel value 330 // check the attribute first for an explicit pixel value
330 bool ok; 331 bool ok;
331 int width = getAttribute(widthAttr).toInt(&ok); 332 int width = getAttribute(widthAttr).toInt(&ok);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } 578 }
578 imageLoader().updateFromElement(behavior); 579 imageLoader().updateFromElement(behavior);
579 } 580 }
580 581
581 const KURL& HTMLImageElement::sourceURL() const 582 const KURL& HTMLImageElement::sourceURL() const
582 { 583 {
583 return cachedImage()->response().url(); 584 return cachedImage()->response().url();
584 } 585 }
585 586
586 } 587 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLFormElement.cpp ('k') | Source/core/inspector/PageConsoleAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698