本文整理汇总了C++中LayoutRect::contract方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutRect::contract方法的具体用法?C++ LayoutRect::contract怎么用?C++ LayoutRect::contract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutRect
的用法示例。
在下文中一共展示了LayoutRect::contract方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: elementRect
LayoutRect AccessibilityScrollView::elementRect() const
{
if (!m_scrollView)
return LayoutRect();
LayoutRect rect = m_scrollView->frameRect();
float topContentInset = m_scrollView->topContentInset();
// Top content inset pushes the frame down and shrinks it.
rect.move(0, topContentInset);
rect.contract(0, topContentInset);
return rect;
}
示例2: addRelevantRepaintedObject
void Page::addRelevantRepaintedObject(RenderObject* object, const LayoutRect& objectPaintRect)
{
if (!isCountingRelevantRepaintedObjects())
return;
// Objects inside sub-frames are not considered to be relevant.
if (object->document()->frame() != mainFrame())
return;
RenderView* view = object->view();
if (!view)
return;
LayoutRect relevantRect = relevantViewRect(view);
// The objects are only relevant if they are being painted within the viewRect().
if (!objectPaintRect.intersects(pixelSnappedIntRect(relevantRect)))
return;
IntRect snappedPaintRect = pixelSnappedIntRect(objectPaintRect);
// If this object was previously counted as an unpainted object, remove it from that HashSet
// and corresponding Region. FIXME: This doesn't do the right thing if the objects overlap.
HashSet<RenderObject*>::iterator it = m_relevantUnpaintedRenderObjects.find(object);
if (it != m_relevantUnpaintedRenderObjects.end()) {
m_relevantUnpaintedRenderObjects.remove(it);
m_relevantUnpaintedRegion.subtract(snappedPaintRect);
}
// Split the relevantRect into a top half and a bottom half. Making sure we have coverage in
// both halves helps to prevent cases where we have a fully loaded menu bar or masthead with
// no content beneath that.
LayoutRect topRelevantRect = relevantRect;
topRelevantRect.contract(LayoutSize(0, relevantRect.height() / 2));
LayoutRect bottomRelevantRect = topRelevantRect;
bottomRelevantRect.setY(relevantRect.height() / 2);
// If the rect straddles both Regions, split it appropriately.
if (topRelevantRect.intersects(snappedPaintRect) && bottomRelevantRect.intersects(snappedPaintRect)) {
IntRect topIntersection = snappedPaintRect;
topIntersection.intersect(pixelSnappedIntRect(topRelevantRect));
m_topRelevantPaintedRegion.unite(topIntersection);
IntRect bottomIntersection = snappedPaintRect;
bottomIntersection.intersect(pixelSnappedIntRect(bottomRelevantRect));
m_bottomRelevantPaintedRegion.unite(bottomIntersection);
} else if (topRelevantRect.intersects(snappedPaintRect))
m_topRelevantPaintedRegion.unite(snappedPaintRect);
else
m_bottomRelevantPaintedRegion.unite(snappedPaintRect);
float topPaintedArea = m_topRelevantPaintedRegion.totalArea();
float bottomPaintedArea = m_bottomRelevantPaintedRegion.totalArea();
float viewArea = relevantRect.width() * relevantRect.height();
float ratioThatIsPaintedOnTop = topPaintedArea / viewArea;
float ratioThatIsPaintedOnBottom = bottomPaintedArea / viewArea;
float ratioOfViewThatIsUnpainted = m_relevantUnpaintedRegion.totalArea() / viewArea;
if (ratioThatIsPaintedOnTop > (gMinimumPaintedAreaRatio / 2) && ratioThatIsPaintedOnBottom > (gMinimumPaintedAreaRatio / 2)
&& ratioOfViewThatIsUnpainted < gMaximumUnpaintedAreaRatio) {
m_isCountingRelevantRepaintedObjects = false;
resetRelevantPaintedObjectCounter();
if (Frame* frame = mainFrame())
frame->loader()->didLayout(DidHitRelevantRepaintedObjectsAreaThreshold);
}
}