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 "core/html/canvas/HitRegion.h" | 6 #include "core/html/canvas/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) | 24 void HitRegion::updateAccessibility(Element* canvas) |
25 { | 25 { |
26 if (!m_control || !canvas || !canvas->renderer() || !m_control->isDescendant
Of(canvas)) | 26 if (!m_control || !canvas || !canvas->layoutObject() || !m_control->isDescen
dantOf(canvas)) |
27 return; | 27 return; |
28 | 28 |
29 AXObjectCache* axObjectCache = m_control->document().existingAXObjectCache()
; | 29 AXObjectCache* axObjectCache = m_control->document().existingAXObjectCache()
; |
30 if (!axObjectCache) | 30 if (!axObjectCache) |
31 return; | 31 return; |
32 | 32 |
33 FloatRect boundingRect = m_path.boundingRect(); | 33 FloatRect boundingRect = m_path.boundingRect(); |
34 | 34 |
35 // Offset by the canvas rect, taking border and padding into account. | 35 // Offset by the canvas rect, taking border and padding into account. |
36 LayoutBoxModelObject* rbmo = canvas->layoutBoxModelObject(); | 36 LayoutBoxModelObject* rbmo = canvas->layoutBoxModelObject(); |
37 IntRect canvasRect = canvas->renderer()->absoluteBoundingBoxRect(); | 37 IntRect canvasRect = canvas->layoutObject()->absoluteBoundingBoxRect(); |
38 canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(), | 38 canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(), |
39 rbmo->borderTop() + rbmo->paddingTop()); | 39 rbmo->borderTop() + rbmo->paddingTop()); |
40 LayoutRect elementRect = enclosingLayoutRect(boundingRect); | 40 LayoutRect elementRect = enclosingLayoutRect(boundingRect); |
41 elementRect.moveBy(canvasRect.location()); | 41 elementRect.moveBy(canvasRect.location()); |
42 | 42 |
43 axObjectCache->setCanvasObjectBounds(m_control.get(), elementRect); | 43 axObjectCache->setCanvasObjectBounds(m_control.get(), elementRect); |
44 } | 44 } |
45 | 45 |
46 bool HitRegion::contains(const LayoutPoint& point) const | 46 bool HitRegion::contains(const LayoutPoint& point) const |
47 { | 47 { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 #if ENABLE(OILPAN) | 165 #if ENABLE(OILPAN) |
166 visitor->trace(m_hitRegionList); | 166 visitor->trace(m_hitRegionList); |
167 visitor->trace(m_hitRegionIdMap); | 167 visitor->trace(m_hitRegionIdMap); |
168 visitor->trace(m_hitRegionControlMap); | 168 visitor->trace(m_hitRegionControlMap); |
169 #endif | 169 #endif |
170 } | 170 } |
171 | 171 |
172 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HitRegionManager) | 172 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HitRegionManager) |
173 | 173 |
174 } // namespace blink | 174 } // namespace blink |
OLD | NEW |