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

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

Issue 1654653002: Canvas2d: Implement rerouting event by hit region's control. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass existing tests. 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 15 matching lines...) Expand all
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/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/ExceptionCode.h" 35 #include "core/dom/ExceptionCode.h"
36 #include "core/events/Event.h"
37 #include "core/events/EventDispatcher.h"
38 #include "core/events/MouseEvent.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"
40 #include "core/html/ImageData.h" 43 #include "core/html/ImageData.h"
41 #include "core/html/canvas/CanvasAsyncBlobCreator.h" 44 #include "core/html/canvas/CanvasAsyncBlobCreator.h"
42 #include "core/html/canvas/CanvasContextCreationAttributes.h" 45 #include "core/html/canvas/CanvasContextCreationAttributes.h"
43 #include "core/html/canvas/CanvasFontCache.h" 46 #include "core/html/canvas/CanvasFontCache.h"
44 #include "core/html/canvas/CanvasRenderingContext.h" 47 #include "core/html/canvas/CanvasRenderingContext.h"
45 #include "core/html/canvas/CanvasRenderingContextFactory.h" 48 #include "core/html/canvas/CanvasRenderingContextFactory.h"
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 return ScriptPromise(); 1018 return ScriptPromise();
1016 } 1019 }
1017 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); 1020 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr);
1018 } 1021 }
1019 1022
1020 bool HTMLCanvasElement::isOpaque() const 1023 bool HTMLCanvasElement::isOpaque() const
1021 { 1024 {
1022 return m_context && !m_context->hasAlpha(); 1025 return m_context && !m_context->hasAlpha();
1023 } 1026 }
1024 1027
1028 bool HTMLCanvasElement::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> even t)
1029 {
1030 if (event->isMouseEvent() && event->isTrusted()) {
1031 MouseEvent* mouseEvent = toMouseEvent(event);
1032 std::pair<Element*, String> regionInfo = getControlAndIDIfHitRegionExist s(mouseEvent->absoluteLocation());
1033 mouseEvent->setRegion(regionInfo.second);
1034 if (regionInfo.first)
1035 return EventDispatcher::dispatchEvent(*regionInfo.first, event->crea teMediator());
1036 }
1037 return HTMLElement::dispatchEventInternal(event);
1038 }
1039
1040 std::pair<Element*, String> HTMLCanvasElement::getControlAndIDIfHitRegionExists( const LayoutPoint& location)
philipj_slow 2016/02/05 07:30:06 Should probably be Id (not ID) for consistency. I
zino 2016/02/12 15:26:18 I think it's better to "Id" than "ID". Done.
1041 {
1042 if (m_context && m_context->is2d() && m_context->hitRegionsCount() > 0)
philipj_slow 2016/02/05 07:30:06 It's a bit odd to both have an is2d() test and a v
1043 return m_context->getControlAndIDIfHitRegionExists(location);
1044 return std::make_pair(nullptr, String());
1045 }
1046
1025 } // namespace blink 1047 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698