Source/WebCore:
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Jun 2016 19:48:26 +0000 (19:48 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Jun 2016 19:48:26 +0000 (19:48 +0000)
commit7be1f0eb820bcc4dfb669bf2c34083ea3f14a556
treeba69f2d4b385f3de50f9c9407bf54e3fffaabd9c
parent6290035bda37472103f8478b04349e09549549ce
Source/WebCore:
Find on page finds too many matches
https://bugs.webkit.org/show_bug.cgi?id=158395
rdar://problem/7440637

Reviewed by Dan Bernstein and Darin Adler.

There is a long standing bug where in some cases WebKit may find non-visible text matches when doing find on page.
For example searching patch review view in bugs.webkit.org returns twice as many matches as there actually are
on the page. This happens because the text content is replicated in an invisible subframe.

Fix by making TextIterator ignore content in non-visible subframes in findPlainText.

Test: editing/text-iterator/count-matches-in-frames.html

* editing/TextIterator.cpp:
(WebCore::nextInPreOrderCrossingShadowBoundaries):

    Remove support for an uninteresting assertion.

(WebCore::fullyClipsContents):

    Elements without renderer clip their content (except for display:contents).
    Test the content rect instead of the size rect for emptiness.

(WebCore::ignoresContainerClip):
(WebCore::pushFullyClippedState):
(WebCore::setUpFullyClippedStack):
(WebCore::isClippedByFrameAncestor):

    Test if the frame owner element is clipped in any of the parent frames.

(WebCore::TextIterator::TextIterator):

    If the frame is clipped by its ancestors the iterator is initialized to end state.
    Clipped frame never renders anything so there is no need to maintain clip stack and traverse.

(WebCore::findPlainText):

    Use TextIteratorClipsToFrameAncestors behavior. There might be other places where
    this behavior should be used (or perhaps it should be used always?) but limit this to
    text search for now.

(WebCore::depthCrossingShadowBoundaries): Deleted.
* editing/TextIterator.h:
* editing/TextIteratorBehavior.h:

    Add TextIteratorClipsToFrameAncestors behavior.

* testing/Internals.cpp:
(WebCore::Internals::countMatchesForText):
(WebCore::Internals::countFindMatches):
(WebCore::Internals::numberOfLiveNodes):
* testing/Internals.h:
* testing/Internals.idl:

    Testing support

LayoutTests:
TextIterator should ignore non-visible frames in findPlainText
https://bugs.webkit.org/show_bug.cgi?id=158395

Reviewed by Dan Bernstein and Darin Adler.

* editing/text-iterator/count-matches-in-frames-expected.txt: Added.
* editing/text-iterator/count-matches-in-frames.html: Added.
* imported/blink/fast/shapes/shape-outside-floats/shape-outside-negative-height-crash-width.html: Non-rendered whitespace change.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/text-iterator/count-matches-in-frames-expected.txt [new file with mode: 0644]
LayoutTests/editing/text-iterator/count-matches-in-frames.html [new file with mode: 0644]
LayoutTests/imported/blink/fast/shapes/shape-outside-floats/shape-outside-negative-height-crash-width-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/TextIteratorBehavior.h
Source/WebCore/rendering/RenderBox.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl