<commit_before>/*
 * Copyright 2011 Esrille Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "HTMLAnchorElementImp.h"

#include <iostream>
#include <boost/bind.hpp>

#include "utf.h"

namespace org
{
namespace w3c
{
namespace dom
{
namespace bootstrap
{

HTMLAnchorElementImp::HTMLAnchorElementImp(HTMLAnchorElementImp* org, bool deep) :
    ObjectMixin(org, deep),
    clickListener(boost::bind(&HTMLAnchorElementImp::handleClick, this, _1))
{
    addEventListener(u"click", &clickListener);
}

HTMLAnchorElementImp::HTMLAnchorElementImp(DocumentImp* ownerDocument) :
    ObjectMixin(ownerDocument, u"a"),
    clickListener(boost::bind(&HTMLAnchorElementImp::handleClick, this, _1))
{
    addEventListener(u"click", &clickListener);
}

HTMLAnchorElementImp::~HTMLAnchorElementImp()
{
}

void HTMLAnchorElementImp::handleClick(events::Event event)
{
    if (event.getDefaultPrevented())
        return;
    std::u16string href = getHref();
    if (!href.empty())
        getOwnerDocument().setLocation(href);
}

std::u16string HTMLAnchorElementImp::getHref()
{
    return getAttribute(u"href");
}

void HTMLAnchorElementImp::setHref(std::u16string href)
{
    // TODO: implement me!
}

std::u16string HTMLAnchorElementImp::getTarget()
{
    // TODO: implement me!
    return u"";
}

void HTMLAnchorElementImp::setTarget(std::u16string target)
{<commit_msg>(HTMLAnchorElementImp::handleClick) : Check click by the primary button only.<commit_after>/*
 * Copyright 2011 Esrille Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "HTMLAnchorElementImp.h"

#include <iostream>
#include <boost/bind.hpp>

#include <org/w3c/dom/events/MouseEvent.h>

#include "utf.h"

namespace org
{
namespace w3c
{
namespace dom
{
namespace bootstrap
{

HTMLAnchorElementImp::HTMLAnchorElementImp(HTMLAnchorElementImp* org, bool deep) :
    ObjectMixin(org, deep),
    clickListener(boost::bind(&HTMLAnchorElementImp::handleClick, this, _1))
{
    addEventListener(u"click", &clickListener);
}

HTMLAnchorElementImp::HTMLAnchorElementImp(DocumentImp* ownerDocument) :
    ObjectMixin(ownerDocument, u"a"),
    clickListener(boost::bind(&HTMLAnchorElementImp::handleClick, this, _1))
{
    addEventListener(u"click", &clickListener);
}

HTMLAnchorElementImp::~HTMLAnchorElementImp()
{
}

void HTMLAnchorElementImp::handleClick(events::Event event)
{
    if (event.getDefaultPrevented())
        return;
    events::MouseEvent mouse = interface_cast<events::MouseEvent>(event);
    std::u16string href = getHref();
    if (!href.empty() && mouse.getButton() == 0)
        getOwnerDocument().setLocation(href);
}

std::u16string HTMLAnchorElementImp::getHref()
{
    return getAttribute(u"href");
}

void HTMLAnchorElementImp::setHref(std::u16string href)
{
    // TODO: implement me!
}

std::u16string HTMLAnchorElementImp::getTarget()
{
    // TODO: implement me!
    return u"";
}

void HTMLAnchorElementImp::setTarget(std::u16string target)
{
{'fraction_non_alphanumeric': 0.11544265593561369, 'fraction_numerical': 0.011066398390342052, 'mean_word_length': 5.053272450532725, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3202978', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1169, 'n_words': 318}