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

Side by Side Diff: sky/engine/core/html/HTMLImageElement.cpp

Issue 732163004: Teach HTMLImageElement that it doesn't need ::attach. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Swap logic. Created 6 years, 1 month 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } else { 142 } else {
143 HTMLElement::parseAttribute(name, value); 143 HTMLElement::parseAttribute(name, value);
144 } 144 }
145 } 145 }
146 146
147 RenderObject* HTMLImageElement::createRenderer(RenderStyle* style) 147 RenderObject* HTMLImageElement::createRenderer(RenderStyle* style)
148 { 148 {
149 RenderImage* image = new RenderImage(this); 149 RenderImage* image = new RenderImage(this);
150 image->setImageResource(RenderImageResource::create()); 150 image->setImageResource(RenderImageResource::create());
151 image->setImageDevicePixelRatio(m_imageDevicePixelRatio); 151 image->setImageDevicePixelRatio(m_imageDevicePixelRatio);
152
153 RenderImageResource* imageResource = image->imageResource();
154 if (cachedImage() || imageResource->cachedImage())
155 imageResource->setImageResource(cachedImage());
156
152 return image; 157 return image;
153 } 158 }
154 159
155 bool HTMLImageElement::canStartSelection() const 160 bool HTMLImageElement::canStartSelection() const
156 { 161 {
157 if (shadow()) 162 if (shadow())
158 return HTMLElement::canStartSelection(); 163 return HTMLElement::canStartSelection();
159 164
160 return false; 165 return false;
161 } 166 }
162 167
163 void HTMLImageElement::attach(const AttachContext& context)
164 {
165 HTMLElement::attach(context);
166
167 if (renderer() && renderer()->isImage()) {
168 RenderImage* renderImage = toRenderImage(renderer());
169 RenderImageResource* renderImageResource = renderImage->imageResource();
170 if (renderImageResource->hasImage())
171 return;
172
173 if (imageLoader().image() || renderImageResource->cachedImage())
174 renderImageResource->setImageResource(imageLoader().image());
175 }
176 }
177
178 Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode* insertionPoint) 168 Node::InsertionNotificationRequest HTMLImageElement::insertedInto(ContainerNode* insertionPoint)
179 { 169 {
180 if (m_listener) 170 if (m_listener)
181 document().mediaQueryMatcher().addViewportListener(m_listener.get()); 171 document().mediaQueryMatcher().addViewportListener(m_listener.get());
182 172
183 // If we have been inserted from a renderer-less document, 173 // If we have been inserted from a renderer-less document,
184 // our loader may have not fetched the image, so do it now. 174 // our loader may have not fetched the image, so do it now.
185 if ((insertionPoint->inDocument() && !imageLoader().image())) 175 if ((insertionPoint->inDocument() && !imageLoader().image()))
186 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_elementCrea tedByParser ? ImageLoader::ForceLoadImmediately : ImageLoader::LoadNormally); 176 imageLoader().updateFromElement(ImageLoader::UpdateNormal, m_elementCrea tedByParser ? ImageLoader::ForceLoadImmediately : ImageLoader::LoadNormally);
187 177
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 383 }
394 imageLoader().updateFromElement(behavior); 384 imageLoader().updateFromElement(behavior);
395 } 385 }
396 386
397 const KURL& HTMLImageElement::sourceURL() const 387 const KURL& HTMLImageElement::sourceURL() const
398 { 388 {
399 return cachedImage()->response().url(); 389 return cachedImage()->response().url();
400 } 390 }
401 391
402 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698