summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webview_impl.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 06:36:28 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 06:36:28 +0000
commit4873c7de675554a357717ddedc1fcaca2820de19 (patch)
treecd6446547d3b9d57f634187aecb1853c5ecbc8fb /webkit/glue/webview_impl.cc
parent3b846396a90174835320be2ff50afe8dd4e31590 (diff)
downloadchromium_src-4873c7de675554a357717ddedc1fcaca2820de19.zip
chromium_src-4873c7de675554a357717ddedc1fcaca2820de19.tar.gz
chromium_src-4873c7de675554a357717ddedc1fcaca2820de19.tar.bz2
Reverting 20855.
Review URL: http://codereview.chromium.org/149744 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webview_impl.cc')
-rw-r--r--webkit/glue/webview_impl.cc305
1 files changed, 159 insertions, 146 deletions
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index a29836d..29152bd 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -91,6 +91,7 @@ MSVC_POP_WARNING();
#include "webkit/api/public/WebInputEvent.h"
#include "webkit/api/public/WebPoint.h"
#include "webkit/api/public/WebRect.h"
+#include "webkit/api/public/WebString.h"
#include "webkit/glue/chrome_client_impl.h"
#include "webkit/glue/context_menu_client_impl.h"
#include "webkit/glue/dom_operations.h"
@@ -105,12 +106,12 @@ MSVC_POP_WARNING();
#include "webkit/glue/webdevtoolsagent_impl.h"
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webkit_glue.h"
+#include "webkit/glue/webpopupmenu_impl.h"
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webdevtoolsagent.h"
#include "webkit/glue/webdevtoolsclient.h"
#include "webkit/glue/webview_delegate.h"
#include "webkit/glue/webview_impl.h"
-#include "webkit/glue/webwidget_impl.h"
// Get rid of WTF's pow define so we can use std::pow.
#undef pow
@@ -118,6 +119,10 @@ MSVC_POP_WARNING();
using namespace WebCore;
+using WebKit::WebCanvas;
+using WebKit::WebCompositionCommand;
+using WebKit::WebCompositionCommandConfirm;
+using WebKit::WebCompositionCommandDiscard;
using WebKit::WebDragData;
using WebKit::WebInputEvent;
using WebKit::WebKeyboardEvent;
@@ -126,6 +131,11 @@ using WebKit::WebMouseWheelEvent;
using WebKit::WebPoint;
using WebKit::WebRect;
using WebKit::WebSize;
+using WebKit::WebString;
+using WebKit::WebTextDirection;
+using WebKit::WebTextDirectionDefault;
+using WebKit::WebTextDirectionLeftToRight;
+using WebKit::WebTextDirectionRightToLeft;
using webkit_glue::ImageResourceFetcher;
@@ -374,7 +384,7 @@ WebViewImpl::WebViewImpl()
doing_drag_and_drop_(false),
ignore_input_events_(false),
suppress_next_keypress_event_(false),
- window_open_disposition_(IGNORE_ACTION),
+ initial_navigation_policy_(WebKit::WebNavigationPolicyIgnore),
ime_accept_events_(true),
drag_target_dispatch_(false),
drag_identity_(0),
@@ -532,7 +542,7 @@ void WebViewImpl::MouseUp(const WebMouseEvent& event) {
if (!main_frame() || !main_frame()->frameview())
return;
- MouseCaptureLost();
+ mouseCaptureLost();
main_frame()->frame()->eventHandler()->handleMouseReleaseEvent(
MakePlatformMouseEvent(main_frame()->frameview(), event));
@@ -915,20 +925,9 @@ WebViewImpl* WebViewImpl::FromPage(WebCore::Page* page) {
return WebFrameImpl::FromFrame(page->mainFrame())->GetWebViewImpl();
}
-// WebView --------------------------------------------------------------------
-
-bool WebViewImpl::ShouldClose() {
- // TODO(creis): This should really cause a recursive depth-first walk of all
- // frames in the tree, calling each frame's onbeforeunload. At the moment,
- // we're consistent with Safari 3.1, not IE/FF.
- Frame* frame = page_->focusController()->focusedOrMainFrame();
- if (!frame)
- return true;
+// WebWidget ------------------------------------------------------------------
- return frame->shouldClose();
-}
-
-void WebViewImpl::Close() {
+void WebViewImpl::close() {
if (page_.get()) {
// Initiate shutdown for the entire frameset. This will cause a lot of
// notifications to be sent.
@@ -948,57 +947,7 @@ void WebViewImpl::Close() {
Release(); // Balances AddRef from WebView::Create
}
-WebViewDelegate* WebViewImpl::GetDelegate() {
- return delegate_;
-}
-
-void WebViewImpl::SetDelegate(WebViewDelegate* delegate) {
- delegate_ = delegate;
-}
-
-WebFrame* WebViewImpl::GetMainFrame() {
- return main_frame();
-}
-
-WebFrame* WebViewImpl::GetFocusedFrame() {
- Frame* frame = GetFocusedWebCoreFrame();
- return frame ? WebFrameImpl::FromFrame(frame) : NULL;
-}
-
-void WebViewImpl::SetFocusedFrame(WebFrame* frame) {
- if (!frame) {
- // Clears the focused frame if any.
- Frame* frame = GetFocusedWebCoreFrame();
- if (frame)
- frame->selection()->setFocused(false);
- return;
- }
- WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame);
- WebCore::Frame* webcore_frame = frame_impl->frame();
- webcore_frame->page()->focusController()->setFocusedFrame(webcore_frame);
-}
-
-WebFrame* WebViewImpl::GetFrameWithName(const std::wstring& name) {
- String name_str = webkit_glue::StdWStringToString(name);
- Frame* frame = page_->mainFrame()->tree()->find(name_str);
- return frame ? WebFrameImpl::FromFrame(frame) : NULL;
-}
-
-WebFrame* WebViewImpl::GetPreviousFrameBefore(WebFrame* frame, bool wrap) {
- WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame);
- WebCore::Frame* previous =
- frame_impl->frame()->tree()->traversePreviousWithWrap(wrap);
- return previous ? WebFrameImpl::FromFrame(previous) : NULL;
-}
-
-WebFrame* WebViewImpl::GetNextFrameAfter(WebFrame* frame, bool wrap) {
- WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame);
- WebCore::Frame* next =
- frame_impl->frame()->tree()->traverseNextWithWrap(wrap);
- return next ? WebFrameImpl::FromFrame(next) : NULL;
-}
-
-void WebViewImpl::Resize(const WebSize& new_size) {
+void WebViewImpl::resize(const WebSize& new_size) {
if (size_ == new_size)
return;
size_ = new_size;
@@ -1010,11 +959,11 @@ void WebViewImpl::Resize(const WebSize& new_size) {
if (delegate_) {
WebRect damaged_rect(0, 0, size_.width, size_.height);
- delegate_->DidInvalidateRect(this, damaged_rect);
+ delegate_->didInvalidateRect(damaged_rect);
}
}
-void WebViewImpl::Layout() {
+void WebViewImpl::layout() {
WebFrameImpl* webframe = main_frame();
if (webframe) {
// In order for our child HWNDs (NativeWindowWidgets) to update properly,
@@ -1034,7 +983,7 @@ void WebViewImpl::Layout() {
}
}
-void WebViewImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) {
+void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) {
WebFrameImpl* webframe = main_frame();
if (webframe)
webframe->Paint(canvas, rect);
@@ -1045,7 +994,7 @@ void WebViewImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) {
/* static */
const WebInputEvent* WebViewImpl::g_current_input_event = NULL;
-bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) {
+bool WebViewImpl::handleInputEvent(const WebInputEvent& input_event) {
// If we've started a drag and drop operation, ignore input events until
// we're done.
if (doing_drag_and_drop_)
@@ -1060,42 +1009,42 @@ bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) {
// Safari must perform a similar hack, ours is in our WebKit glue layer
// theirs is in the application. This should go when WebCore can be fixed
// to pass more event information to ChromeClient::show()
- g_current_input_event = input_event;
+ g_current_input_event = &input_event;
bool handled = true;
// TODO(jcampan): WebKit seems to always return false on mouse events
// processing methods. For now we'll assume it has processed them (as we are
// only interested in whether keyboard events are processed).
- switch (input_event->type) {
+ switch (input_event.type) {
case WebInputEvent::MouseMove:
- MouseMove(*static_cast<const WebMouseEvent*>(input_event));
+ MouseMove(*static_cast<const WebMouseEvent*>(&input_event));
break;
case WebInputEvent::MouseLeave:
- MouseLeave(*static_cast<const WebMouseEvent*>(input_event));
+ MouseLeave(*static_cast<const WebMouseEvent*>(&input_event));
break;
case WebInputEvent::MouseWheel:
- MouseWheel(*static_cast<const WebMouseWheelEvent*>(input_event));
+ MouseWheel(*static_cast<const WebMouseWheelEvent*>(&input_event));
break;
case WebInputEvent::MouseDown:
- MouseDown(*static_cast<const WebMouseEvent*>(input_event));
+ MouseDown(*static_cast<const WebMouseEvent*>(&input_event));
break;
case WebInputEvent::MouseUp:
- MouseUp(*static_cast<const WebMouseEvent*>(input_event));
+ MouseUp(*static_cast<const WebMouseEvent*>(&input_event));
break;
case WebInputEvent::RawKeyDown:
case WebInputEvent::KeyDown:
case WebInputEvent::KeyUp:
- handled = KeyEvent(*static_cast<const WebKeyboardEvent*>(input_event));
+ handled = KeyEvent(*static_cast<const WebKeyboardEvent*>(&input_event));
break;
case WebInputEvent::Char:
- handled = CharEvent(*static_cast<const WebKeyboardEvent*>(input_event));
+ handled = CharEvent(*static_cast<const WebKeyboardEvent*>(&input_event));
break;
default:
handled = false;
@@ -1106,53 +1055,10 @@ bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) {
return handled;
}
-void WebViewImpl::MouseCaptureLost() {
+void WebViewImpl::mouseCaptureLost() {
}
-// TODO(darin): these navigation methods should be killed
-
-void WebViewImpl::StopLoading() {
- main_frame()->StopLoading();
-}
-
-void WebViewImpl::SetBackForwardListSize(int size) {
- page_->backForwardList()->setCapacity(size);
-}
-
-void WebViewImpl::ClearFocusedNode() {
- if (!page_.get())
- return;
-
- RefPtr<Frame> frame = page_->mainFrame();
- if (!frame.get())
- return;
-
- RefPtr<Document> document = frame->document();
- if (!document.get())
- return;
-
- RefPtr<Node> old_focused_node = document->focusedNode();
-
- // Clear the focused node.
- document->setFocusedNode(NULL);
-
- if (!old_focused_node.get())
- return;
-
- // If a text field has focus, we need to make sure the selection controller
- // knows to remove selection from it. Otherwise, the text field is still
- // processing keyboard events even though focus has been moved to the page and
- // keystrokes get eaten as a result.
- if (old_focused_node->hasTagName(HTMLNames::textareaTag) ||
- (old_focused_node->hasTagName(HTMLNames::inputTag) &&
- static_cast<HTMLInputElement*>(old_focused_node.get())->isTextField())) {
- // Clear the selection.
- SelectionController* selection = frame->selection();
- selection->clear();
- }
-}
-
-void WebViewImpl::SetFocus(bool enable) {
+void WebViewImpl::setFocus(bool enable) {
page_->focusController()->setFocused(enable);
if (enable) {
// Note that we don't call setActive() when disabled as this cause extra
@@ -1181,11 +1087,11 @@ void WebViewImpl::SetFocus(bool enable) {
}
}
-bool WebViewImpl::ImeSetComposition(int string_type,
- int cursor_position,
- int target_start,
- int target_end,
- const std::wstring& ime_string) {
+bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command,
+ int cursor_position,
+ int target_start,
+ int target_end,
+ const WebString& ime_string) {
Frame* focused = GetFocusedWebCoreFrame();
if (!focused || !ime_accept_events_) {
return false;
@@ -1212,7 +1118,7 @@ bool WebViewImpl::ImeSetComposition(int string_type,
return false;
}
- if (string_type == -1) {
+ if (command == WebCompositionCommandDiscard) {
// A browser process sent an IPC message which does not contain a valid
// string, which means an ongoing composition has been canceled.
// If the ongoing composition has been canceled, replace the ongoing
@@ -1225,10 +1131,12 @@ bool WebViewImpl::ImeSetComposition(int string_type,
// displayed in this Editor object.
// To display the given string, set the given string to the
// m_compositionNode member of this Editor object and display it.
- if (target_start < 0) target_start = 0;
- if (target_end < 0) target_end = static_cast<int>(ime_string.length());
+ if (target_start < 0)
+ target_start = 0;
+ if (target_end < 0)
+ target_end = static_cast<int>(ime_string.length());
WebCore::String composition_string(
- webkit_glue::StdWStringToString(ime_string));
+ webkit_glue::WebStringToString(ime_string));
// Create custom underlines.
// To emphasize the selection, the selected region uses a solid black
// for its underline while other regions uses a pale gray for theirs.
@@ -1255,16 +1163,15 @@ bool WebViewImpl::ImeSetComposition(int string_type,
// The given string is a result string, which means the ongoing
// composition has been completed. I have to call the
// Editor::confirmCompletion() and complete this composition.
- if (string_type == 1) {
+ if (command == WebCompositionCommandConfirm)
editor->confirmComposition();
- }
}
return editor->hasComposition();
}
-bool WebViewImpl::ImeUpdateStatus(bool* enable_ime,
- WebRect* caret_rect) {
+bool WebViewImpl::queryCompositionStatus(bool* enable_ime,
+ WebRect* caret_rect) {
// Store whether the selected node needs IME and the caret rectangle.
// This process consists of the following four steps:
// 1. Retrieve the selection controller of the focused frame;
@@ -1299,7 +1206,7 @@ bool WebViewImpl::ImeUpdateStatus(bool* enable_ime,
return true;
}
-void WebViewImpl::SetTextDirection(WebTextDirection direction) {
+void WebViewImpl::setTextDirection(WebTextDirection direction) {
// The Editor::setBaseWritingDirection() function checks if we can change
// the text direction of the selected node and updates its DOM "dir"
// attribute and its CSS "direction" property.
@@ -1313,15 +1220,15 @@ void WebViewImpl::SetTextDirection(WebTextDirection direction) {
return;
switch (direction) {
- case WEB_TEXT_DIRECTION_DEFAULT:
+ case WebTextDirectionDefault:
editor->setBaseWritingDirection(WebCore::NaturalWritingDirection);
break;
- case WEB_TEXT_DIRECTION_LTR:
+ case WebTextDirectionLeftToRight:
editor->setBaseWritingDirection(WebCore::LeftToRightWritingDirection);
break;
- case WEB_TEXT_DIRECTION_RTL:
+ case WebTextDirectionRightToLeft:
editor->setBaseWritingDirection(WebCore::RightToLeftWritingDirection);
break;
@@ -1331,6 +1238,112 @@ void WebViewImpl::SetTextDirection(WebTextDirection direction) {
}
}
+// WebView --------------------------------------------------------------------
+
+bool WebViewImpl::ShouldClose() {
+ // TODO(creis): This should really cause a recursive depth-first walk of all
+ // frames in the tree, calling each frame's onbeforeunload. At the moment,
+ // we're consistent with Safari 3.1, not IE/FF.
+ Frame* frame = page_->focusController()->focusedOrMainFrame();
+ if (!frame)
+ return true;
+
+ return frame->shouldClose();
+}
+
+WebViewDelegate* WebViewImpl::GetDelegate() {
+ return delegate_;
+}
+
+void WebViewImpl::SetDelegate(WebViewDelegate* delegate) {
+ delegate_ = delegate;
+}
+
+WebFrame* WebViewImpl::GetMainFrame() {
+ return main_frame();
+}
+
+WebFrame* WebViewImpl::GetFocusedFrame() {
+ Frame* frame = GetFocusedWebCoreFrame();
+ return frame ? WebFrameImpl::FromFrame(frame) : NULL;
+}
+
+void WebViewImpl::SetFocusedFrame(WebFrame* frame) {
+ if (!frame) {
+ // Clears the focused frame if any.
+ Frame* frame = GetFocusedWebCoreFrame();
+ if (frame)
+ frame->selection()->setFocused(false);
+ return;
+ }
+ WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame);
+ WebCore::Frame* webcore_frame = frame_impl->frame();
+ webcore_frame->page()->focusController()->setFocusedFrame(webcore_frame);
+}
+
+WebFrame* WebViewImpl::GetFrameWithName(const std::wstring& name) {
+ String name_str = webkit_glue::StdWStringToString(name);
+ Frame* frame = page_->mainFrame()->tree()->find(name_str);
+ return frame ? WebFrameImpl::FromFrame(frame) : NULL;
+}
+
+WebFrame* WebViewImpl::GetPreviousFrameBefore(WebFrame* frame, bool wrap) {
+ WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame);
+ WebCore::Frame* previous =
+ frame_impl->frame()->tree()->traversePreviousWithWrap(wrap);
+ return previous ? WebFrameImpl::FromFrame(previous) : NULL;
+}
+
+WebFrame* WebViewImpl::GetNextFrameAfter(WebFrame* frame, bool wrap) {
+ WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame);
+ WebCore::Frame* next =
+ frame_impl->frame()->tree()->traverseNextWithWrap(wrap);
+ return next ? WebFrameImpl::FromFrame(next) : NULL;
+}
+
+// TODO(darin): these navigation methods should be killed
+
+void WebViewImpl::StopLoading() {
+ main_frame()->StopLoading();
+}
+
+void WebViewImpl::SetBackForwardListSize(int size) {
+ page_->backForwardList()->setCapacity(size);
+}
+
+void WebViewImpl::ClearFocusedNode() {
+ if (!page_.get())
+ return;
+
+ RefPtr<Frame> frame = page_->mainFrame();
+ if (!frame.get())
+ return;
+
+ RefPtr<Document> document = frame->document();
+ if (!document.get())
+ return;
+
+ RefPtr<Node> old_focused_node = document->focusedNode();
+
+ // Clear the focused node.
+ document->setFocusedNode(NULL);
+
+ if (!old_focused_node.get())
+ return;
+
+ // If a text field has focus, we need to make sure the selection controller
+ // knows to remove selection from it. Otherwise, the text field is still
+ // processing keyboard events even though focus has been moved to the page and
+ // keystrokes get eaten as a result.
+ if (old_focused_node->hasTagName(HTMLNames::textareaTag) ||
+ (old_focused_node->hasTagName(HTMLNames::inputTag) &&
+ static_cast<HTMLInputElement*>(old_focused_node.get())->isTextField())) {
+ // Clear the selection.
+ SelectionController* selection = frame->selection();
+ selection->clear();
+ }
+}
+
void WebViewImpl::SetInitialFocus(bool reverse) {
if (page_.get()) {
// Since we don't have a keyboard event, we'll create one.
@@ -1866,10 +1879,10 @@ void WebViewImpl::RefreshAutofillPopup() {
IntRect new_bounds = autocomplete_popup_->boundsRect();
// Let's resize the backing window if necessary.
if (old_bounds != new_bounds) {
- WebWidgetImpl* web_widget =
- static_cast<WebWidgetImpl*>(autocomplete_popup_->client());
- web_widget->delegate()->SetWindowRect(
- web_widget, webkit_glue::IntRectToWebRect(new_bounds));
+ WebPopupMenuImpl* popup_menu =
+ static_cast<WebPopupMenuImpl*>(autocomplete_popup_->client());
+ popup_menu->client()->setWindowRect(
+ webkit_glue::IntRectToWebRect(new_bounds));
}
}