| 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/accessibility/AXObjectCache.h" | 8 #include "core/accessibility/AXObjectCache.h" |
| 9 #include "core/rendering/RenderBoxModelObject.h" | 9 #include "core/rendering/RenderBoxModelObject.h" |
| 10 | 10 |
| 11 namespace WebCore { | 11 namespace WebCore { |
| 12 | 12 |
| 13 HitRegion::HitRegion(const HitRegionOptions& options) | 13 HitRegion::HitRegion(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(options.path) | 16 , m_path(options.path) |
| 17 , m_fillRule(options.fillRule) |
| 17 { | 18 { |
| 18 } | 19 } |
| 19 | 20 |
| 20 void HitRegion::updateAccessibility(Element* canvas) | 21 void HitRegion::updateAccessibility(Element* canvas) |
| 21 { | 22 { |
| 22 if (!m_control || !canvas || !canvas->renderer() || !m_control->isDescendant
Of(canvas)) | 23 if (!m_control || !canvas || !canvas->renderer() || !m_control->isDescendant
Of(canvas)) |
| 23 return; | 24 return; |
| 24 | 25 |
| 25 AXObjectCache* axObjectCache = m_control->document().existingAXObjectCache()
; | 26 AXObjectCache* axObjectCache = m_control->document().existingAXObjectCache()
; |
| 26 if (!axObjectCache) | 27 if (!axObjectCache) |
| 27 return; | 28 return; |
| 28 | 29 |
| 29 FloatRect boundingRect = m_path.boundingRect(); | 30 FloatRect boundingRect = m_path.boundingRect(); |
| 30 | 31 |
| 31 // Offset by the canvas rect, taking border and padding into account. | 32 // Offset by the canvas rect, taking border and padding into account. |
| 32 RenderBoxModelObject* rbmo = canvas->renderBoxModelObject(); | 33 RenderBoxModelObject* rbmo = canvas->renderBoxModelObject(); |
| 33 IntRect canvasRect = canvas->renderer()->absoluteBoundingBoxRect(); | 34 IntRect canvasRect = canvas->renderer()->absoluteBoundingBoxRect(); |
| 34 canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(), | 35 canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(), |
| 35 rbmo->borderTop() + rbmo->paddingTop()); | 36 rbmo->borderTop() + rbmo->paddingTop()); |
| 36 LayoutRect elementRect = enclosingLayoutRect(boundingRect); | 37 LayoutRect elementRect = enclosingLayoutRect(boundingRect); |
| 37 elementRect.moveBy(canvasRect.location()); | 38 elementRect.moveBy(canvasRect.location()); |
| 38 | 39 |
| 39 axObjectCache->setCanvasObjectBounds(m_control.get(), elementRect); | 40 axObjectCache->setCanvasObjectBounds(m_control.get(), elementRect); |
| 40 } | 41 } |
| 41 | 42 |
| 42 bool HitRegion::contains(const LayoutPoint& point) const | 43 bool HitRegion::contains(const LayoutPoint& point) const |
| 43 { | 44 { |
| 44 return m_path.contains(point, RULE_NONZERO); | 45 return m_path.contains(point, m_fillRule); |
| 45 } | 46 } |
| 46 | 47 |
| 47 void HitRegion::removePixels(const Path& clearArea) | 48 void HitRegion::removePixels(const Path& clearArea) |
| 48 { | 49 { |
| 49 m_path.subtractPath(clearArea); | 50 m_path.subtractPath(clearArea); |
| 50 } | 51 } |
| 51 | 52 |
| 52 void HitRegion::trace(Visitor* visitor) | 53 void HitRegion::trace(Visitor* visitor) |
| 53 { | 54 { |
| 54 visitor->trace(m_control); | 55 visitor->trace(m_control); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void HitRegionManager::trace(Visitor* visitor) | 155 void HitRegionManager::trace(Visitor* visitor) |
| 155 { | 156 { |
| 156 visitor->trace(m_hitRegionList); | 157 visitor->trace(m_hitRegionList); |
| 157 visitor->trace(m_hitRegionIdMap); | 158 visitor->trace(m_hitRegionIdMap); |
| 158 visitor->trace(m_hitRegionControlMap); | 159 visitor->trace(m_hitRegionControlMap); |
| 159 } | 160 } |
| 160 | 161 |
| 161 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HitRegionManager) | 162 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HitRegionManager) |
| 162 | 163 |
| 163 } // namespace WebCore | 164 } // namespace WebCore |
| OLD | NEW |