Ejemplo n.º 1
0
// 'region' is in contents coordinates relative to the frame containing 'node'
// 'remainingFingerRegion' and 'intersectingRegions' will always be in main frame contents
// coordinates.
// Thus, before comparing, we need to map the former to main frame contents coordinates.
bool FatFingers::checkFingerIntersection(const Platform::IntRectRegion& region,
                                         const Platform::IntRectRegion& remainingFingerRegion,
                                         Node* node, Vector<IntersectingRegion>& intersectingRegions)
{
    ASSERT(node);

    Platform::IntRectRegion regionCopy(region);
    WebCore::IntPoint framePos(m_webPage->frameOffset(node->document()->frame()));
    regionCopy.move(framePos.x(), framePos.y());

    Platform::IntRectRegion intersection = intersectRegions(regionCopy, remainingFingerRegion);
    if (intersection.isEmpty())
        return false;

#if DEBUG_FAT_FINGERS
    String nodeName;
    if (node->isTextNode())
        nodeName = "text node";
    else if (node->isElementNode())
        nodeName = String::format("%s node", toElement(node)->tagName().latin1().data());
    else
        nodeName = "unknown node";
    log(LogLevelInfo, "%s has region %s, intersecting at %s (area %d)", nodeName.latin1().data(),
        regionCopy.toString().c_str(), intersection.toString().c_str(), intersection.area());
#endif

    intersectingRegions.append(std::make_pair(node, intersection));
    return true;
}
//! Makes a duplicate of each memory region.
StExecutableImage::StExecutableImage(const StExecutableImage &inOther)
    : m_name(inOther.m_name)
    , m_alignment(inOther.m_alignment)
    , m_hasEntry(inOther.m_hasEntry)
    , m_entry(inOther.m_entry)
    , m_filters(inOther.m_filters)
{
    const_iterator it = inOther.getRegionBegin();
    for (; it != inOther.getRegionEnd(); ++it)
    {
        const MemoryRegion &region = *it;

        MemoryRegion regionCopy(region);
        if (region.m_type == FILL_REGION && region.m_data != NULL)
        {
            regionCopy.m_data = new uint8_t[region.m_length];
            memcpy(regionCopy.m_data, region.m_data, region.m_length);
        }

        m_image.push_back(regionCopy);
    }
}