| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 Google Inc. All Rights Reserved. | 2 * Copyright 2007 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * ***** BEGIN LICENSE BLOCK ***** | 6 * ***** BEGIN LICENSE BLOCK ***** |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 #include "base/gfx/rect.h" | 85 #include "base/gfx/rect.h" |
| 86 #include "base/keyboard_codes.h" | 86 #include "base/keyboard_codes.h" |
| 87 #include "base/logging.h" | 87 #include "base/logging.h" |
| 88 #include "base/message_loop.h" | 88 #include "base/message_loop.h" |
| 89 #include "base/string_util.h" | 89 #include "base/string_util.h" |
| 90 #include "webkit/api/public/WebDragData.h" | 90 #include "webkit/api/public/WebDragData.h" |
| 91 #include "webkit/api/public/WebInputEvent.h" | 91 #include "webkit/api/public/WebInputEvent.h" |
| 92 #include "webkit/api/public/WebPoint.h" | 92 #include "webkit/api/public/WebPoint.h" |
| 93 #include "webkit/api/public/WebRect.h" | 93 #include "webkit/api/public/WebRect.h" |
| 94 #include "webkit/api/public/WebString.h" |
| 94 #include "webkit/glue/chrome_client_impl.h" | 95 #include "webkit/glue/chrome_client_impl.h" |
| 95 #include "webkit/glue/context_menu_client_impl.h" | 96 #include "webkit/glue/context_menu_client_impl.h" |
| 96 #include "webkit/glue/dom_operations.h" | 97 #include "webkit/glue/dom_operations.h" |
| 97 #include "webkit/glue/dragclient_impl.h" | 98 #include "webkit/glue/dragclient_impl.h" |
| 98 #include "webkit/glue/editor_client_impl.h" | 99 #include "webkit/glue/editor_client_impl.h" |
| 99 #include "webkit/glue/event_conversion.h" | 100 #include "webkit/glue/event_conversion.h" |
| 100 #include "webkit/glue/glue_serialize.h" | 101 #include "webkit/glue/glue_serialize.h" |
| 101 #include "webkit/glue/glue_util.h" | 102 #include "webkit/glue/glue_util.h" |
| 102 #include "webkit/glue/image_resource_fetcher.h" | 103 #include "webkit/glue/image_resource_fetcher.h" |
| 103 #include "webkit/glue/inspector_client_impl.h" | 104 #include "webkit/glue/inspector_client_impl.h" |
| 104 #include "webkit/glue/searchable_form_data.h" | 105 #include "webkit/glue/searchable_form_data.h" |
| 105 #include "webkit/glue/webdevtoolsagent_impl.h" | 106 #include "webkit/glue/webdevtoolsagent_impl.h" |
| 106 #include "webkit/glue/webdropdata.h" | 107 #include "webkit/glue/webdropdata.h" |
| 107 #include "webkit/glue/webkit_glue.h" | 108 #include "webkit/glue/webkit_glue.h" |
| 109 #include "webkit/glue/webpopupmenu_impl.h" |
| 108 #include "webkit/glue/webpreferences.h" | 110 #include "webkit/glue/webpreferences.h" |
| 109 #include "webkit/glue/webdevtoolsagent.h" | 111 #include "webkit/glue/webdevtoolsagent.h" |
| 110 #include "webkit/glue/webdevtoolsclient.h" | 112 #include "webkit/glue/webdevtoolsclient.h" |
| 111 #include "webkit/glue/webview_delegate.h" | 113 #include "webkit/glue/webview_delegate.h" |
| 112 #include "webkit/glue/webview_impl.h" | 114 #include "webkit/glue/webview_impl.h" |
| 113 #include "webkit/glue/webwidget_impl.h" | |
| 114 | 115 |
| 115 // Get rid of WTF's pow define so we can use std::pow. | 116 // Get rid of WTF's pow define so we can use std::pow. |
| 116 #undef pow | 117 #undef pow |
| 117 #include <cmath> // for std::pow | 118 #include <cmath> // for std::pow |
| 118 | 119 |
| 119 using namespace WebCore; | 120 using namespace WebCore; |
| 120 | 121 |
| 122 using WebKit::WebCanvas; |
| 123 using WebKit::WebCompositionCommand; |
| 124 using WebKit::WebCompositionCommandConfirm; |
| 125 using WebKit::WebCompositionCommandDiscard; |
| 121 using WebKit::WebDragData; | 126 using WebKit::WebDragData; |
| 122 using WebKit::WebInputEvent; | 127 using WebKit::WebInputEvent; |
| 123 using WebKit::WebKeyboardEvent; | 128 using WebKit::WebKeyboardEvent; |
| 124 using WebKit::WebMouseEvent; | 129 using WebKit::WebMouseEvent; |
| 125 using WebKit::WebMouseWheelEvent; | 130 using WebKit::WebMouseWheelEvent; |
| 126 using WebKit::WebPoint; | 131 using WebKit::WebPoint; |
| 127 using WebKit::WebRect; | 132 using WebKit::WebRect; |
| 128 using WebKit::WebSize; | 133 using WebKit::WebSize; |
| 134 using WebKit::WebString; |
| 135 using WebKit::WebTextDirection; |
| 136 using WebKit::WebTextDirectionDefault; |
| 137 using WebKit::WebTextDirectionLeftToRight; |
| 138 using WebKit::WebTextDirectionRightToLeft; |
| 129 | 139 |
| 130 using webkit_glue::ImageResourceFetcher; | 140 using webkit_glue::ImageResourceFetcher; |
| 131 | 141 |
| 132 // Change the text zoom level by kTextSizeMultiplierRatio each time the user | 142 // Change the text zoom level by kTextSizeMultiplierRatio each time the user |
| 133 // zooms text in or out (ie., change by 20%). The min and max values limit | 143 // zooms text in or out (ie., change by 20%). The min and max values limit |
| 134 // text zoom to half and 3x the original text size. These three values match | 144 // text zoom to half and 3x the original text size. These three values match |
| 135 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm | 145 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm |
| 136 static const double kTextSizeMultiplierRatio = 1.2; | 146 static const double kTextSizeMultiplierRatio = 1.2; |
| 137 static const double kMinTextSizeMultiplier = 0.5; | 147 static const double kMinTextSizeMultiplier = 0.5; |
| 138 static const double kMaxTextSizeMultiplier = 3.0; | 148 static const double kMaxTextSizeMultiplier = 3.0; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 : ALLOW_THIS_IN_INITIALIZER_LIST(back_forward_list_client_impl_(this)), | 377 : ALLOW_THIS_IN_INITIALIZER_LIST(back_forward_list_client_impl_(this)), |
| 368 observed_new_navigation_(false), | 378 observed_new_navigation_(false), |
| 369 #ifndef NDEBUG | 379 #ifndef NDEBUG |
| 370 new_navigation_loader_(NULL), | 380 new_navigation_loader_(NULL), |
| 371 #endif | 381 #endif |
| 372 zoom_level_(0), | 382 zoom_level_(0), |
| 373 context_menu_allowed_(false), | 383 context_menu_allowed_(false), |
| 374 doing_drag_and_drop_(false), | 384 doing_drag_and_drop_(false), |
| 375 ignore_input_events_(false), | 385 ignore_input_events_(false), |
| 376 suppress_next_keypress_event_(false), | 386 suppress_next_keypress_event_(false), |
| 377 window_open_disposition_(IGNORE_ACTION), | 387 initial_navigation_policy_(WebKit::WebNavigationPolicyIgnore), |
| 378 ime_accept_events_(true), | 388 ime_accept_events_(true), |
| 379 drag_target_dispatch_(false), | 389 drag_target_dispatch_(false), |
| 380 drag_identity_(0), | 390 drag_identity_(0), |
| 381 drop_effect_(DROP_EFFECT_DEFAULT), | 391 drop_effect_(DROP_EFFECT_DEFAULT), |
| 382 drop_accept_(false), | 392 drop_accept_(false), |
| 383 autocomplete_popup_showing_(false), | 393 autocomplete_popup_showing_(false), |
| 384 is_transparent_(false) { | 394 is_transparent_(false) { |
| 385 // WebKit/win/WebView.cpp does the same thing, except they call the | 395 // WebKit/win/WebView.cpp does the same thing, except they call the |
| 386 // KJS specific wrapper around this method. We need to have threading | 396 // KJS specific wrapper around this method. We need to have threading |
| 387 // initialized because CollatorICU requires it. | 397 // initialized because CollatorICU requires it. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 target_frame->eventHandler()->sendContextMenuEvent(pme); | 535 target_frame->eventHandler()->sendContextMenuEvent(pme); |
| 526 context_menu_allowed_ = false; | 536 context_menu_allowed_ = false; |
| 527 // Actually showing the context menu is handled by the ContextMenuClient | 537 // Actually showing the context menu is handled by the ContextMenuClient |
| 528 // implementation... | 538 // implementation... |
| 529 } | 539 } |
| 530 | 540 |
| 531 void WebViewImpl::MouseUp(const WebMouseEvent& event) { | 541 void WebViewImpl::MouseUp(const WebMouseEvent& event) { |
| 532 if (!main_frame() || !main_frame()->frameview()) | 542 if (!main_frame() || !main_frame()->frameview()) |
| 533 return; | 543 return; |
| 534 | 544 |
| 535 MouseCaptureLost(); | 545 mouseCaptureLost(); |
| 536 main_frame()->frame()->eventHandler()->handleMouseReleaseEvent( | 546 main_frame()->frame()->eventHandler()->handleMouseReleaseEvent( |
| 537 MakePlatformMouseEvent(main_frame()->frameview(), event)); | 547 MakePlatformMouseEvent(main_frame()->frameview(), event)); |
| 538 | 548 |
| 539 #if defined(OS_WIN) | 549 #if defined(OS_WIN) |
| 540 // Dispatch the contextmenu event regardless of if the click was swallowed. | 550 // Dispatch the contextmenu event regardless of if the click was swallowed. |
| 541 // On Mac/Linux, we handle it on mouse down, not up. | 551 // On Mac/Linux, we handle it on mouse down, not up. |
| 542 if (event.button == WebMouseEvent::ButtonRight) | 552 if (event.button == WebMouseEvent::ButtonRight) |
| 543 MouseContextMenu(event); | 553 MouseContextMenu(event); |
| 544 #endif | 554 #endif |
| 545 | 555 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 | 918 |
| 909 Frame* WebViewImpl::GetFocusedWebCoreFrame() { | 919 Frame* WebViewImpl::GetFocusedWebCoreFrame() { |
| 910 return page_.get() ? page_->focusController()->focusedOrMainFrame() : NULL; | 920 return page_.get() ? page_->focusController()->focusedOrMainFrame() : NULL; |
| 911 } | 921 } |
| 912 | 922 |
| 913 // static | 923 // static |
| 914 WebViewImpl* WebViewImpl::FromPage(WebCore::Page* page) { | 924 WebViewImpl* WebViewImpl::FromPage(WebCore::Page* page) { |
| 915 return WebFrameImpl::FromFrame(page->mainFrame())->GetWebViewImpl(); | 925 return WebFrameImpl::FromFrame(page->mainFrame())->GetWebViewImpl(); |
| 916 } | 926 } |
| 917 | 927 |
| 918 // WebView -------------------------------------------------------------------- | 928 // WebWidget ------------------------------------------------------------------ |
| 919 | 929 |
| 920 bool WebViewImpl::ShouldClose() { | 930 void WebViewImpl::close() { |
| 921 // TODO(creis): This should really cause a recursive depth-first walk of all | |
| 922 // frames in the tree, calling each frame's onbeforeunload. At the moment, | |
| 923 // we're consistent with Safari 3.1, not IE/FF. | |
| 924 Frame* frame = page_->focusController()->focusedOrMainFrame(); | |
| 925 if (!frame) | |
| 926 return true; | |
| 927 | |
| 928 return frame->shouldClose(); | |
| 929 } | |
| 930 | |
| 931 void WebViewImpl::Close() { | |
| 932 if (page_.get()) { | 931 if (page_.get()) { |
| 933 // Initiate shutdown for the entire frameset. This will cause a lot of | 932 // Initiate shutdown for the entire frameset. This will cause a lot of |
| 934 // notifications to be sent. | 933 // notifications to be sent. |
| 935 if (page_->mainFrame()) | 934 if (page_->mainFrame()) |
| 936 page_->mainFrame()->loader()->frameDetached(); | 935 page_->mainFrame()->loader()->frameDetached(); |
| 937 page_.reset(); | 936 page_.reset(); |
| 938 } | 937 } |
| 939 | 938 |
| 940 // Should happen after page_.reset(). | 939 // Should happen after page_.reset(). |
| 941 if (devtools_agent_.get()) | 940 if (devtools_agent_.get()) |
| 942 devtools_agent_.reset(NULL); | 941 devtools_agent_.reset(NULL); |
| 943 | 942 |
| 944 // Reset the delegate to prevent notifications being sent as we're being | 943 // Reset the delegate to prevent notifications being sent as we're being |
| 945 // deleted. | 944 // deleted. |
| 946 delegate_ = NULL; | 945 delegate_ = NULL; |
| 947 | 946 |
| 948 Release(); // Balances AddRef from WebView::Create | 947 Release(); // Balances AddRef from WebView::Create |
| 949 } | 948 } |
| 950 | 949 |
| 951 WebViewDelegate* WebViewImpl::GetDelegate() { | 950 void WebViewImpl::resize(const WebSize& new_size) { |
| 952 return delegate_; | |
| 953 } | |
| 954 | |
| 955 void WebViewImpl::SetDelegate(WebViewDelegate* delegate) { | |
| 956 delegate_ = delegate; | |
| 957 } | |
| 958 | |
| 959 WebFrame* WebViewImpl::GetMainFrame() { | |
| 960 return main_frame(); | |
| 961 } | |
| 962 | |
| 963 WebFrame* WebViewImpl::GetFocusedFrame() { | |
| 964 Frame* frame = GetFocusedWebCoreFrame(); | |
| 965 return frame ? WebFrameImpl::FromFrame(frame) : NULL; | |
| 966 } | |
| 967 | |
| 968 void WebViewImpl::SetFocusedFrame(WebFrame* frame) { | |
| 969 if (!frame) { | |
| 970 // Clears the focused frame if any. | |
| 971 Frame* frame = GetFocusedWebCoreFrame(); | |
| 972 if (frame) | |
| 973 frame->selection()->setFocused(false); | |
| 974 return; | |
| 975 } | |
| 976 WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); | |
| 977 WebCore::Frame* webcore_frame = frame_impl->frame(); | |
| 978 webcore_frame->page()->focusController()->setFocusedFrame(webcore_frame); | |
| 979 } | |
| 980 | |
| 981 WebFrame* WebViewImpl::GetFrameWithName(const std::wstring& name) { | |
| 982 String name_str = webkit_glue::StdWStringToString(name); | |
| 983 Frame* frame = page_->mainFrame()->tree()->find(name_str); | |
| 984 return frame ? WebFrameImpl::FromFrame(frame) : NULL; | |
| 985 } | |
| 986 | |
| 987 WebFrame* WebViewImpl::GetPreviousFrameBefore(WebFrame* frame, bool wrap) { | |
| 988 WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); | |
| 989 WebCore::Frame* previous = | |
| 990 frame_impl->frame()->tree()->traversePreviousWithWrap(wrap); | |
| 991 return previous ? WebFrameImpl::FromFrame(previous) : NULL; | |
| 992 } | |
| 993 | |
| 994 WebFrame* WebViewImpl::GetNextFrameAfter(WebFrame* frame, bool wrap) { | |
| 995 WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); | |
| 996 WebCore::Frame* next = | |
| 997 frame_impl->frame()->tree()->traverseNextWithWrap(wrap); | |
| 998 return next ? WebFrameImpl::FromFrame(next) : NULL; | |
| 999 } | |
| 1000 | |
| 1001 void WebViewImpl::Resize(const WebSize& new_size) { | |
| 1002 if (size_ == new_size) | 951 if (size_ == new_size) |
| 1003 return; | 952 return; |
| 1004 size_ = new_size; | 953 size_ = new_size; |
| 1005 | 954 |
| 1006 if (main_frame()->frameview()) { | 955 if (main_frame()->frameview()) { |
| 1007 main_frame()->frameview()->resize(size_.width, size_.height); | 956 main_frame()->frameview()->resize(size_.width, size_.height); |
| 1008 main_frame()->frame()->eventHandler()->sendResizeEvent(); | 957 main_frame()->frame()->eventHandler()->sendResizeEvent(); |
| 1009 } | 958 } |
| 1010 | 959 |
| 1011 if (delegate_) { | 960 if (delegate_) { |
| 1012 WebRect damaged_rect(0, 0, size_.width, size_.height); | 961 WebRect damaged_rect(0, 0, size_.width, size_.height); |
| 1013 delegate_->DidInvalidateRect(this, damaged_rect); | 962 delegate_->didInvalidateRect(damaged_rect); |
| 1014 } | 963 } |
| 1015 } | 964 } |
| 1016 | 965 |
| 1017 void WebViewImpl::Layout() { | 966 void WebViewImpl::layout() { |
| 1018 WebFrameImpl* webframe = main_frame(); | 967 WebFrameImpl* webframe = main_frame(); |
| 1019 if (webframe) { | 968 if (webframe) { |
| 1020 // In order for our child HWNDs (NativeWindowWidgets) to update properly, | 969 // In order for our child HWNDs (NativeWindowWidgets) to update properly, |
| 1021 // they need to be told that we are updating the screen. The problem is | 970 // they need to be told that we are updating the screen. The problem is |
| 1022 // that the native widgets need to recalculate their clip region and not | 971 // that the native widgets need to recalculate their clip region and not |
| 1023 // overlap any of our non-native widgets. To force the resizing, call | 972 // overlap any of our non-native widgets. To force the resizing, call |
| 1024 // setFrameRect(). This will be a quick operation for most frames, but | 973 // setFrameRect(). This will be a quick operation for most frames, but |
| 1025 // the NativeWindowWidgets will update a proper clipping region. | 974 // the NativeWindowWidgets will update a proper clipping region. |
| 1026 FrameView* view = webframe->frameview(); | 975 FrameView* view = webframe->frameview(); |
| 1027 if (view) | 976 if (view) |
| 1028 view->setFrameRect(view->frameRect()); | 977 view->setFrameRect(view->frameRect()); |
| 1029 | 978 |
| 1030 // setFrameRect may have the side-effect of causing existing page | 979 // setFrameRect may have the side-effect of causing existing page |
| 1031 // layout to be invalidated, so layout needs to be called last. | 980 // layout to be invalidated, so layout needs to be called last. |
| 1032 | 981 |
| 1033 webframe->Layout(); | 982 webframe->Layout(); |
| 1034 } | 983 } |
| 1035 } | 984 } |
| 1036 | 985 |
| 1037 void WebViewImpl::Paint(skia::PlatformCanvas* canvas, const WebRect& rect) { | 986 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) { |
| 1038 WebFrameImpl* webframe = main_frame(); | 987 WebFrameImpl* webframe = main_frame(); |
| 1039 if (webframe) | 988 if (webframe) |
| 1040 webframe->Paint(canvas, rect); | 989 webframe->Paint(canvas, rect); |
| 1041 } | 990 } |
| 1042 | 991 |
| 1043 // TODO(eseidel): g_current_input_event should be removed once | 992 // TODO(eseidel): g_current_input_event should be removed once |
| 1044 // ChromeClient:show() can get the current-event information from WebCore. | 993 // ChromeClient:show() can get the current-event information from WebCore. |
| 1045 /* static */ | 994 /* static */ |
| 1046 const WebInputEvent* WebViewImpl::g_current_input_event = NULL; | 995 const WebInputEvent* WebViewImpl::g_current_input_event = NULL; |
| 1047 | 996 |
| 1048 bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) { | 997 bool WebViewImpl::handleInputEvent(const WebInputEvent& input_event) { |
| 1049 // If we've started a drag and drop operation, ignore input events until | 998 // If we've started a drag and drop operation, ignore input events until |
| 1050 // we're done. | 999 // we're done. |
| 1051 if (doing_drag_and_drop_) | 1000 if (doing_drag_and_drop_) |
| 1052 return true; | 1001 return true; |
| 1053 | 1002 |
| 1054 if (ignore_input_events_) | 1003 if (ignore_input_events_) |
| 1055 return true; | 1004 return true; |
| 1056 | 1005 |
| 1057 // TODO(eseidel): Remove g_current_input_event. | 1006 // TODO(eseidel): Remove g_current_input_event. |
| 1058 // This only exists to allow ChromeClient::show() to know which mouse button | 1007 // This only exists to allow ChromeClient::show() to know which mouse button |
| 1059 // triggered a window.open event. | 1008 // triggered a window.open event. |
| 1060 // Safari must perform a similar hack, ours is in our WebKit glue layer | 1009 // Safari must perform a similar hack, ours is in our WebKit glue layer |
| 1061 // theirs is in the application. This should go when WebCore can be fixed | 1010 // theirs is in the application. This should go when WebCore can be fixed |
| 1062 // to pass more event information to ChromeClient::show() | 1011 // to pass more event information to ChromeClient::show() |
| 1063 g_current_input_event = input_event; | 1012 g_current_input_event = &input_event; |
| 1064 | 1013 |
| 1065 bool handled = true; | 1014 bool handled = true; |
| 1066 | 1015 |
| 1067 // TODO(jcampan): WebKit seems to always return false on mouse events | 1016 // TODO(jcampan): WebKit seems to always return false on mouse events |
| 1068 // processing methods. For now we'll assume it has processed them (as we are | 1017 // processing methods. For now we'll assume it has processed them (as we are |
| 1069 // only interested in whether keyboard events are processed). | 1018 // only interested in whether keyboard events are processed). |
| 1070 switch (input_event->type) { | 1019 switch (input_event.type) { |
| 1071 case WebInputEvent::MouseMove: | 1020 case WebInputEvent::MouseMove: |
| 1072 MouseMove(*static_cast<const WebMouseEvent*>(input_event)); | 1021 MouseMove(*static_cast<const WebMouseEvent*>(&input_event)); |
| 1073 break; | 1022 break; |
| 1074 | 1023 |
| 1075 case WebInputEvent::MouseLeave: | 1024 case WebInputEvent::MouseLeave: |
| 1076 MouseLeave(*static_cast<const WebMouseEvent*>(input_event)); | 1025 MouseLeave(*static_cast<const WebMouseEvent*>(&input_event)); |
| 1077 break; | 1026 break; |
| 1078 | 1027 |
| 1079 case WebInputEvent::MouseWheel: | 1028 case WebInputEvent::MouseWheel: |
| 1080 MouseWheel(*static_cast<const WebMouseWheelEvent*>(input_event)); | 1029 MouseWheel(*static_cast<const WebMouseWheelEvent*>(&input_event)); |
| 1081 break; | 1030 break; |
| 1082 | 1031 |
| 1083 case WebInputEvent::MouseDown: | 1032 case WebInputEvent::MouseDown: |
| 1084 MouseDown(*static_cast<const WebMouseEvent*>(input_event)); | 1033 MouseDown(*static_cast<const WebMouseEvent*>(&input_event)); |
| 1085 break; | 1034 break; |
| 1086 | 1035 |
| 1087 case WebInputEvent::MouseUp: | 1036 case WebInputEvent::MouseUp: |
| 1088 MouseUp(*static_cast<const WebMouseEvent*>(input_event)); | 1037 MouseUp(*static_cast<const WebMouseEvent*>(&input_event)); |
| 1089 break; | 1038 break; |
| 1090 | 1039 |
| 1091 case WebInputEvent::RawKeyDown: | 1040 case WebInputEvent::RawKeyDown: |
| 1092 case WebInputEvent::KeyDown: | 1041 case WebInputEvent::KeyDown: |
| 1093 case WebInputEvent::KeyUp: | 1042 case WebInputEvent::KeyUp: |
| 1094 handled = KeyEvent(*static_cast<const WebKeyboardEvent*>(input_event)); | 1043 handled = KeyEvent(*static_cast<const WebKeyboardEvent*>(&input_event)); |
| 1095 break; | 1044 break; |
| 1096 | 1045 |
| 1097 case WebInputEvent::Char: | 1046 case WebInputEvent::Char: |
| 1098 handled = CharEvent(*static_cast<const WebKeyboardEvent*>(input_event)); | 1047 handled = CharEvent(*static_cast<const WebKeyboardEvent*>(&input_event)); |
| 1099 break; | 1048 break; |
| 1100 default: | 1049 default: |
| 1101 handled = false; | 1050 handled = false; |
| 1102 } | 1051 } |
| 1103 | 1052 |
| 1104 g_current_input_event = NULL; | 1053 g_current_input_event = NULL; |
| 1105 | 1054 |
| 1106 return handled; | 1055 return handled; |
| 1107 } | 1056 } |
| 1108 | 1057 |
| 1109 void WebViewImpl::MouseCaptureLost() { | 1058 void WebViewImpl::mouseCaptureLost() { |
| 1110 } | 1059 } |
| 1111 | 1060 |
| 1112 // TODO(darin): these navigation methods should be killed | 1061 void WebViewImpl::setFocus(bool enable) { |
| 1113 | |
| 1114 void WebViewImpl::StopLoading() { | |
| 1115 main_frame()->StopLoading(); | |
| 1116 } | |
| 1117 | |
| 1118 void WebViewImpl::SetBackForwardListSize(int size) { | |
| 1119 page_->backForwardList()->setCapacity(size); | |
| 1120 } | |
| 1121 | |
| 1122 void WebViewImpl::ClearFocusedNode() { | |
| 1123 if (!page_.get()) | |
| 1124 return; | |
| 1125 | |
| 1126 RefPtr<Frame> frame = page_->mainFrame(); | |
| 1127 if (!frame.get()) | |
| 1128 return; | |
| 1129 | |
| 1130 RefPtr<Document> document = frame->document(); | |
| 1131 if (!document.get()) | |
| 1132 return; | |
| 1133 | |
| 1134 RefPtr<Node> old_focused_node = document->focusedNode(); | |
| 1135 | |
| 1136 // Clear the focused node. | |
| 1137 document->setFocusedNode(NULL); | |
| 1138 | |
| 1139 if (!old_focused_node.get()) | |
| 1140 return; | |
| 1141 | |
| 1142 // If a text field has focus, we need to make sure the selection controller | |
| 1143 // knows to remove selection from it. Otherwise, the text field is still | |
| 1144 // processing keyboard events even though focus has been moved to the page and | |
| 1145 // keystrokes get eaten as a result. | |
| 1146 if (old_focused_node->hasTagName(HTMLNames::textareaTag) || | |
| 1147 (old_focused_node->hasTagName(HTMLNames::inputTag) && | |
| 1148 static_cast<HTMLInputElement*>(old_focused_node.get())->isTextField())) { | |
| 1149 // Clear the selection. | |
| 1150 SelectionController* selection = frame->selection(); | |
| 1151 selection->clear(); | |
| 1152 } | |
| 1153 } | |
| 1154 | |
| 1155 void WebViewImpl::SetFocus(bool enable) { | |
| 1156 page_->focusController()->setFocused(enable); | 1062 page_->focusController()->setFocused(enable); |
| 1157 if (enable) { | 1063 if (enable) { |
| 1158 // Note that we don't call setActive() when disabled as this cause extra | 1064 // Note that we don't call setActive() when disabled as this cause extra |
| 1159 // focus/blur events to be dispatched. | 1065 // focus/blur events to be dispatched. |
| 1160 page_->focusController()->setActive(true); | 1066 page_->focusController()->setActive(true); |
| 1161 ime_accept_events_ = true; | 1067 ime_accept_events_ = true; |
| 1162 } else { | 1068 } else { |
| 1163 HideAutoCompletePopup(); | 1069 HideAutoCompletePopup(); |
| 1164 | 1070 |
| 1165 // Clear focus on the currently focused frame if any. | 1071 // Clear focus on the currently focused frame if any. |
| 1166 if (!page_.get()) | 1072 if (!page_.get()) |
| 1167 return; | 1073 return; |
| 1168 | 1074 |
| 1169 Frame* frame = page_->mainFrame(); | 1075 Frame* frame = page_->mainFrame(); |
| 1170 if (!frame) | 1076 if (!frame) |
| 1171 return; | 1077 return; |
| 1172 | 1078 |
| 1173 RefPtr<Frame> focused_frame = page_->focusController()->focusedFrame(); | 1079 RefPtr<Frame> focused_frame = page_->focusController()->focusedFrame(); |
| 1174 if (focused_frame.get()) { | 1080 if (focused_frame.get()) { |
| 1175 // Finish an ongoing composition to delete the composition node. | 1081 // Finish an ongoing composition to delete the composition node. |
| 1176 Editor* editor = focused_frame->editor(); | 1082 Editor* editor = focused_frame->editor(); |
| 1177 if (editor && editor->hasComposition()) | 1083 if (editor && editor->hasComposition()) |
| 1178 editor->confirmComposition(); | 1084 editor->confirmComposition(); |
| 1179 ime_accept_events_ = false; | 1085 ime_accept_events_ = false; |
| 1180 } | 1086 } |
| 1181 } | 1087 } |
| 1182 } | 1088 } |
| 1183 | 1089 |
| 1184 bool WebViewImpl::ImeSetComposition(int string_type, | 1090 bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command, |
| 1185 int cursor_position, | 1091 int cursor_position, |
| 1186 int target_start, | 1092 int target_start, |
| 1187 int target_end, | 1093 int target_end, |
| 1188 const std::wstring& ime_string) { | 1094 const WebString& ime_string) { |
| 1189 Frame* focused = GetFocusedWebCoreFrame(); | 1095 Frame* focused = GetFocusedWebCoreFrame(); |
| 1190 if (!focused || !ime_accept_events_) { | 1096 if (!focused || !ime_accept_events_) { |
| 1191 return false; | 1097 return false; |
| 1192 } | 1098 } |
| 1193 Editor* editor = focused->editor(); | 1099 Editor* editor = focused->editor(); |
| 1194 if (!editor) | 1100 if (!editor) |
| 1195 return false; | 1101 return false; |
| 1196 if (!editor->canEdit()) { | 1102 if (!editor->canEdit()) { |
| 1197 // The input focus has been moved to another WebWidget object. | 1103 // The input focus has been moved to another WebWidget object. |
| 1198 // We should use this |editor| object only to complete the ongoing | 1104 // We should use this |editor| object only to complete the ongoing |
| 1199 // composition. | 1105 // composition. |
| 1200 if (!editor->hasComposition()) | 1106 if (!editor->hasComposition()) |
| 1201 return false; | 1107 return false; |
| 1202 } | 1108 } |
| 1203 | 1109 |
| 1204 // We should verify the parent node of this IME composition node are | 1110 // We should verify the parent node of this IME composition node are |
| 1205 // editable because JavaScript may delete a parent node of the composition | 1111 // editable because JavaScript may delete a parent node of the composition |
| 1206 // node. In this case, WebKit crashes while deleting texts from the parent | 1112 // node. In this case, WebKit crashes while deleting texts from the parent |
| 1207 // node, which doesn't exist any longer. | 1113 // node, which doesn't exist any longer. |
| 1208 PassRefPtr<Range> range = editor->compositionRange(); | 1114 PassRefPtr<Range> range = editor->compositionRange(); |
| 1209 if (range) { | 1115 if (range) { |
| 1210 const Node* node = range->startPosition().node(); | 1116 const Node* node = range->startPosition().node(); |
| 1211 if (!node || !node->isContentEditable()) | 1117 if (!node || !node->isContentEditable()) |
| 1212 return false; | 1118 return false; |
| 1213 } | 1119 } |
| 1214 | 1120 |
| 1215 if (string_type == -1) { | 1121 if (command == WebCompositionCommandDiscard) { |
| 1216 // A browser process sent an IPC message which does not contain a valid | 1122 // A browser process sent an IPC message which does not contain a valid |
| 1217 // string, which means an ongoing composition has been canceled. | 1123 // string, which means an ongoing composition has been canceled. |
| 1218 // If the ongoing composition has been canceled, replace the ongoing | 1124 // If the ongoing composition has been canceled, replace the ongoing |
| 1219 // composition string with an empty string and complete it. | 1125 // composition string with an empty string and complete it. |
| 1220 WebCore::String empty_string; | 1126 WebCore::String empty_string; |
| 1221 WTF::Vector<WebCore::CompositionUnderline> empty_underlines; | 1127 WTF::Vector<WebCore::CompositionUnderline> empty_underlines; |
| 1222 editor->setComposition(empty_string, empty_underlines, 0, 0); | 1128 editor->setComposition(empty_string, empty_underlines, 0, 0); |
| 1223 } else { | 1129 } else { |
| 1224 // A browser process sent an IPC message which contains a string to be | 1130 // A browser process sent an IPC message which contains a string to be |
| 1225 // displayed in this Editor object. | 1131 // displayed in this Editor object. |
| 1226 // To display the given string, set the given string to the | 1132 // To display the given string, set the given string to the |
| 1227 // m_compositionNode member of this Editor object and display it. | 1133 // m_compositionNode member of this Editor object and display it. |
| 1228 if (target_start < 0) target_start = 0; | 1134 if (target_start < 0) |
| 1229 if (target_end < 0) target_end = static_cast<int>(ime_string.length()); | 1135 target_start = 0; |
| 1136 if (target_end < 0) |
| 1137 target_end = static_cast<int>(ime_string.length()); |
| 1230 WebCore::String composition_string( | 1138 WebCore::String composition_string( |
| 1231 webkit_glue::StdWStringToString(ime_string)); | 1139 webkit_glue::WebStringToString(ime_string)); |
| 1232 // Create custom underlines. | 1140 // Create custom underlines. |
| 1233 // To emphasize the selection, the selected region uses a solid black | 1141 // To emphasize the selection, the selected region uses a solid black |
| 1234 // for its underline while other regions uses a pale gray for theirs. | 1142 // for its underline while other regions uses a pale gray for theirs. |
| 1235 WTF::Vector<WebCore::CompositionUnderline> underlines(3); | 1143 WTF::Vector<WebCore::CompositionUnderline> underlines(3); |
| 1236 underlines[0].startOffset = 0; | 1144 underlines[0].startOffset = 0; |
| 1237 underlines[0].endOffset = target_start; | 1145 underlines[0].endOffset = target_start; |
| 1238 underlines[0].thick = true; | 1146 underlines[0].thick = true; |
| 1239 underlines[0].color.setRGB(0xd3, 0xd3, 0xd3); | 1147 underlines[0].color.setRGB(0xd3, 0xd3, 0xd3); |
| 1240 underlines[1].startOffset = target_start; | 1148 underlines[1].startOffset = target_start; |
| 1241 underlines[1].endOffset = target_end; | 1149 underlines[1].endOffset = target_end; |
| 1242 underlines[1].thick = true; | 1150 underlines[1].thick = true; |
| 1243 underlines[1].color.setRGB(0x00, 0x00, 0x00); | 1151 underlines[1].color.setRGB(0x00, 0x00, 0x00); |
| 1244 underlines[2].startOffset = target_end; | 1152 underlines[2].startOffset = target_end; |
| 1245 underlines[2].endOffset = static_cast<int>(ime_string.length()); | 1153 underlines[2].endOffset = static_cast<int>(ime_string.length()); |
| 1246 underlines[2].thick = true; | 1154 underlines[2].thick = true; |
| 1247 underlines[2].color.setRGB(0xd3, 0xd3, 0xd3); | 1155 underlines[2].color.setRGB(0xd3, 0xd3, 0xd3); |
| 1248 // When we use custom underlines, WebKit ("InlineTextBox.cpp" Line 282) | 1156 // When we use custom underlines, WebKit ("InlineTextBox.cpp" Line 282) |
| 1249 // prevents from writing a text in between 'selectionStart' and | 1157 // prevents from writing a text in between 'selectionStart' and |
| 1250 // 'selectionEnd' somehow. | 1158 // 'selectionEnd' somehow. |
| 1251 // Therefore, we use the 'cursor_position' for these arguments so that | 1159 // Therefore, we use the 'cursor_position' for these arguments so that |
| 1252 // there are not any characters in the above region. | 1160 // there are not any characters in the above region. |
| 1253 editor->setComposition(composition_string, underlines, | 1161 editor->setComposition(composition_string, underlines, |
| 1254 cursor_position, cursor_position); | 1162 cursor_position, cursor_position); |
| 1255 // The given string is a result string, which means the ongoing | 1163 // The given string is a result string, which means the ongoing |
| 1256 // composition has been completed. I have to call the | 1164 // composition has been completed. I have to call the |
| 1257 // Editor::confirmCompletion() and complete this composition. | 1165 // Editor::confirmCompletion() and complete this composition. |
| 1258 if (string_type == 1) { | 1166 if (command == WebCompositionCommandConfirm) |
| 1259 editor->confirmComposition(); | 1167 editor->confirmComposition(); |
| 1260 } | |
| 1261 } | 1168 } |
| 1262 | 1169 |
| 1263 return editor->hasComposition(); | 1170 return editor->hasComposition(); |
| 1264 } | 1171 } |
| 1265 | 1172 |
| 1266 bool WebViewImpl::ImeUpdateStatus(bool* enable_ime, | 1173 bool WebViewImpl::queryCompositionStatus(bool* enable_ime, |
| 1267 WebRect* caret_rect) { | 1174 WebRect* caret_rect) { |
| 1268 // Store whether the selected node needs IME and the caret rectangle. | 1175 // Store whether the selected node needs IME and the caret rectangle. |
| 1269 // This process consists of the following four steps: | 1176 // This process consists of the following four steps: |
| 1270 // 1. Retrieve the selection controller of the focused frame; | 1177 // 1. Retrieve the selection controller of the focused frame; |
| 1271 // 2. Retrieve the caret rectangle from the controller; | 1178 // 2. Retrieve the caret rectangle from the controller; |
| 1272 // 3. Convert the rectangle, which is relative to the parent view, to the | 1179 // 3. Convert the rectangle, which is relative to the parent view, to the |
| 1273 // one relative to the client window, and; | 1180 // one relative to the client window, and; |
| 1274 // 4. Store the converted rectangle. | 1181 // 4. Store the converted rectangle. |
| 1275 const Frame* focused = GetFocusedWebCoreFrame(); | 1182 const Frame* focused = GetFocusedWebCoreFrame(); |
| 1276 if (!focused) | 1183 if (!focused) |
| 1277 return false; | 1184 return false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1292 !controller->isInPasswordField(); | 1199 !controller->isInPasswordField(); |
| 1293 const FrameView* view = node->document()->view(); | 1200 const FrameView* view = node->document()->view(); |
| 1294 if (!view) | 1201 if (!view) |
| 1295 return false; | 1202 return false; |
| 1296 | 1203 |
| 1297 *caret_rect = webkit_glue::IntRectToWebRect( | 1204 *caret_rect = webkit_glue::IntRectToWebRect( |
| 1298 view->contentsToWindow(controller->absoluteCaretBounds())); | 1205 view->contentsToWindow(controller->absoluteCaretBounds())); |
| 1299 return true; | 1206 return true; |
| 1300 } | 1207 } |
| 1301 | 1208 |
| 1302 void WebViewImpl::SetTextDirection(WebTextDirection direction) { | 1209 void WebViewImpl::setTextDirection(WebTextDirection direction) { |
| 1303 // The Editor::setBaseWritingDirection() function checks if we can change | 1210 // The Editor::setBaseWritingDirection() function checks if we can change |
| 1304 // the text direction of the selected node and updates its DOM "dir" | 1211 // the text direction of the selected node and updates its DOM "dir" |
| 1305 // attribute and its CSS "direction" property. | 1212 // attribute and its CSS "direction" property. |
| 1306 // So, we just call the function as Safari does. | 1213 // So, we just call the function as Safari does. |
| 1307 const Frame* focused = GetFocusedWebCoreFrame(); | 1214 const Frame* focused = GetFocusedWebCoreFrame(); |
| 1308 if (!focused) | 1215 if (!focused) |
| 1309 return; | 1216 return; |
| 1310 | 1217 |
| 1311 Editor* editor = focused->editor(); | 1218 Editor* editor = focused->editor(); |
| 1312 if (!editor || !editor->canEdit()) | 1219 if (!editor || !editor->canEdit()) |
| 1313 return; | 1220 return; |
| 1314 | 1221 |
| 1315 switch (direction) { | 1222 switch (direction) { |
| 1316 case WEB_TEXT_DIRECTION_DEFAULT: | 1223 case WebTextDirectionDefault: |
| 1317 editor->setBaseWritingDirection(WebCore::NaturalWritingDirection); | 1224 editor->setBaseWritingDirection(WebCore::NaturalWritingDirection); |
| 1318 break; | 1225 break; |
| 1319 | 1226 |
| 1320 case WEB_TEXT_DIRECTION_LTR: | 1227 case WebTextDirectionLeftToRight: |
| 1321 editor->setBaseWritingDirection(WebCore::LeftToRightWritingDirection); | 1228 editor->setBaseWritingDirection(WebCore::LeftToRightWritingDirection); |
| 1322 break; | 1229 break; |
| 1323 | 1230 |
| 1324 case WEB_TEXT_DIRECTION_RTL: | 1231 case WebTextDirectionRightToLeft: |
| 1325 editor->setBaseWritingDirection(WebCore::RightToLeftWritingDirection); | 1232 editor->setBaseWritingDirection(WebCore::RightToLeftWritingDirection); |
| 1326 break; | 1233 break; |
| 1327 | 1234 |
| 1328 default: | 1235 default: |
| 1329 NOTIMPLEMENTED(); | 1236 NOTIMPLEMENTED(); |
| 1330 break; | 1237 break; |
| 1331 } | 1238 } |
| 1332 } | 1239 } |
| 1333 | 1240 |
| 1241 // WebView -------------------------------------------------------------------- |
| 1242 |
| 1243 bool WebViewImpl::ShouldClose() { |
| 1244 // TODO(creis): This should really cause a recursive depth-first walk of all |
| 1245 // frames in the tree, calling each frame's onbeforeunload. At the moment, |
| 1246 // we're consistent with Safari 3.1, not IE/FF. |
| 1247 Frame* frame = page_->focusController()->focusedOrMainFrame(); |
| 1248 if (!frame) |
| 1249 return true; |
| 1250 |
| 1251 return frame->shouldClose(); |
| 1252 } |
| 1253 |
| 1254 WebViewDelegate* WebViewImpl::GetDelegate() { |
| 1255 return delegate_; |
| 1256 } |
| 1257 |
| 1258 void WebViewImpl::SetDelegate(WebViewDelegate* delegate) { |
| 1259 delegate_ = delegate; |
| 1260 } |
| 1261 |
| 1262 WebFrame* WebViewImpl::GetMainFrame() { |
| 1263 return main_frame(); |
| 1264 } |
| 1265 |
| 1266 WebFrame* WebViewImpl::GetFocusedFrame() { |
| 1267 Frame* frame = GetFocusedWebCoreFrame(); |
| 1268 return frame ? WebFrameImpl::FromFrame(frame) : NULL; |
| 1269 } |
| 1270 |
| 1271 void WebViewImpl::SetFocusedFrame(WebFrame* frame) { |
| 1272 if (!frame) { |
| 1273 // Clears the focused frame if any. |
| 1274 Frame* frame = GetFocusedWebCoreFrame(); |
| 1275 if (frame) |
| 1276 frame->selection()->setFocused(false); |
| 1277 return; |
| 1278 } |
| 1279 WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); |
| 1280 WebCore::Frame* webcore_frame = frame_impl->frame(); |
| 1281 webcore_frame->page()->focusController()->setFocusedFrame(webcore_frame); |
| 1282 } |
| 1283 |
| 1284 WebFrame* WebViewImpl::GetFrameWithName(const std::wstring& name) { |
| 1285 String name_str = webkit_glue::StdWStringToString(name); |
| 1286 Frame* frame = page_->mainFrame()->tree()->find(name_str); |
| 1287 return frame ? WebFrameImpl::FromFrame(frame) : NULL; |
| 1288 } |
| 1289 |
| 1290 WebFrame* WebViewImpl::GetPreviousFrameBefore(WebFrame* frame, bool wrap) { |
| 1291 WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); |
| 1292 WebCore::Frame* previous = |
| 1293 frame_impl->frame()->tree()->traversePreviousWithWrap(wrap); |
| 1294 return previous ? WebFrameImpl::FromFrame(previous) : NULL; |
| 1295 } |
| 1296 |
| 1297 WebFrame* WebViewImpl::GetNextFrameAfter(WebFrame* frame, bool wrap) { |
| 1298 WebFrameImpl* frame_impl = static_cast<WebFrameImpl*>(frame); |
| 1299 WebCore::Frame* next = |
| 1300 frame_impl->frame()->tree()->traverseNextWithWrap(wrap); |
| 1301 return next ? WebFrameImpl::FromFrame(next) : NULL; |
| 1302 } |
| 1303 |
| 1304 // TODO(darin): these navigation methods should be killed |
| 1305 |
| 1306 void WebViewImpl::StopLoading() { |
| 1307 main_frame()->StopLoading(); |
| 1308 } |
| 1309 |
| 1310 void WebViewImpl::SetBackForwardListSize(int size) { |
| 1311 page_->backForwardList()->setCapacity(size); |
| 1312 } |
| 1313 |
| 1314 void WebViewImpl::ClearFocusedNode() { |
| 1315 if (!page_.get()) |
| 1316 return; |
| 1317 |
| 1318 RefPtr<Frame> frame = page_->mainFrame(); |
| 1319 if (!frame.get()) |
| 1320 return; |
| 1321 |
| 1322 RefPtr<Document> document = frame->document(); |
| 1323 if (!document.get()) |
| 1324 return; |
| 1325 |
| 1326 RefPtr<Node> old_focused_node = document->focusedNode(); |
| 1327 |
| 1328 // Clear the focused node. |
| 1329 document->setFocusedNode(NULL); |
| 1330 |
| 1331 if (!old_focused_node.get()) |
| 1332 return; |
| 1333 |
| 1334 // If a text field has focus, we need to make sure the selection controller |
| 1335 // knows to remove selection from it. Otherwise, the text field is still |
| 1336 // processing keyboard events even though focus has been moved to the page and |
| 1337 // keystrokes get eaten as a result. |
| 1338 if (old_focused_node->hasTagName(HTMLNames::textareaTag) || |
| 1339 (old_focused_node->hasTagName(HTMLNames::inputTag) && |
| 1340 static_cast<HTMLInputElement*>(old_focused_node.get())->isTextField())) { |
| 1341 // Clear the selection. |
| 1342 SelectionController* selection = frame->selection(); |
| 1343 selection->clear(); |
| 1344 } |
| 1345 } |
| 1346 |
| 1334 void WebViewImpl::SetInitialFocus(bool reverse) { | 1347 void WebViewImpl::SetInitialFocus(bool reverse) { |
| 1335 if (page_.get()) { | 1348 if (page_.get()) { |
| 1336 // Since we don't have a keyboard event, we'll create one. | 1349 // Since we don't have a keyboard event, we'll create one. |
| 1337 WebKeyboardEvent keyboard_event; | 1350 WebKeyboardEvent keyboard_event; |
| 1338 keyboard_event.type = WebInputEvent::RawKeyDown; | 1351 keyboard_event.type = WebInputEvent::RawKeyDown; |
| 1339 if (reverse) | 1352 if (reverse) |
| 1340 keyboard_event.modifiers = WebInputEvent::ShiftKey; | 1353 keyboard_event.modifiers = WebInputEvent::ShiftKey; |
| 1341 // VK_TAB which is only defined on Windows. | 1354 // VK_TAB which is only defined on Windows. |
| 1342 keyboard_event.windowsKeyCode = 0x09; | 1355 keyboard_event.windowsKeyCode = 0x09; |
| 1343 MakePlatformKeyboardEvent platform_event(keyboard_event); | 1356 MakePlatformKeyboardEvent platform_event(keyboard_event); |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 if (autocomplete_popup_client_->listSize() == 0) { | 1872 if (autocomplete_popup_client_->listSize() == 0) { |
| 1860 HideAutoCompletePopup(); | 1873 HideAutoCompletePopup(); |
| 1861 return; | 1874 return; |
| 1862 } | 1875 } |
| 1863 | 1876 |
| 1864 IntRect old_bounds = autocomplete_popup_->boundsRect(); | 1877 IntRect old_bounds = autocomplete_popup_->boundsRect(); |
| 1865 autocomplete_popup_->refresh(); | 1878 autocomplete_popup_->refresh(); |
| 1866 IntRect new_bounds = autocomplete_popup_->boundsRect(); | 1879 IntRect new_bounds = autocomplete_popup_->boundsRect(); |
| 1867 // Let's resize the backing window if necessary. | 1880 // Let's resize the backing window if necessary. |
| 1868 if (old_bounds != new_bounds) { | 1881 if (old_bounds != new_bounds) { |
| 1869 WebWidgetImpl* web_widget = | 1882 WebPopupMenuImpl* popup_menu = |
| 1870 static_cast<WebWidgetImpl*>(autocomplete_popup_->client()); | 1883 static_cast<WebPopupMenuImpl*>(autocomplete_popup_->client()); |
| 1871 web_widget->delegate()->SetWindowRect( | 1884 popup_menu->client()->setWindowRect( |
| 1872 web_widget, webkit_glue::IntRectToWebRect(new_bounds)); | 1885 webkit_glue::IntRectToWebRect(new_bounds)); |
| 1873 } | 1886 } |
| 1874 } | 1887 } |
| 1875 | 1888 |
| 1876 Node* WebViewImpl::GetFocusedNode() { | 1889 Node* WebViewImpl::GetFocusedNode() { |
| 1877 Frame* frame = page_->focusController()->focusedFrame(); | 1890 Frame* frame = page_->focusController()->focusedFrame(); |
| 1878 if (!frame) | 1891 if (!frame) |
| 1879 return NULL; | 1892 return NULL; |
| 1880 | 1893 |
| 1881 Document* document = frame->document(); | 1894 Document* document = frame->document(); |
| 1882 if (!document) | 1895 if (!document) |
| 1883 return NULL; | 1896 return NULL; |
| 1884 | 1897 |
| 1885 return document->focusedNode(); | 1898 return document->focusedNode(); |
| 1886 } | 1899 } |
| 1887 | 1900 |
| 1888 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { | 1901 HitTestResult WebViewImpl::HitTestResultForWindowPos(const IntPoint& pos) { |
| 1889 IntPoint doc_point( | 1902 IntPoint doc_point( |
| 1890 page_->mainFrame()->view()->windowToContents(pos)); | 1903 page_->mainFrame()->view()->windowToContents(pos)); |
| 1891 return page_->mainFrame()->eventHandler()-> | 1904 return page_->mainFrame()->eventHandler()-> |
| 1892 hitTestResultAtPoint(doc_point, false); | 1905 hitTestResultAtPoint(doc_point, false); |
| 1893 } | 1906 } |
| OLD | NEW |