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; }
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); } }