Delete an assortment of unneeded paint invalidation code.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/845093002
This commit is contained in:
Ojan Vafai 2015-01-09 18:31:26 -08:00
parent b7336cd862
commit a794eb951d
19 changed files with 3 additions and 239 deletions

View File

@ -61,13 +61,10 @@ bool DragCaretController::isContentRichlyEditable() const
void DragCaretController::setCaretPosition(const VisiblePosition& position)
{
if (Node* node = m_position.deepEquivalent().deprecatedNode())
invalidateCaretRect(node);
m_position = position;
setCaretRectNeedsUpdate();
Document* document = 0;
if (Node* node = m_position.deepEquivalent().deprecatedNode()) {
invalidateCaretRect(node);
document = &node->document();
}
if (m_position.isNull() || m_position.isOrphan()) {
@ -184,42 +181,6 @@ IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect
return caretPainter->localToAbsoluteQuad(FloatRect(rect)).enclosingBoundingBox();
}
void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect)
{
RenderBlock* caretPainter = caretRenderer(node);
if (!caretPainter)
return;
// FIXME: Need to over-paint 1 pixel to workaround some rounding problems.
// https://bugs.webkit.org/show_bug.cgi?id=108283
LayoutRect inflatedRect = rect;
inflatedRect.inflate(1);
caretPainter->invalidatePaintRectangle(inflatedRect);
}
void CaretBase::invalidateCaretRect(Node* node, bool caretRectChanged)
{
// EDIT FIXME: This is an unfortunate hack.
// Basically, we can't trust this layout position since we
// can't guarantee that the check to see if we are in unrendered
// content will work at this point. We may have to wait for
// a layout and re-render of the document to happen. So, resetting this
// flag will cause another caret layout to happen the first time
// that we try to paint the caret after this call. That one will work since
// it happens after the document has accounted for any editing
// changes which may have been done.
// And, we need to leave this layout here so the caret moves right
// away after clicking.
m_caretRectNeedsUpdate = true;
if (caretRectChanged)
return;
if (node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable))
invalidateLocalCaretRect(node, localCaretRectWithoutUpdate());
}
void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& clipRect) const
{
if (m_caretVisibility == Hidden)

View File

@ -46,7 +46,6 @@ protected:
enum CaretVisibility { Visible, Hidden };
explicit CaretBase(CaretVisibility = Hidden);
void invalidateCaretRect(Node*, bool caretRectChanged = false);
void clearCaretRect();
// Creating VisiblePosition causes synchronous layout so we should use the
// PositionWithAffinity version if possible.
@ -67,7 +66,6 @@ protected:
protected:
static RenderBlock* caretRenderer(Node*);
static void invalidateLocalCaretRect(Node*, const LayoutRect&);
private:
LayoutRect m_caretLocalRect; // caret rect in coords local to the renderer responsible for painting the caret

View File

@ -83,7 +83,6 @@ FrameSelection::FrameSelection(LocalFrame* frame)
, m_observingVisibleSelection(false)
, m_granularity(CharacterGranularity)
, m_caretBlinkTimer(this, &FrameSelection::caretBlinkTimerFired)
, m_caretRectDirty(true)
, m_shouldPaintCaret(true)
, m_isCaretBlinkingSuspended(false)
, m_focused(frame && frame->page() && frame->page()->focusController().focusedFrame() == frame)
@ -1156,7 +1155,6 @@ void FrameSelection::prepareForDestruction()
view->clearSelection();
setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdateAppearance);
m_previousCaretNode.clear();
}
void FrameSelection::setStart(const VisiblePosition &pos, EUserTriggered trigger)
@ -1209,37 +1207,6 @@ IntRect FrameSelection::absoluteCaretBounds()
return absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), localCaretRectWithoutUpdate());
}
static LayoutRect localCaretRect(const VisibleSelection& m_selection, const PositionWithAffinity& caretPosition, RenderObject*& renderer)
{
renderer = nullptr;
if (!isNonOrphanedCaret(m_selection))
return LayoutRect();
return localCaretRectOfPosition(caretPosition, renderer);
}
void FrameSelection::invalidateCaretRect()
{
if (!m_caretRectDirty)
return;
m_caretRectDirty = false;
RenderObject* renderer = nullptr;
LayoutRect newRect = localCaretRect(m_selection, PositionWithAffinity(m_selection.start(), m_selection.affinity()), renderer);
Node* newNode = renderer ? renderer->node() : nullptr;
if (!m_caretBlinkTimer.isActive() && newNode == m_previousCaretNode && newRect == m_previousCaretRect)
return;
if (m_previousCaretNode && m_previousCaretNode->isContentEditable())
invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect);
if (newNode && newNode->isContentEditable())
invalidateLocalCaretRect(newNode, newRect);
m_previousCaretNode = newNode;
m_previousCaretRect = newRect;
}
void FrameSelection::paintCaret(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& clipRect)
{
if (m_selection.isCaret() && m_shouldPaintCaret) {
@ -1688,8 +1655,6 @@ void FrameSelection::showTreeForThis() const
void FrameSelection::setCaretRectNeedsUpdate()
{
m_caretRectDirty = true;
scheduleVisualUpdate();
}

View File

@ -167,10 +167,8 @@ public:
void updateAppearance(ResetCaretBlinkOption = None);
void setCaretVisible(bool caretIsVisible) { setCaretVisibility(caretIsVisible ? Visible : Hidden); }
bool isCaretBoundsDirty() const { return m_caretRectDirty; }
void setCaretRectNeedsUpdate();
void scheduleVisualUpdate() const;
void invalidateCaretRect();
void paintCaret(GraphicsContext*, const LayoutPoint&, const LayoutRect& clipRect);
bool ShouldPaintCaretForTesting() const { return m_shouldPaintCaret; }
@ -268,14 +266,10 @@ private:
// become null, in which case logical positions == visible positions.
RefPtr<Range> m_logicalRange;
RefPtr<Node> m_previousCaretNode; // The last node which painted the caret. Retained for clearing the old caret when it moves.
LayoutRect m_previousCaretRect;
RefPtr<EditingStyle> m_typingStyle;
Timer<FrameSelection> m_caretBlinkTimer;
bool m_caretRectDirty : 1;
bool m_shouldPaintCaret : 1;
bool m_isCaretBlinkingSuspended : 1;
bool m_focused : 1;

View File

@ -407,8 +407,6 @@ void FrameView::invalidateTreeIfNeeded()
RenderView& rootForPaintInvalidation = *renderView();
ASSERT(!rootForPaintInvalidation.needsLayout());
TRACE_EVENT1("blink", "FrameView::invalidateTree", "root", rootForPaintInvalidation.debugName().ascii().data());
PaintInvalidationState rootPaintInvalidationState(rootForPaintInvalidation);
rootForPaintInvalidation.invalidateTreeIfNeeded(rootPaintInvalidationState);
@ -418,9 +416,6 @@ void FrameView::invalidateTreeIfNeeded()
renderView()->assertSubtreeClearedPaintInvalidationState();
#endif
if (m_frame->selection().isCaretBoundsDirty())
m_frame->selection().invalidateCaretRect();
lifecycle().advanceTo(DocumentLifecycle::PaintInvalidationClean);
}
@ -472,20 +467,6 @@ HostWindow* FrameView::hostWindow() const
return &page->chrome();
}
void FrameView::contentRectangleForPaintInvalidation(const IntRect& r)
{
ASSERT(paintInvalidationIsAllowed());
IntRect paintRect = r;
if (clipsPaintInvalidations() && !paintsEntireContents())
paintRect.intersect(visibleContentRect());
if (paintRect.isEmpty())
return;
if (HostWindow* window = hostWindow())
window->invalidateContentsAndRootView(contentsToWindow(paintRect));
}
void FrameView::contentsResized()
{
setNeedsLayout();

View File

@ -224,7 +224,6 @@ private:
DocumentLifecycle& lifecycle() const;
// FIXME(sky): Remove now that we're not a ScrollView?
void contentRectangleForPaintInvalidation(const IntRect&);
void contentsResized();
bool wasViewportResized();

View File

@ -200,10 +200,6 @@ void HTMLCanvasElement::didFinalizeFrame()
// before restarting with a blank dirty rect.
FloatRect srcRect(0, 0, size().width(), size().height());
m_dirtyRect.intersect(srcRect);
if (RenderBox* ro = renderBox()) {
FloatRect mappedDirtyRect = mapRect(m_dirtyRect, srcRect, ro->contentBoxRect());
ro->invalidatePaintRectangle(enclosingIntRect(mappedDirtyRect));
}
notifyObserversCanvasChanged(m_dirtyRect);
m_finalizeFrameTask.Cancel();
m_dirtyRect = FloatRect();

View File

@ -235,37 +235,6 @@ void RenderBlock::invalidateTreeIfNeeded(const PaintInvalidationState& paintInva
PaintInvalidationState childPaintInvalidationState(paintInvalidationState, *this, newPaintInvalidationContainer);
for (TrackedRendererListHashSet::iterator it = positionedObjects->begin(); it != end; ++it) {
RenderBox* box = *it;
// One of the renderers we're skipping over here may be the child's paint invalidation container,
// so we can't pass our own paint invalidation container along.
const RenderLayerModelObject& paintInvalidationContainerForChild = *box->containerForPaintInvalidation();
// If it's a new paint invalidation container, we won't have properly accumulated the offset into the
// PaintInvalidationState.
// FIXME: Teach PaintInvalidationState to handle this case. crbug.com/371485
if (&paintInvalidationContainerForChild != newPaintInvalidationContainer) {
ForceHorriblySlowRectMapping slowRectMapping(&childPaintInvalidationState);
PaintInvalidationState disabledPaintInvalidationState(childPaintInvalidationState, *this, paintInvalidationContainerForChild);
box->invalidateTreeIfNeeded(disabledPaintInvalidationState);
continue;
}
// If the positioned renderer is absolutely positioned and it is inside
// a relatively positioned inline element, we need to account for
// the inline elements position in PaintInvalidationState.
if (box->style()->position() == AbsolutePosition) {
RenderObject* container = box->container(&paintInvalidationContainerForChild, 0);
if (container->isRelPositioned() && container->isRenderInline()) {
// FIXME: We should be able to use PaintInvalidationState for this.
// Currently, we will place absolutely positioned elements inside
// relatively positioned inline blocks in the wrong location. crbug.com/371485
ForceHorriblySlowRectMapping slowRectMapping(&childPaintInvalidationState);
PaintInvalidationState disabledPaintInvalidationState(childPaintInvalidationState, *this, paintInvalidationContainerForChild);
box->invalidateTreeIfNeeded(disabledPaintInvalidationState);
continue;
}
}
box->invalidateTreeIfNeeded(childPaintInvalidationState);
}
}

View File

@ -204,6 +204,8 @@ public:
bool recalcChildOverflowAfterStyleChange();
bool recalcOverflowAfterStyleChange();
virtual void invalidateTreeIfNeeded(const PaintInvalidationState&) override;
protected:
virtual void willBeDestroyed() override;
@ -269,8 +271,6 @@ protected:
virtual bool isInlineBlock() const override final { return isInline() && isReplaced(); }
virtual void invalidateTreeIfNeeded(const PaintInvalidationState&) override;
virtual void paintContents(PaintInfo&, const LayoutPoint&);
virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);

View File

@ -165,23 +165,6 @@ void RenderImage::paintInvalidationOrMarkForLayout(const IntRect* rect)
// early. It may be that layout hasn't even taken place once yet.
updateInnerContentRect();
}
LayoutRect paintInvalidationRect;
if (rect) {
// The image changed rect is in source image coordinates,
// so map from the bounds of the image to the contentsBox.
paintInvalidationRect = enclosingIntRect(mapRect(*rect, FloatRect(FloatPoint(), m_imageResource->imageSize()), contentBoxRect()));
// Guard against too-large changed rects.
paintInvalidationRect.intersect(contentBoxRect());
} else {
paintInvalidationRect = contentBoxRect();
}
{
// FIXME: We should not be allowing paint invalidations during layout. crbug.com/339584
AllowPaintInvalidationScope scoper(frameView());
invalidatePaintRectangle(paintInvalidationRect);
}
}
void RenderImage::notifyFinished(Resource* newImage)

View File

@ -1660,26 +1660,6 @@ void RenderLayer::clearBlockSelectionGapsBounds()
child->clearBlockSelectionGapsBounds();
}
void RenderLayer::invalidatePaintForBlockSelectionGaps()
{
for (RenderLayer* child = firstChild(); child; child = child->nextSibling())
child->invalidatePaintForBlockSelectionGaps();
if (m_blockSelectionGapsBounds.isEmpty())
return;
LayoutRect rect = m_blockSelectionGapsBounds;
if (renderer()->hasOverflowClip()) {
RenderBox* box = renderBox();
rect.move(-box->scrolledContentOffset());
rect.intersect(box->overflowClipRect(LayoutPoint()));
}
if (renderer()->hasClip())
rect.intersect(toRenderBox(renderer())->clipRect(LayoutPoint()));
if (!rect.isEmpty())
renderer()->invalidatePaintRectangle(rect);
}
IntRect RenderLayer::blockSelectionGapsBounds() const
{
if (!renderer()->isRenderBlock())

View File

@ -128,7 +128,6 @@ public:
void addBlockSelectionGapsBounds(const LayoutRect&);
void clearBlockSelectionGapsBounds();
void invalidatePaintForBlockSelectionGaps();
IntRect blockSelectionGapsBounds() const;
RenderLayerStackingNode* stackingNode() { return m_stackingNode.get(); }

View File

@ -106,6 +106,7 @@ HostWindow* RenderLayerScrollableArea::hostWindow() const
return nullptr;
}
// FIXME(sky): Remove
void RenderLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
{
IntRect scrollRect = rect;
@ -125,8 +126,6 @@ void RenderLayerScrollableArea::invalidateScrollbarRect(Scrollbar* scrollbar, co
if (box().frameView()->isInPerformLayout())
addScrollbarDamage(scrollbar, intRect);
else
box().invalidatePaintRectangle(intRect);
}
bool RenderLayerScrollableArea::isActive() const

View File

@ -1230,11 +1230,6 @@ LayoutRect RenderObject::boundsRectForPaintInvalidation(const RenderLayerModelOb
return RenderLayer::computePaintInvalidationRect(this, paintInvalidationContainer->layer(), paintInvalidationState);
}
// FIXME(sky): Remove
void RenderObject::invalidatePaintRectangle(const LayoutRect& r) const
{
}
IntRect RenderObject::pixelSnappedAbsoluteClippedOverflowRect() const
{
return pixelSnappedIntRect(absoluteClippedOverflowRect());
@ -1255,11 +1250,6 @@ void RenderObject::invalidateTreeIfNeeded(const PaintInvalidationState& paintInv
}
}
bool RenderObject::checkForPaintInvalidation() const
{
return !document().view()->needsFullPaintInvalidation() && everHadLayout();
}
LayoutRect RenderObject::rectWithOutlineForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvalidationState* paintInvalidationState) const
{
LayoutRect r(clippedOverflowRectForPaintInvalidation(paintInvalidationContainer, paintInvalidationState));

View File

@ -614,14 +614,9 @@ public:
// Returns the rect bounds needed to invalidate the paint of this object, in the coordinate space of the rendering backing of |paintInvalidationContainer|
LayoutRect boundsRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const;
// Invalidate the paint of a specific subrectangle within a given object. The rect |r| is in the object's coordinate space.
void invalidatePaintRectangle(const LayoutRect&) const;
// Walk the tree after layout issuing paint invalidations for renderers that have changed or moved, updating bounds that have changed, and clearing paint invalidation state.
virtual void invalidateTreeIfNeeded(const PaintInvalidationState&);
bool checkForPaintInvalidation() const;
// Returns the rect that should have paint invalidated whenever this object changes. The rect is in the view's
// coordinate space. This method deals with outlines and overflow.
LayoutRect absoluteClippedOverflowRect() const;

View File

@ -735,7 +735,6 @@ void RenderParagraph::layoutRunsAndFloats(LineLayoutState& layoutState)
layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineBidiStatus);
linkToEndLineIfNeeded(layoutState);
markDirtyFloatsForPaintInvalidation(layoutState.floats());
}
void RenderParagraph::layoutRunsAndFloatsInRange(LineLayoutState& layoutState,
@ -853,22 +852,6 @@ void RenderParagraph::linkToEndLineIfNeeded(LineLayoutState& layoutState)
}
}
void RenderParagraph::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats)
{
size_t floatCount = floats.size();
// Floats that did not have layout did not paint invalidations when we laid them out. They would have
// painted by now if they had moved, but if they stayed at (0, 0), they still need to be
// painted.
for (size_t i = 0; i < floatCount; ++i) {
if (!floats[i].everHadLayout) {
RenderBox* f = floats[i].object;
if (!f->x() && !f->y() && f->checkForPaintInvalidation()) {
f->setShouldDoFullPaintInvalidation(true);
}
}
}
}
struct InlineMinMaxIterator {
/* InlineMinMaxIterator is a class that will iterate over all render objects that contribute to
inline min/max width calculations. Note the following about the way it walks:

View File

@ -62,7 +62,6 @@ private:
void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&,
const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus);
void linkToEndLineIfNeeded(LineLayoutState&);
static void markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats);
void checkFloatsInCleanLine(RootInlineBox*, Vector<FloatWithRect>&, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByFloat);
RootInlineBox* determineStartPosition(LineLayoutState&, InlineBidiResolver&);
void determineEndPosition(LineLayoutState&, RootInlineBox* startBox, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus);

View File

@ -275,28 +275,6 @@ void RenderView::paintBoxDecorationBackground(PaintInfo& paintInfo, const Layout
}
}
void RenderView::invalidateTreeIfNeeded(const PaintInvalidationState& paintInvalidationState)
{
ASSERT(!needsLayout());
// We specifically need to issue paint invalidations for the viewRect since other renderers
// short-circuit on full-paint invalidation.
LayoutRect dirtyRect = viewRect();
if (doingFullPaintInvalidation() && !dirtyRect.isEmpty()) {
const RenderLayerModelObject* paintInvalidationContainer = &paintInvalidationState.paintInvalidationContainer();
mapRectToPaintInvalidationBacking(paintInvalidationContainer, dirtyRect, &paintInvalidationState);
}
RenderBlock::invalidateTreeIfNeeded(paintInvalidationState);
}
void RenderView::invalidatePaintForRectangle(const LayoutRect& paintInvalidationRect) const
{
ASSERT(!paintInvalidationRect.isEmpty());
if (m_frameView)
m_frameView->contentRectangleForPaintInvalidation(pixelSnappedIntRect(paintInvalidationRect));
}
void RenderView::mapRectToPaintInvalidationBacking(const RenderLayerModelObject* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* state) const
{
// Apply our transform if we have one (because of full page zooming).
@ -304,7 +282,6 @@ void RenderView::mapRectToPaintInvalidationBacking(const RenderLayerModelObject*
rect = layer()->transform()->mapRect(rect);
}
void RenderView::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
{
rects.append(pixelSnappedIntRect(accumulatedOffset, layer()->size()));
@ -551,7 +528,6 @@ void RenderView::getSelection(RenderObject*& startRenderer, int& startOffset, Re
void RenderView::clearSelection()
{
layer()->invalidatePaintForBlockSelectionGaps();
setSelection(0, -1, 0, -1, PaintInvalidationNewMinusOld);
}

View File

@ -75,8 +75,6 @@ public:
virtual void mapRectToPaintInvalidationBacking(const RenderLayerModelObject* paintInvalidationContainer, LayoutRect&, const PaintInvalidationState*) const override;
void invalidatePaintForRectangle(const LayoutRect&) const;
virtual void paint(PaintInfo&, const LayoutPoint&) override;
virtual void paintBoxDecorationBackground(PaintInfo&, const LayoutPoint&) override;
@ -116,7 +114,6 @@ public:
void pushLayoutState(LayoutState&);
void popLayoutState();
virtual void invalidateTreeIfNeeded(const PaintInvalidationState&) override final;
void addIFrame(RenderIFrame* iframe);
void removeIFrame(RenderIFrame* iframe);