|
|
Created:
7 years, 1 month ago by Andrey Kraynov Modified:
6 years, 11 months ago CC:
blink-reviews Base URL:
https://chromium.googlesource.com/chromium/blink.git@upload-review-4 Visibility:
Public. |
DescriptionIntroduce TextFinder class for decoupling WebFrameImpl and text finder.
It will be lazily initialized when user activates find on page functionality.
BUG=
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=164780
Patch Set 1 #
Total comments: 4
Patch Set 2 : Fix remarks in InFrameFinder.h #Patch Set 3 : TextFinder files only #
Total comments: 11
Patch Set 4 : TextFinder and WebFrameImpl files #
Total comments: 2
Patch Set 5 : Rename TextFinder::stopFinding to stopFindingAndClearSelection #Patch Set 6 : Rebase #Patch Set 7 : Rebase #
Messages
Total messages: 20 (0 generated)
This patch should be rebased after http://crrev.com/68263009 committed.
This patch should be simple renaming of code move rather than introducing new code. https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.cpp File Source/web/InFrameFinder.cpp (right): https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.cpp#... Source/web/InFrameFinder.cpp:85: InFrameFinder* m_finder; Should we use RefPtr<>? It isn't clear life time of InFrameFinder. How do we ensure InFrameFinder alive until timeout? https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.h File Source/web/InFrameFinder.h (right): https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.h#ne... Source/web/InFrameFinder.h:81: void increaseMarkerVersion() { m_findMatchMarkersVersion++; } nit: ++m_findMatchMarkersVersion to follow Chromium coding style. https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.h#ne... Source/web/InFrameFinder.h:100: virtual ~InFrameFinder(); We don't need to have |virtual|. I don't think we have derived class for InFrameFinder. https://codereview.chromium.org/69923006/diff/1/Source/web/WebFrameImpl.h File Source/web/WebFrameImpl.h (right): https://codereview.chromium.org/69923006/diff/1/Source/web/WebFrameImpl.h#new... Source/web/WebFrameImpl.h:312: friend class InFrameFinder; Which private member functions in WebFrameImpl does InFrameFinder call? Could you try to define API between WebFrameImpl and InFrameFinder?
On 2013/11/14 02:06:55, Yoshi wrote: > This patch should be simple renaming of code move rather than introducing new > code. Should I split this patch into two patches? One for InFrameFinder.{h,cpp} and one for changes in WebFrameImpl.{h,cpp}? > > https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.cpp > File Source/web/InFrameFinder.cpp (right): > > https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.cpp#... > Source/web/InFrameFinder.cpp:85: InFrameFinder* m_finder; > Should we use RefPtr<>? It isn't clear life time of InFrameFinder. How do we > ensure InFrameFinder alive until timeout? Lifetime of InFrameFinder should be the same as WebFrameImpl. When user stops text searching process or when InFrameFinder destroys, cancelPendingScopingEffort() is called. It deletes all active timers and destructor of TimerBase stops each timer. So as I understand, it can work without making InFrameFinder refcounted or without keeping reference to owner WebFrameImpl object. Correct me if I wrong. > > https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.h > File Source/web/InFrameFinder.h (right): > > https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.h#ne... > Source/web/InFrameFinder.h:81: void increaseMarkerVersion() { > m_findMatchMarkersVersion++; } > nit: ++m_findMatchMarkersVersion > to follow Chromium coding style. Done. > > https://codereview.chromium.org/69923006/diff/1/Source/web/InFrameFinder.h#ne... > Source/web/InFrameFinder.h:100: virtual ~InFrameFinder(); > We don't need to have |virtual|. I don't think we have derived class for > InFrameFinder. Done. > > https://codereview.chromium.org/69923006/diff/1/Source/web/WebFrameImpl.h > File Source/web/WebFrameImpl.h (right): > > https://codereview.chromium.org/69923006/diff/1/Source/web/WebFrameImpl.h#new... > Source/web/WebFrameImpl.h:312: friend class InFrameFinder; > Which private member functions in WebFrameImpl does InFrameFinder call? > Could you try to define API between WebFrameImpl and InFrameFinder? I tried to follow FrameLoaderClientImpl pattern, with the only difference that InFrameFinder is lazy initialized and stored as OwnPtr<InFrameFinder>. The most important functions of WebFrameImpl used by InFrameFinder are invalidateArea, invalidateIfNecessary and getOrCreateFinder. I can try to move calls to invalidate* functions back to WebFrameImpl and make getOrCreateFinder public for WebFrameImpl. This should allow me to remove friend declaration for InFrameFinder.
On 2013/11/26 10:28:53, iceman wrote: > On 2013/11/14 02:06:55, Yoshi wrote: > > This patch should be simple renaming of code move rather than introducing new > > code. > > Should I split this patch into two patches? > One for InFrameFinder.{h,cpp} and one for changes in WebFrameImpl.{h,cpp}? > Yes, please and wait for https://codereview.chromium.org/68263009/ (copying WebFrameImpl.{cpp,h} to TextFinder.{cpp,h}). It makes diffs small.
On 2013/11/27 01:57:52, Yoshi wrote: > On 2013/11/26 10:28:53, iceman wrote: > > On 2013/11/14 02:06:55, Yoshi wrote: > > > This patch should be simple renaming of code move rather than introducing > new > > > code. > > > > Should I split this patch into two patches? > > One for InFrameFinder.{h,cpp} and one for changes in WebFrameImpl.{h,cpp}? > > > Yes, please and wait for https://codereview.chromium.org/68263009/ (copying > WebFrameImpl.{cpp,h} to TextFinder.{cpp,h}). It makes diffs small. I have uploaded changes for TextFinder.{h,cpp} files only. Here is the second part of this patch with WebFrameImpl changes. https://codereview.chromium.org/108273003 Could you review this patch please?
Please update description. It is now |TextFinder| instead of |InFrameFinder|. I think you can have only one patch for introducing TextFinder and integrate into WebFrameImpl. We would like to see usage of |TextFinder|. https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.cpp File Source/web/TextFinder.cpp (right): https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.cp... Source/web/TextFinder.cpp:216: frame = m_ownerFrame->frame(); We don't need L216. |frame| is already initialized in L203. https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.cp... Source/web/TextFinder.cpp:752: m_framesScopingCount--; nit: We prefer prefix unary operator. https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h File Source/web/TextFinder.h (right): https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h#... Source/web/TextFinder.h:117: explicit TextFinder(WebFrameImpl* ownerFrame); nit: Can we pass reference rather than pointer? Since |ownerFrame| can't be null. See Node::document(), Frame::editor(), etc. https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h#... Source/web/TextFinder.h:197: WebFrameImpl* m_ownerFrame; Can we make |m_ownerFrame| as reference?
I have uploaded all changes for TextFinder and WebFrameImpl together. https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.cpp File Source/web/TextFinder.cpp (right): https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.cp... Source/web/TextFinder.cpp:216: frame = m_ownerFrame->frame(); On 2013/12/09 01:29:12, Yoshi wrote: > We don't need L216. |frame| is already initialized in L203. Fixed. https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.cp... Source/web/TextFinder.cpp:752: m_framesScopingCount--; On 2013/12/09 01:29:12, Yoshi wrote: > nit: We prefer prefix unary operator. Fixed. https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h File Source/web/TextFinder.h (right): https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h#... Source/web/TextFinder.h:117: explicit TextFinder(WebFrameImpl* ownerFrame); On 2013/12/09 01:29:12, Yoshi wrote: > nit: Can we pass reference rather than pointer? Since |ownerFrame| can't be > null. See Node::document(), Frame::editor(), etc. Sure we can. https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h#... Source/web/TextFinder.h:197: WebFrameImpl* m_ownerFrame; On 2013/12/09 01:29:12, Yoshi wrote: > Can we make |m_ownerFrame| as reference? Yes, definitely. This leads us to the code like 'activeFrame = &m_ownerFrame' in several lines, is it OK?
https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h File Source/web/TextFinder.h (right): https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h#... Source/web/TextFinder.h:196: // Owner frame nit: We don't need to have this comment. Variable name is self descriptive. https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h#... Source/web/TextFinder.h:197: WebFrameImpl* m_ownerFrame; On 2013/12/13 14:03:58, iceman wrote: > On 2013/12/09 01:29:12, Yoshi wrote: > > Can we make |m_ownerFrame| as reference? > > Yes, definitely. > This leads us to the code like 'activeFrame = &m_ownerFrame' in several lines, > is it OK? I think it is OK. Using m_ownerFrame is more often than taking pointer of m_ownerFrame. https://codereview.chromium.org/69923006/diff/120001/Source/web/TextFinder.cpp File Source/web/TextFinder.cpp (right): https://codereview.chromium.org/69923006/diff/120001/Source/web/TextFinder.cp... Source/web/TextFinder.cpp:176: void TextFinder::stopFinding(bool clearSelection) Please introduce split TextFinder::stopFinding() into two functions to avoid using bool parameter. 1 void stopFinding() 2 void stopFindingAndClearSelection() WebFrameImpl::stopFinding(bool) can be void WebFrameImpl::stopFinding(bool clearSelection) { if (cleareSelection) stopFindingAndClearSelection() else stopFinding() } Note: WebFrameImpl::stopFinding() is expose to Chromium. So, changing it requires Chromium side changes.
https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h File Source/web/TextFinder.h (right): https://codereview.chromium.org/69923006/diff/100001/Source/web/TextFinder.h#... Source/web/TextFinder.h:196: // Owner frame On 2013/12/16 03:51:04, Yoshi wrote: > nit: We don't need to have this comment. Variable name is self descriptive. Fixed. https://codereview.chromium.org/69923006/diff/120001/Source/web/TextFinder.cpp File Source/web/TextFinder.cpp (right): https://codereview.chromium.org/69923006/diff/120001/Source/web/TextFinder.cp... Source/web/TextFinder.cpp:176: void TextFinder::stopFinding(bool clearSelection) On 2013/12/16 03:51:04, Yoshi wrote: > Please introduce split TextFinder::stopFinding() into two functions to avoid > using bool parameter. > 1 void stopFinding() > 2 void stopFindingAndClearSelection() > > WebFrameImpl::stopFinding(bool) can be > void WebFrameImpl::stopFinding(bool clearSelection) { > if (cleareSelection) > stopFindingAndClearSelection() > else > stopFinding() > } > > Note: WebFrameImpl::stopFinding() is expose to Chromium. So, changing it > requires Chromium side changes. The |clearSelection| flag is used only in L178. If it is set to false then WebFrameImpl::setFindEndstateFocusAndSelection function is invoked. I've decided to move these lines L178-L179 with setFindEndstateFocusAndSelection call from TextFinder::stopFinding to WebFrameImpl::stopFinding and rename TextFinder::stopFinding to TextFinder::stopFindingAndClearSelection.
ACK Thanks! +tkent@ for OWNERS review.
TextFinder.{cpp,h} were removed because they were not used. Would you make a CL to copy WebFrameImpl to TextFinder again please? This CL looses revision history without the copy.
On 2013/12/19 01:07:02, tkent wrote: > TextFinder.{cpp,h} were removed because they were not used. > Would you make a CL to copy WebFrameImpl to TextFinder again please? > This CL looses revision history without the copy. OK, here it is - https://codereview.chromium.org/119113003/ eseidel@ recommended me to use a BUG field for CLs like this. Should I do it for these two patches? Also I have rebased this patch to be sure that it can be applied. I did some little style-related changes.
On 2013/12/19 17:28:55, iceman wrote: > eseidel@ recommended me to use a BUG field for CLs like this. > Should I do it for these two patches? Yeah, it's recommended.
The approach before was fine. It just took too long. There was a whole file of dead code lying around. Once we move to git the copy/move problem will go away. BUt until then it is nice to use svn cp before doing splits like this.
lgtm
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/iceman@yandex-team.ru/69923006/160001
Failed to apply patch for Source/web/TextFinder.cpp: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file Source/web/TextFinder.cpp Hunk #1 FAILED at 28. Hunk #2 succeeded at 1523 (offset -5 lines). Hunk #3 succeeded at 1540 (offset -5 lines). Hunk #4 succeeded at 1548 (offset -5 lines). Hunk #5 succeeded at 1573 (offset -5 lines). Hunk #6 succeeded at 1583 (offset -5 lines). Hunk #7 succeeded at 1602 (offset -5 lines). Hunk #8 succeeded at 1620 (offset -5 lines). Hunk #9 succeeded at 1634 (offset -5 lines). Hunk #10 succeeded at 1665 (offset -5 lines). Hunk #11 succeeded at 1674 (offset -5 lines). Hunk #12 succeeded at 1702 (offset -5 lines). Hunk #13 succeeded at 1729 (offset -5 lines). Hunk #14 succeeded at 1749 (offset -5 lines). Hunk #15 succeeded at 1763 (offset -5 lines). Hunk #16 succeeded at 1791 (offset -5 lines). Hunk #17 succeeded at 1831 (offset -5 lines). Hunk #18 succeeded at 1874 (offset -5 lines). Hunk #19 succeeded at 1917 (offset -5 lines). Hunk #20 FAILED at 1931. Hunk #21 succeeded at 2329 (offset -20 lines). Hunk #22 succeeded at 2381 (offset -20 lines). Hunk #23 succeeded at 2395 (offset -20 lines). Hunk #24 FAILED at 2435. 3 out of 24 hunks FAILED -- saving rejects to file Source/web/TextFinder.cpp.rej Patch: Source/web/TextFinder.cpp Index: Source/web/TextFinder.cpp diff --git a/Source/web/TextFinder.cpp b/Source/web/TextFinder.cpp index b49c4d637f269781255e44a355c6ab77b549b745..10a454b412f6273f8ac65783adc21fdb57af336f 100644 --- a/Source/web/TextFinder.cpp +++ b/Source/web/TextFinder.cpp @@ -28,1499 +28,119 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// How ownership works -// ------------------- -// -// Big oh represents a refcounted relationship: owner O--- ownee -// -// WebView (for the toplevel frame only) -// O -// | -// Page O------- Frame (m_mainFrame) O-------O FrameView -// || -// || -// FrameLoader O-------- WebFrame (via FrameLoaderClient) -// -// FrameLoader and Frame are formerly one object that was split apart because -// it got too big. They basically have the same lifetime, hence the double line. -// -// WebFrame is refcounted and has one ref on behalf of the FrameLoader/Frame. -// This is not a normal reference counted pointer because that would require -// changing WebKit code that we don't control. Instead, it is created with this -// ref initially and it is removed when the FrameLoader is getting destroyed. -// -// WebFrames are created in two places, first in WebViewImpl when the root -// frame is created, and second in WebFrame::createChildFrame when sub-frames -// are created. WebKit will hook up this object to the FrameLoader/Frame -// and the refcount will be correct. -// -// How frames are destroyed -// ------------------------ -// -// The main frame is never destroyed and is re-used. The FrameLoader is re-used -// and a reference to the main frame is kept by the Page. -// -// When frame content is replaced, all subframes are destroyed. This happens -// in FrameLoader::detachFromParent for each subframe. -// -// Frame going away causes the FrameLoader to get deleted. In FrameLoader's -// destructor, it notifies its client with frameLoaderDestroyed. This derefs -// the WebFrame and will cause it to be deleted (unless an external someone -// is also holding a reference). -// -// Thie client is expected to be set whenever the WebFrameImpl is attached to -// the DOM. - -#include "config.h" -#include "TextFinder.h" - -#include <algorithm> -#include "AssociatedURLLoader.h" -#include "DOMUtilitiesPrivate.h" -#include "EventListenerWrapper.h" -#include "FindInPageCoordinates.h" -#include "HTMLNames.h" -#include "PageOverlay.h" -#include "SharedWorkerRepositoryClientImpl.h" -#include "V8DOMFileSystem.h" -#include "V8DirectoryEntry.h" -#include "V8FileEntry.h" -#include "WebConsoleMessage.h" -#include "WebDOMEvent.h" -#include "WebDOMEventListener.h" -#include "WebDataSourceImpl.h" -#include "WebDevToolsAgentPrivate.h" -#include "WebDocument.h" -#include "WebFindOptions.h" -#include "WebFormElement.h" -#include "WebFrameClient.h" -#include "WebHistoryItem.h" -#include "WebIconURL.h" -#include "WebInputElement.h" -#include "WebNode.h" -#include "WebPerformance.h" -#include "WebPlugin.h" -#include "WebPluginContainerImpl.h" -#include "WebPrintParams.h" -#include "WebRange.h" -#include "WebScriptSource.h" -#include "WebSecurityOrigin.h" -#include "WebSerializedScriptValue.h" -#include "WebViewImpl.h" -#include "bindings/v8/DOMWrapperWorld.h" -#include "bindings/v8/ExceptionState.h" -#include "bindings/v8/ExceptionStatePlaceholder.h" -#include "bindings/v8/ScriptController.h" -#include "bindings/v8/ScriptSourceCode.h" -#include "bindings/v8/ScriptValue.h" -#include "bindings/v8/V8GCController.h" -#include "core/dom/Document.h" -#include "core/dom/DocumentMarker.h" -#include "core/dom/DocumentMarkerController.h" -#include "core/dom/IconURL.h" -#include "core/dom/MessagePort.h" -#include "core/dom/Node.h" -#include "core/dom/NodeTraversal.h" -#include "core/dom/shadow/ShadowRoot.h" -#include "core/editing/Editor.h" -#include "core/editing/FrameSelection.h" -#include "core/editing/InputMethodController.h" -#include "core/editing/PlainTextRange.h" -#include "core/editing/SpellChecker.h" -#include "core/editing/TextAffinity.h" -#include "core/editing/TextIterator.h" -#include "core/editing/htmlediting.h" -#include "core/editing/markup.h" -#include "core/frame/Console.h" -#include "core/frame/DOMWindow.h" -#include "core/frame/FrameView.h" -#include "core/history/HistoryItem.h" -#include "core/html/HTMLCollection.h" -#include "core/html/HTMLFormElement.h" -#include "core/html/HTMLFrameOwnerElement.h" -#include "core/html/HTMLHeadElement.h" -#include "core/html/HTMLInputElement.h" -#include "core/html/HTMLLinkElement.h" -#include "core/html/HTMLTextAreaElement.h" -#include "core/html/PluginDocument.h" -#include "core/inspector/InspectorController.h" -#include "core/inspector/ScriptCallStack.h" -#include "core/loader/DocumentLoader.h" -#include "core/loader/FormState.h" -#include "core/loader/FrameLoadRequest.h" -#include "core/loader/FrameLoader.h" -#include "core/loader/SubstituteData.h" -#include "core/page/Chrome.h" -#include "core/page/EventHandler.h" -#include "core/page/FocusController.h" -#include "core/page/FrameTree.h" -#include "core/page/Page.h" -#include "core/page/PrintContext.h" -#include "core/frame/Settings.h" -#include "core/rendering/HitTestResult.h" -#include "core/rendering/RenderBox.h" -#include "core/rendering/RenderFrame.h" -#include "core/rendering/RenderLayer.h" -#include "core/rendering/RenderObject.h" -#include "core/rendering/RenderTreeAsText.h" -#include "core/rendering/RenderView.h" -#include "core/rendering/style/StyleInheritedData.h" -#include "core/timing/Performance.h" -#include "core/xml/DocumentXPathEvaluator.h" -#include "core/xml/XPathResult.h" -#include "modules/filesystem/DOMFileSystem.h" -#include "modules/filesystem/DirectoryEntry.h" -#include "modules/filesystem/FileEntry.h" -#include "platform/FileSystemType.h" -#include "platform/TraceEvent.h" -#include "platform/UserGestureIndicator.h" -#include "platform/clipboard/ClipboardUtilities.h" -#include "platform/fonts/FontCache.h" -#include "platform/graphics/GraphicsContext.h" -#include "platform/graphics/GraphicsLayerClient.h" -#include "platform/graphics/skia/SkiaUtils.h" -#include "platform/network/ResourceRequest.h" -#include "platform/scroll/ScrollbarTheme.h" -#include "platform/scroll/ScrollTypes.h" -#include "platform/weborigin/KURL.h" -#include "platform/weborigin/SchemeRegistry.h" -#include "platform/weborigin/SecurityPolicy.h" -#include "public/platform/Platform.h" -#include "public/platform/WebFileSystem.h" -#include "public/platform/WebFloatPoint.h" -#include "public/platform/WebFloatRect.h" -#include "public/platform/WebLayer.h" -#include "public/platform/WebPoint.h" -#include "public/platform/WebRect.h" -#include "public/platform/WebSize.h" -#include "public/platform/WebURLError.h" -#include "public/platform/WebVector.h" -#include "wtf/CurrentTime.h" -#include "wtf/HashMap.h" - -using namespace WebCore; - -namespace blink { - -static int frameCount = 0; - -// Key for a StatsCounter tracking how many WebFrames are active. -static const char webFrameActiveCount[] = "WebFrameActiveCount"; - -static void frameContentAsPlainText(size_t maxChars, Frame* frame, StringBuilder& output) -{ - Document* document = frame->document(); - if (!document) - return; - - if (!frame->view()) - return; - - // TextIterator iterates over the visual representation of the DOM. As such, - // it requires you to do a layout before using it (otherwise it'll crash). - document->updateLayout(); - - // Select the document body. - RefPtr<Range> range(document->createRange()); - TrackExceptionState exceptionState; - range->selectNodeContents(document->body(), exceptionState); - - if (!exceptionState.hadException()) { - // The text iterator will walk nodes giving us text. This is similar to - // the plainText() function in core/editing/TextIterator.h, but we implement the maximum - // size and also copy the results directly into a wstring, avoiding the - // string conversion. - for (TextIterator it(range.get()); !it.atEnd(); it.advance()) { - it.appendTextToStringBuilder(output, 0, maxChars - output.length()); - if (output.length() >= maxChars) - return; // Filled up the buffer. - } - } - - // The separator between frames when the frames are converted to plain text. - const LChar frameSeparator[] = { '\n', '\n' }; - const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator); - - // Recursively walk the children. - const FrameTree& frameTree = frame->tree(… (message too large)
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/iceman@yandex-team.ru/69923006/220001
Message was sent while issue was closed.
Change committed as 164780
Message was sent while issue was closed.
A revert of this CL has been created in https://codereview.chromium.org/131063003/ by alph@chromium.org. The reason for reverting is: Probably the cause of FindInPageTest.FocusRestore interactive_ui_tests failure http://build.chromium.org/p/chromium.webkit/builders/Win7%20%28dbg%29/builds/... . |