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

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

Issue 1767633002: Support canvas size as default object size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-default-object-size
Patch Set: Save image size on stack Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 417
418 bool listenerNeedsNewFrameCapture = false; 418 bool listenerNeedsNewFrameCapture = false;
419 for (const CanvasDrawListener* listener : m_listeners) { 419 for (const CanvasDrawListener* listener : m_listeners) {
420 if (listener->needsNewFrame()) { 420 if (listener->needsNewFrame()) {
421 listenerNeedsNewFrameCapture = true; 421 listenerNeedsNewFrameCapture = true;
422 } 422 }
423 } 423 }
424 424
425 if (listenerNeedsNewFrameCapture) { 425 if (listenerNeedsNewFrameCapture) {
426 SourceImageStatus status; 426 SourceImageStatus status;
427 RefPtr<Image> sourceImage = getSourceImageForCanvas(&status, PreferNoAcc eleration, SnapshotReasonCanvasListenerCapture); 427 RefPtr<Image> sourceImage = getSourceImageForCanvas(&status, PreferNoAcc eleration, SnapshotReasonCanvasListenerCapture, FloatSize());
428 if (status != NormalSourceImageStatus) 428 if (status != NormalSourceImageStatus)
429 return; 429 return;
430 RefPtr<SkImage> image = sourceImage->imageForCurrentFrame(); 430 RefPtr<SkImage> image = sourceImage->imageForCurrentFrame();
431 for (CanvasDrawListener* listener : m_listeners) { 431 for (CanvasDrawListener* listener : m_listeners) {
432 if (listener->needsNewFrame()) { 432 if (listener->needsNewFrame()) {
433 listener->sendNewFrame(image); 433 listener->sendNewFrame(image);
434 } 434 }
435 } 435 }
436 } 436 }
437 437
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 if (m_context) 962 if (m_context)
963 m_context->styleDidChange(oldStyle, newStyle); 963 m_context->styleDidChange(oldStyle, newStyle);
964 } 964 }
965 965
966 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument) 966 void HTMLCanvasElement::didMoveToNewDocument(Document& oldDocument)
967 { 967 {
968 setObservedDocument(document()); 968 setObservedDocument(document());
969 HTMLElement::didMoveToNewDocument(oldDocument); 969 HTMLElement::didMoveToNewDocument(oldDocument);
970 } 970 }
971 971
972 PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(SourceImageStatus* status, AccelerationHint hint, SnapshotReason reason) const 972 PassRefPtr<Image> HTMLCanvasElement::getSourceImageForCanvas(SourceImageStatus* status, AccelerationHint hint, SnapshotReason reason, const FloatSize&) const
973 { 973 {
974 if (!width() || !height()) { 974 if (!width() || !height()) {
975 *status = ZeroSizeCanvasSourceImageStatus; 975 *status = ZeroSizeCanvasSourceImageStatus;
976 return nullptr; 976 return nullptr;
977 } 977 }
978 978
979 if (!isPaintable()) { 979 if (!isPaintable()) {
980 *status = InvalidSourceImageStatus; 980 *status = InvalidSourceImageStatus;
981 return nullptr; 981 return nullptr;
982 } 982 }
(...skipping 15 matching lines...) Expand all
998 998
999 *status = InvalidSourceImageStatus; 999 *status = InvalidSourceImageStatus;
1000 return nullptr; 1000 return nullptr;
1001 } 1001 }
1002 1002
1003 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const 1003 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const
1004 { 1004 {
1005 return !originClean(); 1005 return !originClean();
1006 } 1006 }
1007 1007
1008 FloatSize HTMLCanvasElement::elementSize() const 1008 FloatSize HTMLCanvasElement::elementSize(const FloatSize&) const
1009 { 1009 {
1010 return FloatSize(width(), height()); 1010 return FloatSize(width(), height());
1011 } 1011 }
1012 1012
1013 IntSize HTMLCanvasElement::bitmapSourceSize() const 1013 IntSize HTMLCanvasElement::bitmapSourceSize() const
1014 { 1014 {
1015 return IntSize(width(), height()); 1015 return IntSize(width(), height());
1016 } 1016 }
1017 1017
1018 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState) 1018 ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, Eve ntTarget& eventTarget, int sx, int sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 || element.hasTagName(HTMLNames::tfootTag) 1082 || element.hasTagName(HTMLNames::tfootTag)
1083 || element.hasTagName(HTMLNames::trTag) 1083 || element.hasTagName(HTMLNames::trTag)
1084 || element.hasTagName(HTMLNames::tdTag) 1084 || element.hasTagName(HTMLNames::tdTag)
1085 || element.hasTagName(HTMLNames::thTag)) 1085 || element.hasTagName(HTMLNames::thTag))
1086 return true; 1086 return true;
1087 1087
1088 return false; 1088 return false;
1089 } 1089 }
1090 1090
1091 } // namespace blink 1091 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLCanvasElement.h ('k') | third_party/WebKit/Source/core/html/HTMLImageElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698