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

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

Issue 1692183002: Canvas2d: The control in hit region should be a canvas fallback element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 13 matching lines...) Expand all
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "core/html/HTMLCanvasElement.h" 28 #include "core/html/HTMLCanvasElement.h"
29 29
30 #include "bindings/core/v8/ExceptionMessages.h" 30 #include "bindings/core/v8/ExceptionMessages.h"
31 #include "bindings/core/v8/ExceptionState.h" 31 #include "bindings/core/v8/ExceptionState.h"
32 #include "bindings/core/v8/ScriptController.h" 32 #include "bindings/core/v8/ScriptController.h"
33 #include "core/HTMLNames.h" 33 #include "core/HTMLNames.h"
34 #include "core/InputTypeNames.h"
34 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/Element.h"
37 #include "core/dom/ElementTraversal.h"
35 #include "core/dom/ExceptionCode.h" 38 #include "core/dom/ExceptionCode.h"
36 #include "core/fileapi/File.h" 39 #include "core/fileapi/File.h"
37 #include "core/frame/ImageBitmap.h" 40 #include "core/frame/ImageBitmap.h"
38 #include "core/frame/LocalFrame.h" 41 #include "core/frame/LocalFrame.h"
39 #include "core/frame/Settings.h" 42 #include "core/frame/Settings.h"
43 #include "core/html/HTMLImageElement.h"
44 #include "core/html/HTMLInputElement.h"
45 #include "core/html/HTMLSelectElement.h"
40 #include "core/html/ImageData.h" 46 #include "core/html/ImageData.h"
41 #include "core/html/canvas/CanvasAsyncBlobCreator.h" 47 #include "core/html/canvas/CanvasAsyncBlobCreator.h"
42 #include "core/html/canvas/CanvasContextCreationAttributes.h" 48 #include "core/html/canvas/CanvasContextCreationAttributes.h"
43 #include "core/html/canvas/CanvasFontCache.h" 49 #include "core/html/canvas/CanvasFontCache.h"
44 #include "core/html/canvas/CanvasRenderingContext.h" 50 #include "core/html/canvas/CanvasRenderingContext.h"
45 #include "core/html/canvas/CanvasRenderingContextFactory.h" 51 #include "core/html/canvas/CanvasRenderingContextFactory.h"
46 #include "core/imagebitmap/ImageBitmapOptions.h" 52 #include "core/imagebitmap/ImageBitmapOptions.h"
47 #include "core/layout/LayoutHTMLCanvas.h" 53 #include "core/layout/LayoutHTMLCanvas.h"
48 #include "core/paint/PaintLayer.h" 54 #include "core/paint/PaintLayer.h"
49 #include "platform/Histogram.h" 55 #include "platform/Histogram.h"
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 return ScriptPromise(); 1030 return ScriptPromise();
1025 } 1031 }
1026 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); 1032 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr);
1027 } 1033 }
1028 1034
1029 bool HTMLCanvasElement::isOpaque() const 1035 bool HTMLCanvasElement::isOpaque() const
1030 { 1036 {
1031 return m_context && !m_context->hasAlpha(); 1037 return m_context && !m_context->hasAlpha();
1032 } 1038 }
1033 1039
1040 bool HTMLCanvasElement::isSupportedInteractiveCanvasFallback(const Element& elem ent)
1041 {
1042 if (!element.isDescendantOf(this))
1043 return false;
1044
1045 // An element is a supported interactive canvas fallback element if it is on e of the following:
1046 // https://html.spec.whatwg.org/multipage/scripting.html#supported-interacti ve-canvas-fallback-element
1047
1048 // An a element that represents a hyperlink and that does not have any img d escendants.
1049 if (isHTMLAnchorElement(element))
1050 return !Traversal<HTMLImageElement>::firstWithin(element);
1051
1052 // A button element
1053 if (isHTMLButtonElement(element))
1054 return true;
1055
1056 // An input element whose type attribute is in one of the Checkbox or Radio Button states.
1057 // An input element that is a button but its type attribute is not in the Im age Button state.
1058 if (isHTMLInputElement(element)) {
1059 const HTMLInputElement& inputElement = toHTMLInputElement(element);
1060 if (inputElement.type() == InputTypeNames::checkbox
1061 || inputElement.type() == InputTypeNames::radio
1062 || inputElement.isTextButton())
1063 return true;
1064 }
1065
1066 // A select element with a multiple attribute or a display size greater than 1.
1067 if (isHTMLSelectElement(element)) {
1068 const HTMLSelectElement& selectElement = toHTMLSelectElement(element);
1069 if (selectElement.multiple() || selectElement.size() > 1)
1070 return true;
1071 }
1072
1073 // An option element that is in a list of options of a select element with a multiple attribute or a display size greater than 1.
1074 if (isHTMLOptionElement(element) && element.parentNode() && isHTMLSelectElem ent(*element.parentNode())) {
1075 const HTMLSelectElement& selectElement = toHTMLSelectElement(*element.pa rentNode());
1076 if (selectElement.multiple() || selectElement.size() > 1)
1077 return true;
1078 }
1079
1080 // An element that would not be interactive content except for having the ta bindex attribute specified.
1081 if (element.fastHasAttribute(HTMLNames::tabindexAttr))
1082 return true;
1083
1084 // A non-interactive table, caption, thead, tbody, tfoot, tr, td, or th elem ent.
1085 if (isHTMLTableElement(element)
1086 || element.hasTagName(HTMLNames::captionTag)
1087 || element.hasTagName(HTMLNames::theadTag)
1088 || element.hasTagName(HTMLNames::tbodyTag)
1089 || element.hasTagName(HTMLNames::tfootTag)
1090 || element.hasTagName(HTMLNames::trTag)
1091 || element.hasTagName(HTMLNames::tdTag)
1092 || element.hasTagName(HTMLNames::thTag))
1093 return true;
1094
1095 return false;
1096 }
1097
1034 } // namespace blink 1098 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698