<commit_before>// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "config.h"
#include "core/html/canvas/HitRegion.h"

#include "core/accessibility/AXObjectCache.h"
#include "core/rendering/RenderBoxModelObject.h"

namespace WebCore {

HitRegion::HitRegion(const HitRegionOptions& options)
    : m_id(options.id)
    , m_control(options.control)
    , m_path(options.path)
{
}

void HitRegion::updateAccessibility(Element* canvas)
{
    if (!m_control || !canvas || !canvas->renderer() || !m_control->isDescendantOf(canvas))
        return;

    AXObjectCache* axObjectCache = m_control->document().existingAXObjectCache();
    if (!axObjectCache)
        return;

    FloatRect boundingRect = m_path.boundingRect();

    // Offset by the canvas rect, taking border and padding into account.
    RenderBoxModelObject* rbmo = canvas->renderBoxModelObject();
    IntRect canvasRect = canvas->renderer()->absoluteBoundingBoxRect();
    canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(),
        rbmo->borderTop() + rbmo->paddingTop());
    LayoutRect elementRect = enclosingLayoutRect(boundingRect);
    elementRect.moveBy(canvasRect.location());

    axObjectCache->setCanvasObjectBounds(m_control.get(), elementRect);
}

bool HitRegion::contains(const LayoutPoint& point) const
{
    if (!m_path.boundingRect().contains(point))
        return false;

    return m_path.contains(point, RULE_NONZERO);
}

void HitRegion::removePixels(const Path& clearArea)
{
    m_path.subtractPath(clearArea);<commit_msg>The bounding check is duplicated.<commit_after>// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "config.h"
#include "core/html/canvas/HitRegion.h"

#include "core/accessibility/AXObjectCache.h"
#include "core/rendering/RenderBoxModelObject.h"

namespace WebCore {

HitRegion::HitRegion(const HitRegionOptions& options)
    : m_id(options.id)
    , m_control(options.control)
    , m_path(options.path)
{
}

void HitRegion::updateAccessibility(Element* canvas)
{
    if (!m_control || !canvas || !canvas->renderer() || !m_control->isDescendantOf(canvas))
        return;

    AXObjectCache* axObjectCache = m_control->document().existingAXObjectCache();
    if (!axObjectCache)
        return;

    FloatRect boundingRect = m_path.boundingRect();

    // Offset by the canvas rect, taking border and padding into account.
    RenderBoxModelObject* rbmo = canvas->renderBoxModelObject();
    IntRect canvasRect = canvas->renderer()->absoluteBoundingBoxRect();
    canvasRect.move(rbmo->borderLeft() + rbmo->paddingLeft(),
        rbmo->borderTop() + rbmo->paddingTop());
    LayoutRect elementRect = enclosingLayoutRect(boundingRect);
    elementRect.moveBy(canvasRect.location());

    axObjectCache->setCanvasObjectBounds(m_control.get(), elementRect);
}

bool HitRegion::contains(const LayoutPoint& point) const
{
    return m_path.contains(point, RULE_NONZERO);
}

void HitRegion::removePixels(const Path& clearArea)
{
    m_path.subtractPath(clearArea);
{'fraction_non_alphanumeric': 0.12099533437013997, 'fraction_numerical': 0.002488335925349922, 'mean_word_length': 4.692035398230089, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6523659', 'n_tokens_mistral': 975, 'n_tokens_neox': 961, 'n_words': 211}