Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Side by Side Diff: webkit/glue/webview_impl.cc

Issue 293001: Delete glue/webview{_delegate}.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webview_impl.h ('k') | webkit/glue/webview_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2007-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2007-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 MSVC_PUSH_WARNING_LEVEL(0); 9 MSVC_PUSH_WARNING_LEVEL(0);
10 #include "AXObjectCache.h" 10 #include "AXObjectCache.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "base/logging.h" 63 #include "base/logging.h"
64 #include "base/message_loop.h" 64 #include "base/message_loop.h"
65 #include "webkit/api/public/WebAccessibilityObject.h" 65 #include "webkit/api/public/WebAccessibilityObject.h"
66 #include "webkit/api/public/WebDragData.h" 66 #include "webkit/api/public/WebDragData.h"
67 #include "webkit/api/public/WebInputEvent.h" 67 #include "webkit/api/public/WebInputEvent.h"
68 #include "webkit/api/public/WebMediaPlayerAction.h" 68 #include "webkit/api/public/WebMediaPlayerAction.h"
69 #include "webkit/api/public/WebPoint.h" 69 #include "webkit/api/public/WebPoint.h"
70 #include "webkit/api/public/WebRect.h" 70 #include "webkit/api/public/WebRect.h"
71 #include "webkit/api/public/WebString.h" 71 #include "webkit/api/public/WebString.h"
72 #include "webkit/api/public/WebVector.h" 72 #include "webkit/api/public/WebVector.h"
73 #include "webkit/api/public/WebViewClient.h"
73 #include "webkit/api/src/WebInputEventConversion.h" 74 #include "webkit/api/src/WebInputEventConversion.h"
74 #include "webkit/api/src/WebSettingsImpl.h" 75 #include "webkit/api/src/WebSettingsImpl.h"
75 #include "webkit/glue/dom_operations.h" 76 #include "webkit/glue/dom_operations.h"
76 #include "webkit/glue/glue_serialize.h" 77 #include "webkit/glue/glue_serialize.h"
77 #include "webkit/glue/glue_util.h" 78 #include "webkit/glue/glue_util.h"
78 #include "webkit/glue/image_resource_fetcher.h" 79 #include "webkit/glue/image_resource_fetcher.h"
79 #include "webkit/glue/searchable_form_data.h" 80 #include "webkit/glue/searchable_form_data.h"
80 #include "webkit/glue/webdevtoolsagent_impl.h" 81 #include "webkit/glue/webdevtoolsagent_impl.h"
81 #include "webkit/glue/webkit_glue.h" 82 #include "webkit/glue/webkit_glue.h"
82 #include "webkit/glue/webpopupmenu_impl.h" 83 #include "webkit/glue/webpopupmenu_impl.h"
83 #include "webkit/glue/webdevtoolsclient.h" 84 #include "webkit/glue/webdevtoolsclient.h"
84 #include "webkit/glue/webview_delegate.h"
85 #include "webkit/glue/webview_impl.h" 85 #include "webkit/glue/webview_impl.h"
86 86
87 // Get rid of WTF's pow define so we can use std::pow. 87 // Get rid of WTF's pow define so we can use std::pow.
88 #undef pow 88 #undef pow
89 #include <cmath> // for std::pow 89 #include <cmath> // for std::pow
90 90
91 using namespace WebCore; 91 using namespace WebCore;
92 92
93 using WebKit::PlatformKeyboardEventBuilder; 93 using WebKit::PlatformKeyboardEventBuilder;
94 using WebKit::PlatformMouseEventBuilder; 94 using WebKit::PlatformMouseEventBuilder;
(...skipping 24 matching lines...) Expand all
119 using WebKit::WebSettings; 119 using WebKit::WebSettings;
120 using WebKit::WebSettingsImpl; 120 using WebKit::WebSettingsImpl;
121 using WebKit::WebSize; 121 using WebKit::WebSize;
122 using WebKit::WebString; 122 using WebKit::WebString;
123 using WebKit::WebTextDirection; 123 using WebKit::WebTextDirection;
124 using WebKit::WebTextDirectionDefault; 124 using WebKit::WebTextDirectionDefault;
125 using WebKit::WebTextDirectionLeftToRight; 125 using WebKit::WebTextDirectionLeftToRight;
126 using WebKit::WebTextDirectionRightToLeft; 126 using WebKit::WebTextDirectionRightToLeft;
127 using WebKit::WebURL; 127 using WebKit::WebURL;
128 using WebKit::WebVector; 128 using WebKit::WebVector;
129 using WebKit::WebViewClient;
129 130
130 using webkit_glue::AccessibilityObjectToWebAccessibilityObject; 131 using webkit_glue::AccessibilityObjectToWebAccessibilityObject;
131 132
132 // Change the text zoom level by kTextSizeMultiplierRatio each time the user 133 // 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 134 // 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 135 // 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 136 // those in Apple's port in WebKit/WebKit/WebView/WebView.mm
136 static const double kTextSizeMultiplierRatio = 1.2; 137 static const double kTextSizeMultiplierRatio = 1.2;
137 static const double kMinTextSizeMultiplier = 0.5; 138 static const double kMinTextSizeMultiplier = 0.5;
138 static const double kMaxTextSizeMultiplier = 3.0; 139 static const double kMaxTextSizeMultiplier = 3.0;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 true, // loopSelectionNavigation 335 true, // loopSelectionNavigation
335 true, // restrictWidthOfListBox. Same as other browser (Fx, IE, and safari) 336 true, // restrictWidthOfListBox. Same as other browser (Fx, IE, and safari)
336 // For autocomplete, we use the direction of the input field as the direction 337 // For autocomplete, we use the direction of the input field as the direction
337 // of the popup items. The main reason is to keep the display of items in 338 // of the popup items. The main reason is to keep the display of items in
338 // drop-down the same as the items in the input field. 339 // drop-down the same as the items in the input field.
339 WebCore::PopupContainerSettings::DOMElementDirection, 340 WebCore::PopupContainerSettings::DOMElementDirection,
340 }; 341 };
341 342
342 // WebView ---------------------------------------------------------------- 343 // WebView ----------------------------------------------------------------
343 344
344 /*static*/ 345 namespace WebKit {
345 WebView* WebView::Create(WebViewDelegate* delegate) { 346
346 WebViewImpl* instance = new WebViewImpl(delegate); 347 // static
348 WebView* WebView::create(WebViewClient* client) {
349 WebViewImpl* instance = new WebViewImpl(client);
347 instance->AddRef(); 350 instance->AddRef();
348 return instance; 351 return instance;
349 } 352 }
350 353
354 // static
355 void WebView::updateVisitedLinkState(unsigned long long link_hash) {
356 WebCore::Page::visitedStateChanged(
357 WebCore::PageGroup::pageGroup(pageGroupName), link_hash);
358 }
359
360 // static
361 void WebView::resetVisitedLinkState() {
362 WebCore::Page::allVisitedStateChanged(
363 WebCore::PageGroup::pageGroup(pageGroupName));
364 }
365
366 } // namespace WebKit
367
351 void WebViewImpl::initializeMainFrame(WebFrameClient* frame_client) { 368 void WebViewImpl::initializeMainFrame(WebFrameClient* frame_client) {
352 // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame 369 // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame
353 // and releases that reference once the corresponding Frame is destroyed. 370 // and releases that reference once the corresponding Frame is destroyed.
354 RefPtr<WebFrameImpl> main_frame = WebFrameImpl::create(frame_client); 371 RefPtr<WebFrameImpl> main_frame = WebFrameImpl::create(frame_client);
355 372
356 main_frame->InitMainFrame(this); 373 main_frame->InitMainFrame(this);
357 374
358 if (client()) { 375 if (client_) {
359 WebDevToolsAgentClient* tools_client = client()->devToolsAgentClient(); 376 WebDevToolsAgentClient* tools_client = client_->devToolsAgentClient();
360 if (tools_client) 377 if (tools_client)
361 devtools_agent_.reset(new WebDevToolsAgentImpl(this, tools_client)); 378 devtools_agent_.reset(new WebDevToolsAgentImpl(this, tools_client));
362 } 379 }
363 380
364 // Restrict the access to the local file system 381 // Restrict the access to the local file system
365 // (see WebView.mm WebView::_commonInitializationWithFrameName). 382 // (see WebView.mm WebView::_commonInitializationWithFrameName).
366 SecurityOrigin::setLocalLoadPolicy( 383 SecurityOrigin::setLocalLoadPolicy(
367 SecurityOrigin::AllowLocalLoadsForLocalOnly); 384 SecurityOrigin::AllowLocalLoadsForLocalOnly);
368 } 385 }
369 386
370 // static 387 WebViewImpl::WebViewImpl(WebViewClient* client)
371 void WebView::UpdateVisitedLinkState(uint64 link_hash) { 388 : client_(client),
372 WebCore::Page::visitedStateChanged(
373 WebCore::PageGroup::pageGroup(pageGroupName), link_hash);
374 }
375
376 // static
377 void WebView::ResetVisitedLinkState() {
378 WebCore::Page::allVisitedStateChanged(
379 WebCore::PageGroup::pageGroup(pageGroupName));
380 }
381
382 WebViewImpl::WebViewImpl(WebViewDelegate* delegate)
383 : delegate_(delegate),
384 ALLOW_THIS_IN_INITIALIZER_LIST(back_forward_list_client_impl_(this)), 389 ALLOW_THIS_IN_INITIALIZER_LIST(back_forward_list_client_impl_(this)),
385 ALLOW_THIS_IN_INITIALIZER_LIST(chrome_client_impl_(this)), 390 ALLOW_THIS_IN_INITIALIZER_LIST(chrome_client_impl_(this)),
386 ALLOW_THIS_IN_INITIALIZER_LIST(context_menu_client_impl_(this)), 391 ALLOW_THIS_IN_INITIALIZER_LIST(context_menu_client_impl_(this)),
387 ALLOW_THIS_IN_INITIALIZER_LIST(drag_client_impl_(this)), 392 ALLOW_THIS_IN_INITIALIZER_LIST(drag_client_impl_(this)),
388 ALLOW_THIS_IN_INITIALIZER_LIST(editor_client_impl_(this)), 393 ALLOW_THIS_IN_INITIALIZER_LIST(editor_client_impl_(this)),
389 ALLOW_THIS_IN_INITIALIZER_LIST(inspector_client_impl_(this)), 394 ALLOW_THIS_IN_INITIALIZER_LIST(inspector_client_impl_(this)),
390 observed_new_navigation_(false), 395 observed_new_navigation_(false),
391 #ifndef NDEBUG 396 #ifndef NDEBUG
392 new_navigation_loader_(NULL), 397 new_navigation_loader_(NULL),
393 #endif 398 #endif
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 main_frame()->frame()->eventHandler()->mouseMoved( 462 main_frame()->frame()->eventHandler()->mouseMoved(
458 PlatformMouseEventBuilder(main_frame()->frameview(), event)); 463 PlatformMouseEventBuilder(main_frame()->frameview(), event));
459 } 464 }
460 465
461 void WebViewImpl::MouseLeave(const WebMouseEvent& event) { 466 void WebViewImpl::MouseLeave(const WebMouseEvent& event) {
462 // This event gets sent as the main frame is closing. In that case, just 467 // This event gets sent as the main frame is closing. In that case, just
463 // ignore it. 468 // ignore it.
464 if (!main_frame() || !main_frame()->frameview()) 469 if (!main_frame() || !main_frame()->frameview())
465 return; 470 return;
466 471
467 client()->setMouseOverURL(WebURL()); 472 client_->setMouseOverURL(WebURL());
468 473
469 main_frame()->frame()->eventHandler()->handleMouseMoveEvent( 474 main_frame()->frame()->eventHandler()->handleMouseMoveEvent(
470 PlatformMouseEventBuilder(main_frame()->frameview(), event)); 475 PlatformMouseEventBuilder(main_frame()->frameview(), event));
471 } 476 }
472 477
473 void WebViewImpl::MouseDown(const WebMouseEvent& event) { 478 void WebViewImpl::MouseDown(const WebMouseEvent& event) {
474 if (!main_frame() || !main_frame()->frameview()) 479 if (!main_frame() || !main_frame()->frameview())
475 return; 480 return;
476 481
477 last_mouse_down_point_ = gfx::Point(event.x, event.y); 482 last_mouse_down_point_ = gfx::Point(event.x, event.y);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 return false; 682 return false;
678 } 683 }
679 684
680 int selected_index = autocomplete_popup_->selectedIndex(); 685 int selected_index = autocomplete_popup_->selectedIndex();
681 WebCore::HTMLInputElement* input_element = 686 WebCore::HTMLInputElement* input_element =
682 static_cast<WebCore::HTMLInputElement*>(element); 687 static_cast<WebCore::HTMLInputElement*>(element);
683 const WebString& name = webkit_glue::StringToWebString( 688 const WebString& name = webkit_glue::StringToWebString(
684 input_element->name()); 689 input_element->name());
685 const WebString& value = webkit_glue::StringToWebString( 690 const WebString& value = webkit_glue::StringToWebString(
686 autocomplete_popup_client_->itemText(selected_index)); 691 autocomplete_popup_client_->itemText(selected_index));
687 client()->removeAutofillSuggestions(name, value); 692 client_->removeAutofillSuggestions(name, value);
688 // Update the entries in the currently showing popup to reflect the 693 // Update the entries in the currently showing popup to reflect the
689 // deletion. 694 // deletion.
690 autocomplete_popup_client_->RemoveItemAtIndex(selected_index); 695 autocomplete_popup_client_->RemoveItemAtIndex(selected_index);
691 RefreshAutofillPopup(); 696 RefreshAutofillPopup();
692 return false; 697 return false;
693 } 698 }
694 699
695 if (!autocomplete_popup_->isInterestedInEventForKey(event.windowsKeyCode)) 700 if (!autocomplete_popup_->isInterestedInEventForKey(event.windowsKeyCode))
696 return false; 701 return false;
697 702
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 if (devtools_agent_.get()) 972 if (devtools_agent_.get())
968 devtools_agent_.reset(NULL); 973 devtools_agent_.reset(NULL);
969 974
970 // We drop the client after the page has been destroyed to support the 975 // We drop the client after the page has been destroyed to support the
971 // WebFrameClient::didDestroyScriptContext method. 976 // WebFrameClient::didDestroyScriptContext method.
972 if (main_frame) 977 if (main_frame)
973 main_frame->drop_client(); 978 main_frame->drop_client();
974 979
975 // Reset the delegate to prevent notifications being sent as we're being 980 // Reset the delegate to prevent notifications being sent as we're being
976 // deleted. 981 // deleted.
977 delegate_ = NULL; 982 client_ = NULL;
978 983
979 Release(); // Balances AddRef from WebView::Create 984 Release(); // Balances AddRef from WebView::create
980 } 985 }
981 986
982 void WebViewImpl::resize(const WebSize& new_size) { 987 void WebViewImpl::resize(const WebSize& new_size) {
983 if (size_ == new_size) 988 if (size_ == new_size)
984 return; 989 return;
985 size_ = new_size; 990 size_ = new_size;
986 991
987 if (main_frame()->frameview()) { 992 if (main_frame()->frameview()) {
988 main_frame()->frameview()->resize(size_.width, size_.height); 993 main_frame()->frameview()->resize(size_.width, size_.height);
989 main_frame()->frame()->eventHandler()->sendResizeEvent(); 994 main_frame()->frame()->eventHandler()->sendResizeEvent();
990 } 995 }
991 996
992 if (delegate_) { 997 if (client_) {
993 WebRect damaged_rect(0, 0, size_.width, size_.height); 998 WebRect damaged_rect(0, 0, size_.width, size_.height);
994 delegate_->didInvalidateRect(damaged_rect); 999 client_->didInvalidateRect(damaged_rect);
995 } 1000 }
996 } 1001 }
997 1002
998 void WebViewImpl::layout() { 1003 void WebViewImpl::layout() {
999 WebFrameImpl* webframe = main_frame(); 1004 WebFrameImpl* webframe = main_frame();
1000 if (webframe) { 1005 if (webframe) {
1001 // In order for our child HWNDs (NativeWindowWidgets) to update properly, 1006 // In order for our child HWNDs (NativeWindowWidgets) to update properly,
1002 // they need to be told that we are updating the screen. The problem is 1007 // they need to be told that we are updating the screen. The problem is
1003 // that the native widgets need to recalculate their clip region and not 1008 // that the native widgets need to recalculate their clip region and not
1004 // overlap any of our non-native widgets. To force the resizing, call 1009 // overlap any of our non-native widgets. To force the resizing, call
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 } else { 1829 } else {
1825 *policy = WebKit::WebNavigationPolicyDownload; 1830 *policy = WebKit::WebNavigationPolicyDownload;
1826 } 1831 }
1827 } 1832 }
1828 return true; 1833 return true;
1829 } 1834 }
1830 1835
1831 void WebViewImpl::StartDragging(const WebPoint& event_pos, 1836 void WebViewImpl::StartDragging(const WebPoint& event_pos,
1832 const WebDragData& drag_data, 1837 const WebDragData& drag_data,
1833 WebDragOperationsMask mask) { 1838 WebDragOperationsMask mask) {
1834 if (!client()) 1839 if (!client_)
1835 return; 1840 return;
1836 DCHECK(!doing_drag_and_drop_); 1841 DCHECK(!doing_drag_and_drop_);
1837 doing_drag_and_drop_ = true; 1842 doing_drag_and_drop_ = true;
1838 client()->startDragging(event_pos, drag_data, mask); 1843 client_->startDragging(event_pos, drag_data, mask);
1839 } 1844 }
1840 1845
1841 void WebViewImpl::SetCurrentHistoryItem(WebCore::HistoryItem* item) { 1846 void WebViewImpl::SetCurrentHistoryItem(WebCore::HistoryItem* item) {
1842 back_forward_list_client_impl_.SetCurrentHistoryItem(item); 1847 back_forward_list_client_impl_.SetCurrentHistoryItem(item);
1843 } 1848 }
1844 1849
1845 WebCore::HistoryItem* WebViewImpl::GetPreviousHistoryItem() { 1850 WebCore::HistoryItem* WebViewImpl::GetPreviousHistoryItem() {
1846 return back_forward_list_client_impl_.GetPreviousHistoryItem(); 1851 return back_forward_list_client_impl_.GetPreviousHistoryItem();
1847 } 1852 }
1848 1853
(...skipping 15 matching lines...) Expand all
1864 autocomplete_popup_showing_ = false; 1869 autocomplete_popup_showing_ = false;
1865 } 1870 }
1866 1871
1867 void WebViewImpl::SetIgnoreInputEvents(bool new_value) { 1872 void WebViewImpl::SetIgnoreInputEvents(bool new_value) {
1868 DCHECK(ignore_input_events_ != new_value); 1873 DCHECK(ignore_input_events_ != new_value);
1869 ignore_input_events_ = new_value; 1874 ignore_input_events_ = new_value;
1870 } 1875 }
1871 1876
1872 #if ENABLE(NOTIFICATIONS) 1877 #if ENABLE(NOTIFICATIONS)
1873 WebKit::NotificationPresenterImpl* WebViewImpl::GetNotificationPresenter() { 1878 WebKit::NotificationPresenterImpl* WebViewImpl::GetNotificationPresenter() {
1874 if (!notification_presenter_.isInitialized() && client()) 1879 if (!notification_presenter_.isInitialized() && client_)
1875 notification_presenter_.initialize(client()->notificationPresenter()); 1880 notification_presenter_.initialize(client_->notificationPresenter());
1876 return &notification_presenter_; 1881 return &notification_presenter_;
1877 } 1882 }
1878 #endif 1883 #endif
1879 1884
1880 void WebViewImpl::RefreshAutofillPopup() { 1885 void WebViewImpl::RefreshAutofillPopup() {
1881 DCHECK(autocomplete_popup_showing_); 1886 DCHECK(autocomplete_popup_showing_);
1882 1887
1883 // Hide the popup if it has become empty. 1888 // Hide the popup if it has become empty.
1884 if (autocomplete_popup_client_->listSize() == 0) { 1889 if (autocomplete_popup_client_->listSize() == 0) {
1885 HideAutoCompletePopup(); 1890 HideAutoCompletePopup();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 hitTestResultAtPoint(doc_point, false); 1922 hitTestResultAtPoint(doc_point, false);
1918 } 1923 }
1919 1924
1920 void WebViewImpl::setTabsToLinks(bool enable) { 1925 void WebViewImpl::setTabsToLinks(bool enable) {
1921 tabs_to_links_ = enable; 1926 tabs_to_links_ = enable;
1922 } 1927 }
1923 1928
1924 bool WebViewImpl::tabsToLinks() const { 1929 bool WebViewImpl::tabsToLinks() const {
1925 return tabs_to_links_; 1930 return tabs_to_links_;
1926 } 1931 }
OLDNEW
« no previous file with comments | « webkit/glue/webview_impl.h ('k') | webkit/glue/webview_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698