diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-06 20:21:59 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-06 20:21:59 +0000 |
commit | 7ea066a9c3e54b7a2fd0c2ac30c8f4a64cf8eb90 (patch) | |
tree | 2f283b622f4ee681e05e7e6119903146f6f4d1ea /webkit | |
parent | d2515f6e52f42d4baaa3c676ba1370ffa1f263eb (diff) | |
download | chromium_src-7ea066a9c3e54b7a2fd0c2ac30c8f4a64cf8eb90.zip chromium_src-7ea066a9c3e54b7a2fd0c2ac30c8f4a64cf8eb90.tar.gz chromium_src-7ea066a9c3e54b7a2fd0c2ac30c8f4a64cf8eb90.tar.bz2 |
Stop serializing WebString over IPC. The new rule is that only POD (plain old
data) types from WebKit API are allowed to be used in the browser process.
I added a big note about this to webkit_param_traits.h to explain the details
of this decision.
R=dglazkov
Review URL: http://codereview.chromium.org/62032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13181 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/build/WebKit/WebKit.vcproj | 2 | ||||
-rw-r--r-- | webkit/glue/webframe.h | 10 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 64 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.h | 12 | ||||
-rw-r--r-- | webkit/webkit.gyp | 2 |
5 files changed, 53 insertions, 37 deletions
diff --git a/webkit/build/WebKit/WebKit.vcproj b/webkit/build/WebKit/WebKit.vcproj index b225b74..0d7f6fd 100644 --- a/webkit/build/WebKit/WebKit.vcproj +++ b/webkit/build/WebKit/WebKit.vcproj @@ -156,7 +156,7 @@ > </File> <File - RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\public\WebFindInPageRequest.h" + RelativePath="..\..\..\third_party\WebKit\WebKit\chromium\public\WebFindOptions.h" > </File> <File diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h index 93f5698d..23b12c5 100644 --- a/webkit/glue/webframe.h +++ b/webkit/glue/webframe.h @@ -25,7 +25,7 @@ class Size; namespace WebKit { struct WebConsoleMessage; -struct WebFindInPageRequest; +struct WebFindOptions; struct WebScriptSource; } @@ -218,7 +218,9 @@ class WebFrame { // If no match is found, this function clears all tickmarks and highlighting. // // Returns true if the search string was found, false otherwise. - virtual bool Find(const WebKit::WebFindInPageRequest& request, + virtual bool Find(int request_id, + const string16& search_text, + const WebKit::WebFindOptions& options, bool wrap_within_frame, gfx::Rect* selection_rect) = 0; @@ -241,7 +243,9 @@ class WebFrame { // cancel at any time (see CancelPendingScopingEffort). The parameter Request // specifies what to look for and Reset signals whether this is a brand new // request or a continuation of the last scoping effort. - virtual void ScopeStringMatches(const WebKit::WebFindInPageRequest& request, + virtual void ScopeStringMatches(int request_id, + const string16& search_text, + const WebKit::WebFindOptions& options, bool reset) = 0; // Cancels any outstanding requests for scoping string matches on a frame. diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 11bdf5e..b1bfff8 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -136,7 +136,7 @@ MSVC_POP_WARNING(); #include "skia/ext/bitmap_platform_device.h" #include "skia/ext/platform_canvas.h" #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" -#include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h" #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "webkit/glue/alt_error_page_resource_fetcher.h" #include "webkit/glue/dom_operations.h" @@ -162,6 +162,7 @@ MSVC_POP_WARNING(); #endif using base::Time; + using WebCore::ChromeClientChromium; using WebCore::Color; using WebCore::Document; @@ -194,8 +195,9 @@ using WebCore::SubstituteData; using WebCore::TextIterator; using WebCore::VisiblePosition; using WebCore::XPathResult; + using WebKit::WebConsoleMessage; -using WebKit::WebFindInPageRequest; +using WebKit::WebFindOptions; using WebKit::WebScriptSource; // Key for a StatsCounter tracking how many WebFrames are active. @@ -947,24 +949,25 @@ void WebFrameImpl::ResetMatchCount() { frames_scoping_count_ = 0; } -bool WebFrameImpl::Find(const WebFindInPageRequest& request, +bool WebFrameImpl::Find(int request_id, + const string16& search_text, + const WebFindOptions& options, bool wrap_within_frame, gfx::Rect* selection_rect) { - WebCore::String webcore_string = - webkit_glue::WebStringToString(request.text); + WebCore::String webcore_string = webkit_glue::String16ToString(search_text); WebFrameImpl* const main_frame_impl = static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); - if (!request.findNext) + if (!options.findNext) frame()->page()->unmarkAllTextMatches(); // Starts the search from the current selection. bool start_in_selection = true; DCHECK(frame() && frame()->view()); - bool found = frame()->findString(webcore_string, request.forward, - request.matchCase, wrap_within_frame, + bool found = frame()->findString(webcore_string, options.forward, + options.matchCase, wrap_within_frame, start_in_selection); if (found) { #if defined(OS_WIN) @@ -993,7 +996,7 @@ bool WebFrameImpl::Find(const WebFindInPageRequest& request, curr_selection_rect = active_match_->boundingBox(); } - if (!request.findNext) { + if (!options.findNext) { // This is a Find operation, so we set the flag to ask the scoping effort // to find the active rect for us so we can update the ordinal (n of m). locating_active_rect_ = true; @@ -1002,14 +1005,14 @@ bool WebFrameImpl::Find(const WebFindInPageRequest& request, // If the active frame has changed it means that we have a multi-frame // page and we just switch to searching in a new frame. Then we just // want to reset the index. - if (request.forward) + if (options.forward) active_match_index_ = 0; else active_match_index_ = last_match_count_ - 1; } else { // We are still the active frame, so increment (or decrement) the // |active_match_index|, wrapping if needed (on single frame pages). - request.forward ? ++active_match_index_ : --active_match_index_; + options.forward ? ++active_match_index_ : --active_match_index_; if (active_match_index_ + 1 > last_match_count_) active_match_index_ = 0; if (active_match_index_ + 1 == 0) @@ -1026,7 +1029,7 @@ bool WebFrameImpl::Find(const WebFindInPageRequest& request, ReportFindInPageSelection(rect, active_match_index_ + 1, - request.identifier); + request_id); } #endif } @@ -1058,7 +1061,7 @@ int WebFrameImpl::OrdinalOfFirstMatchForFrame(WebFrameImpl* frame) const { return ordinal; } -bool WebFrameImpl::ShouldScopeMatches(const WebFindInPageRequest& request) { +bool WebFrameImpl::ShouldScopeMatches(const string16& search_text) { // Don't scope if we can't find a frame or if the frame is not visible. // The user may have closed the tab/application, so abort. if (!frame() || !Visible()) @@ -1073,7 +1076,7 @@ bool WebFrameImpl::ShouldScopeMatches(const WebFindInPageRequest& request) { !last_search_string_.empty() && last_match_count_ == 0) { // Check to see if the search string prefixes match. string16 previous_search_prefix = - string16(request.text).substr(0, last_search_string_.length()); + search_text.substr(0, last_search_string_.length()); if (previous_search_prefix == last_search_string_) { return false; // Don't search this frame, it will be fruitless. @@ -1134,9 +1137,11 @@ void WebFrameImpl::AddMarker(WebCore::Range* range) { } } -void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, +void WebFrameImpl::ScopeStringMatches(int request_id, + const string16& search_text, + const WebFindOptions& options, bool reset) { - if (!ShouldScopeMatches(request)) + if (!ShouldScopeMatches(search_text)) return; WebFrameImpl* main_frame_impl = @@ -1161,13 +1166,14 @@ void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, MessageLoop::current()->PostTask(FROM_HERE, scope_matches_factory_.NewRunnableMethod( &WebFrameImpl::ScopeStringMatches, - request, + request_id, + search_text, + options, false)); // false=we just reset, so don't do it again. return; } - WebCore::String webcore_string = - webkit_glue::WebStringToString(request.text); + WebCore::String webcore_string = webkit_glue::String16ToString(search_text); RefPtr<Range> search_range(rangeOfContents(frame()->document())); @@ -1202,7 +1208,7 @@ void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, RefPtr<Range> result_range(findPlainText(search_range.get(), webcore_string, true, - request.matchCase)); + options.matchCase)); if (result_range->collapsed(ec)) { if (!result_range->startContainer()->isInShadowTree()) break; @@ -1257,7 +1263,7 @@ void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, // To stop looking for the active tickmark, we set this flag. locating_active_rect_ = false; - #if defined(OS_WIN) +#if defined(OS_WIN) // TODO(pinkerton): Fix Mac invalidation to be more like Win ScrollView // Notify browser of new location for the selected rectangle. result_bounds.move(-frameview()->scrollOffset().width(), @@ -1266,8 +1272,8 @@ void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, webkit_glue::FromIntRect( frame()->view()->convertToContainingWindow(result_bounds)), active_match_index_ + 1, - request.identifier); - #endif + request_id); +#endif } } @@ -1277,7 +1283,7 @@ void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, // Remember what we search for last time, so we can skip searching if more // letters are added to the search string (and last outcome was 0). - last_search_string_ = request.text; + last_search_string_ = search_text; if (match_count > 0) { frame()->setMarkedTextMatchesAreHighlighted(true); @@ -1285,7 +1291,7 @@ void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, last_match_count_ += match_count; // Let the mainframe know how much we found during this pass. - main_frame_impl->IncreaseMatchCount(match_count, request.identifier); + main_frame_impl->IncreaseMatchCount(match_count, request_id); } if (timeout) { @@ -1299,7 +1305,9 @@ void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, MessageLoop::current()->PostTask(FROM_HERE, scope_matches_factory_.NewRunnableMethod( &WebFrameImpl::ScopeStringMatches, - request, + request_id, + search_text, + options, false)); // don't reset. return; // Done for now, resume work later. @@ -1313,12 +1321,10 @@ void WebFrameImpl::ScopeStringMatches(const WebFindInPageRequest& request, // If this is the last frame to finish scoping we need to trigger the final // update to be sent. if (main_frame_impl->frames_scoping_count_ == 0) - main_frame_impl->IncreaseMatchCount(0, request.identifier); + main_frame_impl->IncreaseMatchCount(0, request_id); // This frame is done, so show any scrollbar tickmarks we haven't drawn yet. InvalidateArea(INVALIDATE_SCROLLBAR); - - return; } void WebFrameImpl::CancelPendingScopingEffort() { diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index 11d8731..81a5f7f 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -126,11 +126,17 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { virtual void GetContentAsPlainText(int max_chars, std::wstring* text) const; virtual bool Find( - const WebKit::WebFindInPageRequest& request, bool wrap_within_frame, + int request_id, + const string16& search_text, + const WebKit::WebFindOptions& options, + bool wrap_within_frame, gfx::Rect* selection_rect); virtual void StopFinding(bool clear_selection); virtual void ScopeStringMatches( - const WebKit::WebFindInPageRequest& request, bool reset); + int request_id, + const string16& search_text, + const WebKit::WebFindOptions& options, + bool reset); virtual void CancelPendingScopingEffort(); virtual void ResetMatchCount(); virtual bool Visible(); @@ -387,7 +393,7 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { // It is not necessary if the frame is invisible, for example, or if this // is a repeat search that already returned nothing last time the same prefix // was searched. - bool ShouldScopeMatches(const WebKit::WebFindInPageRequest& request); + bool ShouldScopeMatches(const string16& search_text); // Only for test_shell int PendingFrameUnloadEventCount() const; diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index cc6ae99..d9682c1 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -4113,7 +4113,7 @@ '../third_party/WebKit/WebKit/chromium/public/WebCommon.h', '../third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h', '../third_party/WebKit/WebKit/chromium/public/WebCString.h', - '../third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h', + '../third_party/WebKit/WebKit/chromium/public/WebFindOptions.h', '../third_party/WebKit/WebKit/chromium/public/WebImage.h', '../third_party/WebKit/WebKit/chromium/public/WebInputEvent.h', '../third_party/WebKit/WebKit/chromium/public/WebKit.h', |