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

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

Issue 181693006: Refactoring source image usage in CanvasRenderingContext2D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: applied last corrections Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLVideoElement.h » ('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 "CSSPropertyNames.h" 26 #include "CSSPropertyNames.h"
27 #include "HTMLNames.h" 27 #include "HTMLNames.h"
28 #include "RuntimeEnabledFeatures.h" 28 #include "RuntimeEnabledFeatures.h"
29 #include "bindings/v8/ScriptEventListener.h" 29 #include "bindings/v8/ScriptEventListener.h"
30 #include "core/dom/Attribute.h" 30 #include "core/dom/Attribute.h"
31 #include "core/events/ThreadLocalEventNames.h" 31 #include "core/events/ThreadLocalEventNames.h"
32 #include "core/fetch/ImageResource.h" 32 #include "core/fetch/ImageResource.h"
33 #include "core/html/HTMLAnchorElement.h" 33 #include "core/html/HTMLAnchorElement.h"
34 #include "core/html/HTMLCanvasElement.h"
34 #include "core/html/HTMLFormElement.h" 35 #include "core/html/HTMLFormElement.h"
36 #include "core/html/canvas/CanvasRenderingContext.h"
35 #include "core/html/parser/HTMLParserIdioms.h" 37 #include "core/html/parser/HTMLParserIdioms.h"
36 #include "core/html/parser/HTMLSrcsetParser.h" 38 #include "core/html/parser/HTMLSrcsetParser.h"
37 #include "core/rendering/RenderImage.h" 39 #include "core/rendering/RenderImage.h"
38 40
39 using namespace std; 41 using namespace std;
40 42
41 namespace WebCore { 43 namespace WebCore {
42 44
43 using namespace HTMLNames; 45 using namespace HTMLNames;
44 46
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return 0; 405 return 0;
404 406
405 return m_imageLoader.image()->image(); 407 return m_imageLoader.image()->image();
406 } 408 }
407 409
408 bool HTMLImageElement::isInteractiveContent() const 410 bool HTMLImageElement::isInteractiveContent() const
409 { 411 {
410 return fastHasAttribute(usemapAttr); 412 return fastHasAttribute(usemapAttr);
411 } 413 }
412 414
415 PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageMode, Sou rceImageStatus* status) const
416 {
417 if (!complete() || !cachedImage()) {
418 *status = IncompleteSourceImageStatus;
419 return nullptr;
420 }
421
422 if (cachedImage()->errorOccurred()) {
423 *status = UndecodableSourceImageStatus;
424 return nullptr;
425 }
426
427 RefPtr<Image> sourceImage = cachedImage()->imageForRenderer(renderer());
428
429 // We need to synthesize a container size if a renderer is not available to provide one.
430 if (!renderer() && sourceImage->usesContainerSize())
431 sourceImage->setContainerSize(sourceImage->size());
432
433 *status = NormalSourceImageStatus;
434 return sourceImage.release();
413 } 435 }
436
437 bool HTMLImageElement::wouldTaintOrigin(SecurityOrigin* destinationSecurityOrigi n) const
438 {
439 ImageResource* image = cachedImage();
440 if (!image)
441 return false;
442 return !image->isAccessAllowed(destinationSecurityOrigin);
443 }
444
445 FloatSize HTMLImageElement::sourceSize() const
446 {
447 ImageResource* image = cachedImage();
448 if (!image)
449 return FloatSize();
450 LayoutSize size;
451 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo ut this.
452
453 return size;
454 }
455
456 FloatSize HTMLImageElement::defaultDestinationSize() const
457 {
458 ImageResource* image = cachedImage();
459 if (!image)
460 return FloatSize();
461 LayoutSize size;
462 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo ut this.
463 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth())
464 size.scale(toRenderImage(renderer())->imageDevicePixelRatio());
465 return size;
466 }
467
468 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLVideoElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698