This source file includes following definitions.
- getRectToExpose
#include "config.h"
#include "core/rendering/ScrollAlignment.h"
#include "platform/geometry/LayoutRect.h"
namespace WebCore {
const ScrollAlignment ScrollAlignment::alignCenterIfNeeded = { ScrollAlignmentNoScroll, ScrollAlignmentCenter, ScrollAlignmentClosestEdge };
const ScrollAlignment ScrollAlignment::alignToEdgeIfNeeded = { ScrollAlignmentNoScroll, ScrollAlignmentClosestEdge, ScrollAlignmentClosestEdge };
const ScrollAlignment ScrollAlignment::alignCenterAlways = { ScrollAlignmentCenter, ScrollAlignmentCenter, ScrollAlignmentCenter };
const ScrollAlignment ScrollAlignment::alignTopAlways = { ScrollAlignmentTop, ScrollAlignmentTop, ScrollAlignmentTop };
const ScrollAlignment ScrollAlignment::alignBottomAlways = { ScrollAlignmentBottom, ScrollAlignmentBottom, ScrollAlignmentBottom };
#define MIN_INTERSECT_FOR_REVEAL 32
LayoutRect ScrollAlignment::getRectToExpose(const LayoutRect& visibleRect, const LayoutRect& exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& alignY)
{
ScrollAlignmentBehavior scrollX;
LayoutRect exposeRectX(exposeRect.x(), visibleRect.y(), exposeRect.width(), visibleRect.height());
LayoutUnit intersectWidth = intersection(visibleRect, exposeRectX).width();
if (intersectWidth == exposeRect.width() || intersectWidth >= MIN_INTERSECT_FOR_REVEAL) {
scrollX = getVisibleBehavior(alignX);
} else if (intersectWidth == visibleRect.width()) {
scrollX = getVisibleBehavior(alignX);
if (scrollX == ScrollAlignmentCenter)
scrollX = ScrollAlignmentNoScroll;
} else if (intersectWidth > 0) {
scrollX = getPartialBehavior(alignX);
} else {
scrollX = getHiddenBehavior(alignX);
}
if (scrollX == ScrollAlignmentClosestEdge) {
if ((exposeRect.maxX() > visibleRect.maxX() && exposeRect.width() < visibleRect.width())
|| (exposeRect.maxX() < visibleRect.maxX() && exposeRect.width() > visibleRect.width())) {
scrollX = ScrollAlignmentRight;
}
}
LayoutUnit x;
if (scrollX == ScrollAlignmentNoScroll)
x = visibleRect.x();
else if (scrollX == ScrollAlignmentRight)
x = exposeRect.maxX() - visibleRect.width();
else if (scrollX == ScrollAlignmentCenter)
x = exposeRect.x() + (exposeRect.width() - visibleRect.width()) / 2;
else
x = exposeRect.x();
ScrollAlignmentBehavior scrollY;
LayoutRect exposeRectY(visibleRect.x(), exposeRect.y(), visibleRect.width(), exposeRect.height());
LayoutUnit intersectHeight = intersection(visibleRect, exposeRectY).height();
if (intersectHeight == exposeRect.height()) {
scrollY = getVisibleBehavior(alignY);
} else if (intersectHeight == visibleRect.height()) {
scrollY = getVisibleBehavior(alignY);
if (scrollY == ScrollAlignmentCenter)
scrollY = ScrollAlignmentNoScroll;
} else if (intersectHeight > 0) {
scrollY = getPartialBehavior(alignY);
} else {
scrollY = getHiddenBehavior(alignY);
}
if (scrollY == ScrollAlignmentClosestEdge) {
if ((exposeRect.maxY() > visibleRect.maxY() && exposeRect.height() < visibleRect.height())
|| (exposeRect.maxY() < visibleRect.maxY() && exposeRect.height() > visibleRect.height())) {
scrollY = ScrollAlignmentBottom;
}
}
LayoutUnit y;
if (scrollY == ScrollAlignmentNoScroll)
y = visibleRect.y();
else if (scrollY == ScrollAlignmentBottom)
y = exposeRect.maxY() - visibleRect.height();
else if (scrollY == ScrollAlignmentCenter)
y = exposeRect.y() + (exposeRect.height() - visibleRect.height()) / 2;
else
y = exposeRect.y();
return LayoutRect(LayoutPoint(x, y), visibleRect.size());
}
};