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

Side by Side Diff: Source/modules/canvas2d/HitRegion.cpp

Issue 1259973002: Canvas2d: Remove unnecessary conversion in EventHitRegion. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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 | « Source/modules/canvas2d/HitRegion.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/canvas2d/HitRegion.h" 6 #include "modules/canvas2d/HitRegion.h"
7 7
8 #include "core/dom/AXObjectCache.h" 8 #include "core/dom/AXObjectCache.h"
9 #include "core/layout/LayoutBoxModelObject.h" 9 #include "core/layout/LayoutBoxModelObject.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 HitRegion::HitRegion(const Path& path, const HitRegionOptions& options) 13 HitRegion::HitRegion(const Path& path, const HitRegionOptions& options)
14 : m_id(options.id()) 14 : m_id(options.id())
15 , m_control(options.control()) 15 , m_control(options.control())
16 , m_path(path) 16 , m_path(path)
17 { 17 {
18 if (options.fillRule() != "evenodd") 18 if (options.fillRule() != "evenodd")
19 m_fillRule = RULE_NONZERO; 19 m_fillRule = RULE_NONZERO;
20 else 20 else
21 m_fillRule = RULE_EVENODD; 21 m_fillRule = RULE_EVENODD;
22 } 22 }
23 23
24 bool HitRegion::contains(const LayoutPoint& point) const
25 {
26 return m_path.contains(FloatPoint(point), m_fillRule);
27 }
28
29 bool HitRegion::contains(const FloatPoint& point) const 24 bool HitRegion::contains(const FloatPoint& point) const
30 { 25 {
31 return m_path.contains(point, m_fillRule); 26 return m_path.contains(point, m_fillRule);
32 } 27 }
33 28
34 void HitRegion::removePixels(const Path& clearArea) 29 void HitRegion::removePixels(const Path& clearArea)
35 { 30 {
36 m_path.subtractPath(clearArea); 31 m_path.subtractPath(clearArea);
37 } 32 }
38 33
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 108 }
114 109
115 HitRegion* HitRegionManager::getHitRegionByControl(Element* control) const 110 HitRegion* HitRegionManager::getHitRegionByControl(Element* control) const
116 { 111 {
117 if (control) 112 if (control)
118 return m_hitRegionControlMap.get(control); 113 return m_hitRegionControlMap.get(control);
119 114
120 return nullptr; 115 return nullptr;
121 } 116 }
122 117
123 HitRegion* HitRegionManager::getHitRegionAtPoint(const LayoutPoint& point) const 118 HitRegion* HitRegionManager::getHitRegionAtPoint(const FloatPoint& point) const
124 { 119 {
125 HitRegionIterator itEnd = m_hitRegionList.rend(); 120 HitRegionIterator itEnd = m_hitRegionList.rend();
126 121
127 for (HitRegionIterator it = m_hitRegionList.rbegin(); it != itEnd; ++it) { 122 for (HitRegionIterator it = m_hitRegionList.rbegin(); it != itEnd; ++it) {
128 RefPtrWillBeRawPtr<HitRegion> hitRegion = *it; 123 RefPtrWillBeRawPtr<HitRegion> hitRegion = *it;
129 if (hitRegion->contains(point)) 124 if (hitRegion->contains(point))
130 return hitRegion.get(); 125 return hitRegion.get();
131 } 126 }
132 127
133 return nullptr; 128 return nullptr;
134 } 129 }
135 130
136 unsigned HitRegionManager::getHitRegionsCount() const 131 unsigned HitRegionManager::getHitRegionsCount() const
137 { 132 {
138 return m_hitRegionList.size(); 133 return m_hitRegionList.size();
139 } 134 }
140 135
141 DEFINE_TRACE(HitRegionManager) 136 DEFINE_TRACE(HitRegionManager)
142 { 137 {
143 #if ENABLE(OILPAN) 138 #if ENABLE(OILPAN)
144 visitor->trace(m_hitRegionList); 139 visitor->trace(m_hitRegionList);
145 visitor->trace(m_hitRegionIdMap); 140 visitor->trace(m_hitRegionIdMap);
146 visitor->trace(m_hitRegionControlMap); 141 visitor->trace(m_hitRegionControlMap);
147 #endif 142 #endif
148 } 143 }
149 144
150 } // namespace blink 145 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/canvas2d/HitRegion.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698