OLD | NEW |
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 void HitRegion::updateAccessibility(Element* canvas) | |
25 { | |
26 if (!m_control || !canvas || !canvas->layoutObject() || !m_control->isDescen
dantOf(canvas)) | |
27 return; | |
28 | |
29 AXObjectCache* axObjectCache = m_control->document().existingAXObjectCache()
; | |
30 if (!axObjectCache) | |
31 return; | |
32 | |
33 FloatRect boundingRect = m_path.boundingRect(); | |
34 | |
35 // Offset by the canvas rect, taking border and padding into account. | |
36 LayoutBoxModelObject* rbmo = canvas->layoutBoxModelObject(); | |
37 IntRect canvasRect = canvas->layoutObject()->absoluteBoundingBoxRect(); | |
38 canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(), | |
39 rbmo->borderTop() + rbmo->paddingTop()); | |
40 LayoutRect elementRect = enclosingLayoutRect(boundingRect); | |
41 elementRect.moveBy(canvasRect.location()); | |
42 | |
43 axObjectCache->setCanvasObjectBounds(m_control.get(), elementRect); | |
44 } | |
45 | |
46 bool HitRegion::contains(const LayoutPoint& point) const | 24 bool HitRegion::contains(const LayoutPoint& point) const |
47 { | 25 { |
48 return m_path.contains(FloatPoint(point), m_fillRule); | 26 return m_path.contains(FloatPoint(point), m_fillRule); |
49 } | 27 } |
50 | 28 |
51 bool HitRegion::contains(const FloatPoint& point) const | 29 bool HitRegion::contains(const FloatPoint& point) const |
52 { | 30 { |
53 return m_path.contains(point, m_fillRule); | 31 return m_path.contains(point, m_fillRule); |
54 } | 32 } |
55 | 33 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DEFINE_TRACE(HitRegionManager) | 141 DEFINE_TRACE(HitRegionManager) |
164 { | 142 { |
165 #if ENABLE(OILPAN) | 143 #if ENABLE(OILPAN) |
166 visitor->trace(m_hitRegionList); | 144 visitor->trace(m_hitRegionList); |
167 visitor->trace(m_hitRegionIdMap); | 145 visitor->trace(m_hitRegionIdMap); |
168 visitor->trace(m_hitRegionControlMap); | 146 visitor->trace(m_hitRegionControlMap); |
169 #endif | 147 #endif |
170 } | 148 } |
171 | 149 |
172 } // namespace blink | 150 } // namespace blink |
OLD | NEW |