示例#1
0
void LayoutRect::uniteEvenIfEmpty(const LayoutRect& other) {
  LayoutPoint newLocation(std::min(x(), other.x()), std::min(y(), other.y()));
  LayoutPoint newMaxPoint(std::max(maxX(), other.maxX()),
                          std::max(maxY(), other.maxY()));

  m_location = newLocation;
  m_size = newMaxPoint - newLocation;
}
示例#2
0
void LayoutRect::intersect(const LayoutRect& other)
{
    LayoutPoint newLocation(std::max(x(), other.x()), std::max(y(), other.y()));
    LayoutPoint newMaxPoint(std::min(maxX(), other.maxX()), std::min(maxY(), other.maxY()));

    // Return a clean empty rectangle for non-intersecting cases.
    if (newLocation.x() >= newMaxPoint.x() || newLocation.y() >= newMaxPoint.y()) {
        newLocation = LayoutPoint(0, 0);
        newMaxPoint = LayoutPoint(0, 0);
    }

    m_location = newLocation;
    m_size = newMaxPoint - newLocation;
}
示例#3
0
bool LayoutRect::inclusiveIntersect(const LayoutRect& other) {
  LayoutPoint newLocation(std::max(x(), other.x()), std::max(y(), other.y()));
  LayoutPoint newMaxPoint(std::min(maxX(), other.maxX()),
                          std::min(maxY(), other.maxY()));

  if (newLocation.x() > newMaxPoint.x() || newLocation.y() > newMaxPoint.y()) {
    *this = LayoutRect();
    return false;
  }

  m_location = newLocation;
  m_size = newMaxPoint - newLocation;
  return true;
}
示例#4
0
void LayoutRect::uniteIfNonZero(const LayoutRect& other)
{
    // Handle empty special cases first.
    if (!other.width() && !other.height())
        return;
    if (!width() && !height()) {
        *this = other;
        return;
    }

    LayoutPoint newLocation(std::min(x(), other.x()), std::min(y(), other.y()));
    LayoutPoint newMaxPoint(std::max(maxX(), other.maxX()), std::max(maxY(), other.maxY()));

    m_location = newLocation;
    m_size = newMaxPoint - newLocation;
}
示例#5
0
void LayoutRect::unite(const LayoutRect& other)
{
    // Handle empty special cases first.
    if (other.isEmpty())
        return;
    if (isEmpty()) {
        *this = other;
        return;
    }

    LayoutPoint newLocation(std::min(x(), other.x()), std::min(y(), other.y()));
    LayoutPoint newMaxPoint(std::max(maxX(), other.maxX()), std::max(maxY(), other.maxY()));

    m_location = newLocation;
    m_size = newMaxPoint - newLocation;
}