WebCore: Fixed <rdar://problem/7437820> Weird selection artifacts
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Dec 2009 18:22:33 +0000 (18:22 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Dec 2009 18:22:33 +0000 (18:22 +0000)
commit4610ddb0fdedb5c2d3561ea1b90f814f98134b8a
treeab39aca2ae16747725860d3e59db502839af2f87
parente534e7ba607b70cedcbaf0ee67b1e8e7131ff220
WebCore: Fixed <rdar://problem/7437820> Weird selection artifacts

Reviewed by Darin Adler.

Tests: fast/repaint/block-selection-gap-stale-cache-2.html
       fast/repaint/block-selection-gap-stale-cache.html

Instead of caching the block selection gaps’ bounds in the RenderView at setSelection()
time, cache them in each RenderLayer at paint time. This prevents the cache from getting
stale due to layout changes and overflow scrolling.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::selectionGapRectsForRepaint): Account for overflow scroll.
(WebCore::RenderBlock::paintSelection): Update the enclosing layer’s selection gaps bounds.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::addBlockSelectionGapsBounds): Added. Updates the selection gaps
bounds to include the given rect.
(WebCore::RenderLayer::clearBlockSelectionGapsBounds): Added. Recursively clears the cached
selection gaps bounds.
(WebCore::RenderLayer::repaintBlockSelectionGaps): Added. Recursively invalidates the
selection gaps bounds.
* rendering/RenderLayer.h:
* rendering/RenderView.cpp:
(WebCore::RenderView::setSelection): Clear the layer-level selection gaps bounds instead
of the view-level cache.
(WebCore::RenderView::clearSelection): Changed to call repaintBlockSelectionGaps().
* rendering/RenderView.h:

LayoutTests: Tests for <rdar://problem/7437820> Weird selection artifacts

Reviewed by Darin Adler.

* fast/repaint/block-selection-gap-stale-cache-2.html: Added.
* fast/repaint/block-selection-gap-stale-cache.html: Added.
* platform/mac/fast/repaint/block-selection-gap-stale-cache-2-expected.checksum: Added.
* platform/mac/fast/repaint/block-selection-gap-stale-cache-2-expected.png: Added.
* platform/mac/fast/repaint/block-selection-gap-stale-cache-2-expected.txt: Added.
* platform/mac/fast/repaint/block-selection-gap-stale-cache-expected.checksum: Added.
* platform/mac/fast/repaint/block-selection-gap-stale-cache-expected.png: Added.
* platform/mac/fast/repaint/block-selection-gap-stale-cache-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51776 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/repaint/block-selection-gap-stale-cache-2.html [new file with mode: 0644]
LayoutTests/fast/repaint/block-selection-gap-stale-cache.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/repaint/block-selection-gap-stale-cache-2-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/repaint/block-selection-gap-stale-cache-2-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/repaint/block-selection-gap-stale-cache-2-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/repaint/block-selection-gap-stale-cache-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/repaint/block-selection-gap-stale-cache-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/repaint/block-selection-gap-stale-cache-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderBlock.cpp
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderLayer.h
WebCore/rendering/RenderView.cpp
WebCore/rendering/RenderView.h