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

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

Issue 1001913003: Remove <canvas> (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « sky/engine/core/html/HTMLImageElement.h ('k') | sky/engine/core/html/HTMLTagNames.in » ('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 16 matching lines...) Expand all
27 #include "gen/sky/core/HTMLNames.h" 27 #include "gen/sky/core/HTMLNames.h"
28 #include "gen/sky/core/MediaTypeNames.h" 28 #include "gen/sky/core/MediaTypeNames.h"
29 #include "gen/sky/platform/RuntimeEnabledFeatures.h" 29 #include "gen/sky/platform/RuntimeEnabledFeatures.h"
30 #include "sky/engine/core/css/MediaQueryListListener.h" 30 #include "sky/engine/core/css/MediaQueryListListener.h"
31 #include "sky/engine/core/css/MediaQueryMatcher.h" 31 #include "sky/engine/core/css/MediaQueryMatcher.h"
32 #include "sky/engine/core/css/MediaValuesDynamic.h" 32 #include "sky/engine/core/css/MediaValuesDynamic.h"
33 #include "sky/engine/core/dom/Attribute.h" 33 #include "sky/engine/core/dom/Attribute.h"
34 #include "sky/engine/core/dom/NodeTraversal.h" 34 #include "sky/engine/core/dom/NodeTraversal.h"
35 #include "sky/engine/core/fetch/ImageResource.h" 35 #include "sky/engine/core/fetch/ImageResource.h"
36 #include "sky/engine/core/html/HTMLAnchorElement.h" 36 #include "sky/engine/core/html/HTMLAnchorElement.h"
37 #include "sky/engine/core/html/HTMLCanvasElement.h"
38 #include "sky/engine/core/html/canvas/CanvasRenderingContext.h"
39 #include "sky/engine/core/html/parser/HTMLParserIdioms.h" 37 #include "sky/engine/core/html/parser/HTMLParserIdioms.h"
40 #include "sky/engine/core/html/parser/HTMLSrcsetParser.h" 38 #include "sky/engine/core/html/parser/HTMLSrcsetParser.h"
41 #include "sky/engine/core/inspector/ConsoleMessage.h" 39 #include "sky/engine/core/inspector/ConsoleMessage.h"
42 #include "sky/engine/core/rendering/RenderImage.h" 40 #include "sky/engine/core/rendering/RenderImage.h"
43 #include "sky/engine/platform/MIMETypeRegistry.h" 41 #include "sky/engine/platform/MIMETypeRegistry.h"
44 42
45 namespace blink { 43 namespace blink {
46 44
47 class HTMLImageElement::ViewportChangeListener final : public MediaQueryListList ener { 45 class HTMLImageElement::ViewportChangeListener final : public MediaQueryListList ener {
48 public: 46 public:
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 { 300 {
303 return imageLoader().imageComplete(); 301 return imageLoader().imageComplete();
304 } 302 }
305 303
306 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument) 304 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument)
307 { 305 {
308 imageLoader().elementDidMoveToNewDocument(); 306 imageLoader().elementDidMoveToNewDocument();
309 HTMLElement::didMoveToNewDocument(oldDocument); 307 HTMLElement::didMoveToNewDocument(oldDocument);
310 } 308 }
311 309
312 PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageMode, Sou rceImageStatus* status) const
313 {
314 if (!complete() || !cachedImage()) {
315 *status = IncompleteSourceImageStatus;
316 return nullptr;
317 }
318
319 if (cachedImage()->errorOccurred()) {
320 *status = UndecodableSourceImageStatus;
321 return nullptr;
322 }
323
324 RefPtr<Image> sourceImage = cachedImage()->imageForRenderer(renderer());
325
326 // We need to synthesize a container size if a renderer is not available to provide one.
327 if (!renderer() && sourceImage->usesContainerSize())
328 sourceImage->setContainerSize(sourceImage->size());
329
330 *status = NormalSourceImageStatus;
331 return sourceImage->imageForDefaultFrame();
332 }
333
334 FloatSize HTMLImageElement::sourceSize() const
335 {
336 ImageResource* image = cachedImage();
337 if (!image)
338 return FloatSize();
339 return image->imageSizeForRenderer(renderer()); // FIXME: Not sure about thi s.
340 }
341
342 FloatSize HTMLImageElement::defaultDestinationSize() const
343 {
344 ImageResource* image = cachedImage();
345 if (!image)
346 return FloatSize();
347 LayoutSize size;
348 size = image->imageSizeForRenderer(renderer()); // FIXME: Not sure about thi s.
349 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth())
350 size.scale(toRenderImage(renderer())->imageDevicePixelRatio());
351 return size;
352 }
353
354 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) 310 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior)
355 { 311 {
356 unsigned effectiveSize = 0; 312 unsigned effectiveSize = 0;
357 ImageCandidate candidate = bestFitSourceForImageAttributes( 313 ImageCandidate candidate = bestFitSourceForImageAttributes(
358 document().devicePixelRatio(), effectiveSize, 314 document().devicePixelRatio(), effectiveSize,
359 getAttribute(HTMLNames::srcAttr), AtomicString()); 315 getAttribute(HTMLNames::srcAttr), AtomicString());
360 setBestFitURLAndDPRFromImageCandidate(candidate); 316 setBestFitURLAndDPRFromImageCandidate(candidate);
361 if (m_intrinsicSizingViewportDependant && m_effectiveSizeViewportDependant & & !m_listener.get()) { 317 if (m_intrinsicSizingViewportDependant && m_effectiveSizeViewportDependant & & !m_listener.get()) {
362 m_listener = ViewportChangeListener::create(this); 318 m_listener = ViewportChangeListener::create(this);
363 document().mediaQueryMatcher().addViewportListener(m_listener.get()); 319 document().mediaQueryMatcher().addViewportListener(m_listener.get());
364 } 320 }
365 imageLoader().updateFromElement(behavior); 321 imageLoader().updateFromElement(behavior);
366 } 322 }
367 323
368 const KURL& HTMLImageElement::sourceURL() const
369 {
370 return cachedImage()->response().url();
371 } 324 }
372
373 }
OLDNEW
« no previous file with comments | « sky/engine/core/html/HTMLImageElement.h ('k') | sky/engine/core/html/HTMLTagNames.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698