LayoutRect rect1(0, 0, 100, 100); LayoutRect rect2(50, 50, 100, 100); LayoutRect intersectRect = rect1.intersect(rect2); // intersectRect now represents a rectangle with coordinates (50,50,50,50)
LayoutRect rect1(0, 0, 50, 50); LayoutRect rect2(100, 100, 50, 50); LayoutRect intersectRect = rect1.intersect(rect2); // intersectRect now represents an empty rectangleIn this example, rect1 and rect2 do not overlap, so their intersection is an empty rectangle. The LayoutRect class is part of the WebCore namespace in the WebKit package library.