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

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

Issue 149620: Use WebWidget from the WebKit API. This change also makes... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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/api/public/WebWidgetClient.h ('k') | webkit/glue/chromium_bridge_impl.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 8
9 MSVC_PUSH_WARNING_LEVEL(0); 9 MSVC_PUSH_WARNING_LEVEL(0);
10 #include "AccessibilityObject.h" 10 #include "AccessibilityObject.h"
(...skipping 28 matching lines...) Expand all
39 #include "webkit/api/public/WebCursorInfo.h" 39 #include "webkit/api/public/WebCursorInfo.h"
40 #include "webkit/api/public/WebInputEvent.h" 40 #include "webkit/api/public/WebInputEvent.h"
41 #include "webkit/api/public/WebKit.h" 41 #include "webkit/api/public/WebKit.h"
42 #include "webkit/api/public/WebPopupMenuInfo.h" 42 #include "webkit/api/public/WebPopupMenuInfo.h"
43 #include "webkit/api/public/WebRect.h" 43 #include "webkit/api/public/WebRect.h"
44 #include "webkit/api/public/WebURLRequest.h" 44 #include "webkit/api/public/WebURLRequest.h"
45 #include "webkit/api/src/WrappedResourceRequest.h" 45 #include "webkit/api/src/WrappedResourceRequest.h"
46 #include "webkit/glue/glue_util.h" 46 #include "webkit/glue/glue_util.h"
47 #include "webkit/glue/webframe_impl.h" 47 #include "webkit/glue/webframe_impl.h"
48 #include "webkit/glue/webkit_glue.h" 48 #include "webkit/glue/webkit_glue.h"
49 #include "webkit/glue/webpopupmenu_impl.h"
49 #include "webkit/glue/webview_delegate.h" 50 #include "webkit/glue/webview_delegate.h"
50 #include "webkit/glue/webview_impl.h" 51 #include "webkit/glue/webview_impl.h"
51 #include "webkit/glue/webwidget_impl.h"
52 52
53 using WebCore::PopupContainer; 53 using WebCore::PopupContainer;
54 using WebCore::PopupItem; 54 using WebCore::PopupItem;
55 55
56 using WebKit::WebCursorInfo; 56 using WebKit::WebCursorInfo;
57 using WebKit::WebInputEvent; 57 using WebKit::WebInputEvent;
58 using WebKit::WebMouseEvent; 58 using WebKit::WebMouseEvent;
59 using WebKit::WebNavigationPolicy;
59 using WebKit::WebPopupMenuInfo; 60 using WebKit::WebPopupMenuInfo;
60 using WebKit::WebRect; 61 using WebKit::WebRect;
61 using WebKit::WebURLRequest; 62 using WebKit::WebURLRequest;
62 using WebKit::WebVector; 63 using WebKit::WebVector;
64 using WebKit::WebWidget;
63 using WebKit::WrappedResourceRequest; 65 using WebKit::WrappedResourceRequest;
64 66
65 // Callback class that's given to the WebViewDelegate during a file choose 67 // Callback class that's given to the WebViewDelegate during a file choose
66 // operation. 68 // operation.
67 class WebFileChooserCallbackImpl : public WebFileChooserCallback { 69 class WebFileChooserCallbackImpl : public WebFileChooserCallback {
68 public: 70 public:
69 WebFileChooserCallbackImpl(PassRefPtr<WebCore::FileChooser> file_chooser) 71 WebFileChooserCallbackImpl(PassRefPtr<WebCore::FileChooser> file_chooser)
70 : file_chooser_(file_chooser) { 72 : file_chooser_(file_chooser) {
71 } 73 }
72 74
(...skipping 30 matching lines...) Expand all
103 ChromeClientImpl::~ChromeClientImpl() { 105 ChromeClientImpl::~ChromeClientImpl() {
104 } 106 }
105 107
106 void ChromeClientImpl::chromeDestroyed() { 108 void ChromeClientImpl::chromeDestroyed() {
107 delete this; 109 delete this;
108 } 110 }
109 111
110 void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) { 112 void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) {
111 WebViewDelegate* delegate = webview_->delegate(); 113 WebViewDelegate* delegate = webview_->delegate();
112 if (delegate) { 114 if (delegate) {
113 WebCore::IntRect ir(r); 115 delegate->setWindowRect(
114 delegate->SetWindowRect(webview_, 116 webkit_glue::IntRectToWebRect(WebCore::IntRect(r)));
115 gfx::Rect(ir.x(), ir.y(), ir.width(), ir.height()));
116 } 117 }
117 } 118 }
118 119
119 WebCore::FloatRect ChromeClientImpl::windowRect() { 120 WebCore::FloatRect ChromeClientImpl::windowRect() {
120 WebRect rect; 121 WebRect rect;
121 if (webview_->delegate()) { 122 if (webview_->delegate()) {
122 webview_->delegate()->GetRootWindowRect(webview_, &rect); 123 rect = webview_->delegate()->rootWindowRect();
123 } else { 124 } else {
124 // These numbers will be fairly wrong. The window's x/y coordinates will 125 // These numbers will be fairly wrong. The window's x/y coordinates will
125 // be the top left corner of the screen and the size will be the content 126 // be the top left corner of the screen and the size will be the content
126 // size instead of the window size. 127 // size instead of the window size.
127 rect.width = webview_->size().width; 128 rect.width = webview_->size().width;
128 rect.height = webview_->size().height; 129 rect.height = webview_->size().height;
129 } 130 }
130 return WebCore::FloatRect(static_cast<float>(rect.x), 131 return WebCore::FloatRect(webkit_glue::WebRectToIntRect(rect));
131 static_cast<float>(rect.y),
132 static_cast<float>(rect.width),
133 static_cast<float>(rect.height));
134 } 132 }
135 133
136 WebCore::FloatRect ChromeClientImpl::pageRect() { 134 WebCore::FloatRect ChromeClientImpl::pageRect() {
137 // We hide the details of the window's border thickness from the web page by 135 // We hide the details of the window's border thickness from the web page by
138 // simple re-using the window position here. So, from the point-of-view of 136 // simple re-using the window position here. So, from the point-of-view of
139 // the web page, the window has no border. 137 // the web page, the window has no border.
140 return windowRect(); 138 return windowRect();
141 } 139 }
142 140
143 float ChromeClientImpl::scaleFactor() { 141 float ChromeClientImpl::scaleFactor() {
144 // This is supposed to return the scale factor of the web page. It looks like 142 // This is supposed to return the scale factor of the web page. It looks like
145 // the implementor of the graphics layer is responsible for doing most of the 143 // the implementor of the graphics layer is responsible for doing most of the
146 // operations associated with scaling. However, this value is used ins some 144 // operations associated with scaling. However, this value is used ins some
147 // cases by WebCore. For example, this is used as a scaling factor in canvas 145 // cases by WebCore. For example, this is used as a scaling factor in canvas
148 // so that things drawn in it are scaled just like the web page is. 146 // so that things drawn in it are scaled just like the web page is.
149 // 147 //
150 // We don't currently implement scaling, so just return 1.0 (no scaling). 148 // We don't currently implement scaling, so just return 1.0 (no scaling).
151 return 1.0; 149 return 1.0;
152 } 150 }
153 151
154 void ChromeClientImpl::focus() { 152 void ChromeClientImpl::focus() {
155 WebViewDelegate* delegate = webview_->delegate(); 153 WebViewDelegate* delegate = webview_->delegate();
156 if (delegate) 154 if (delegate)
157 delegate->Focus(webview_); 155 delegate->didFocus();
158 156
159 // If accessibility is enabled, we should notify assistive technology that the 157 // If accessibility is enabled, we should notify assistive technology that the
160 // active AccessibilityObject changed. 158 // active AccessibilityObject changed.
161 WebCore::Document* doc = webview_->GetFocusedWebCoreFrame()->document(); 159 WebCore::Document* doc = webview_->GetFocusedWebCoreFrame()->document();
162 160
163 if (doc && doc->axObjectCache()->accessibilityEnabled()) { 161 if (doc && doc->axObjectCache()->accessibilityEnabled()) {
164 WebCore::Node* focused_node = webview_->GetFocusedNode(); 162 WebCore::Node* focused_node = webview_->GetFocusedNode();
165 163
166 if (!focused_node) { 164 if (!focused_node) {
167 // Could not retrieve focused Node. 165 // Could not retrieve focused Node.
168 return; 166 return;
169 } 167 }
170 168
171 // Retrieve the focused AccessibilityObject. 169 // Retrieve the focused AccessibilityObject.
172 WebCore::AccessibilityObject* focused_acc_obj = 170 WebCore::AccessibilityObject* focused_acc_obj =
173 doc->axObjectCache()->getOrCreate(focused_node->renderer()); 171 doc->axObjectCache()->getOrCreate(focused_node->renderer());
174 172
175 // Alert assistive technology that focus changed. 173 // Alert assistive technology that focus changed.
176 if (focused_acc_obj) { 174 if (focused_acc_obj) {
177 delegate->FocusAccessibilityObject(focused_acc_obj); 175 delegate->FocusAccessibilityObject(focused_acc_obj);
178 } 176 }
179 } 177 }
180 } 178 }
181 179
182 void ChromeClientImpl::unfocus() { 180 void ChromeClientImpl::unfocus() {
183 WebViewDelegate* delegate = webview_->delegate(); 181 WebViewDelegate* delegate = webview_->delegate();
184 if (delegate) 182 if (delegate)
185 delegate->Blur(webview_); 183 delegate->didBlur();
186 } 184 }
187 185
188 bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) { 186 bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) {
189 // For now the browser can always take focus if we're not running layout 187 // For now the browser can always take focus if we're not running layout
190 // tests. 188 // tests.
191 return !WebKit::layoutTestMode(); 189 return !WebKit::layoutTestMode();
192 } 190 }
193 191
194 void ChromeClientImpl::takeFocus(WebCore::FocusDirection direction) { 192 void ChromeClientImpl::takeFocus(WebCore::FocusDirection direction) {
195 WebViewDelegate* delegate = webview_->delegate(); 193 WebViewDelegate* delegate = webview_->delegate();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // new window be opened as a toplevel window. 248 // new window be opened as a toplevel window.
251 // 249 //
252 bool as_popup = 250 bool as_popup =
253 !toolbars_visible_ || 251 !toolbars_visible_ ||
254 !statusbar_visible_ || 252 !statusbar_visible_ ||
255 !scrollbars_visible_ || 253 !scrollbars_visible_ ||
256 !menubar_visible_ || 254 !menubar_visible_ ||
257 !resizable_ || 255 !resizable_ ||
258 !delegate->WasOpenedByUserGesture(); 256 !delegate->WasOpenedByUserGesture();
259 257
260 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 258 WebNavigationPolicy policy = WebKit::WebNavigationPolicyNewForegroundTab;
261 if (as_popup) 259 if (as_popup)
262 disposition = NEW_POPUP; 260 policy = WebKit::WebNavigationPolicyNewPopup;
263 if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event()) ) 261 if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event()) )
264 disposition = NEW_BACKGROUND_TAB; 262 policy = WebKit::WebNavigationPolicyNewBackgroundTab;
265 263
266 delegate->Show(webview_, disposition); 264 delegate->show(policy);
267 } 265 }
268 } 266 }
269 267
270 bool ChromeClientImpl::canRunModal() { 268 bool ChromeClientImpl::canRunModal() {
271 return webview_->delegate() != NULL; 269 return webview_->delegate() != NULL;
272 } 270 }
273 271
274 void ChromeClientImpl::runModal() { 272 void ChromeClientImpl::runModal() {
275 WebViewDelegate* delegate = webview_->delegate(); 273 WebViewDelegate* delegate = webview_->delegate();
276 if (delegate) 274 if (delegate)
277 delegate->RunModal(webview_); 275 delegate->runModal();
278 } 276 }
279 277
280 void ChromeClientImpl::setToolbarsVisible(bool value) { 278 void ChromeClientImpl::setToolbarsVisible(bool value) {
281 toolbars_visible_ = value; 279 toolbars_visible_ = value;
282 } 280 }
283 281
284 bool ChromeClientImpl::toolbarsVisible() { 282 bool ChromeClientImpl::toolbarsVisible() {
285 return toolbars_visible_; 283 return toolbars_visible_;
286 } 284 }
287 285
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 348
351 void ChromeClientImpl::closeWindowSoon() { 349 void ChromeClientImpl::closeWindowSoon() {
352 // Make sure this Page can no longer be found by JS. 350 // Make sure this Page can no longer be found by JS.
353 webview_->page()->setGroupName(WebCore::String()); 351 webview_->page()->setGroupName(WebCore::String());
354 352
355 // Make sure that all loading is stopped. Ensures that JS stops executing! 353 // Make sure that all loading is stopped. Ensures that JS stops executing!
356 webview_->StopLoading(); 354 webview_->StopLoading();
357 355
358 WebViewDelegate* delegate = webview_->delegate(); 356 WebViewDelegate* delegate = webview_->delegate();
359 if (delegate) 357 if (delegate)
360 delegate->CloseWidgetSoon(webview_); 358 delegate->closeWidgetSoon();
361 } 359 }
362 360
363 // Although a WebCore::Frame is passed in, we don't actually use it, since we 361 // Although a WebCore::Frame is passed in, we don't actually use it, since we
364 // already know our own webview_. 362 // already know our own webview_.
365 void ChromeClientImpl::runJavaScriptAlert(WebCore::Frame* frame, 363 void ChromeClientImpl::runJavaScriptAlert(WebCore::Frame* frame,
366 const WebCore::String& message) { 364 const WebCore::String& message) {
367 // Pass the request on to the WebView delegate, for more control. 365 // Pass the request on to the WebView delegate, for more control.
368 WebViewDelegate* delegate = webview_->delegate(); 366 WebViewDelegate* delegate = webview_->delegate();
369 if (delegate) { 367 if (delegate) {
370 #if USE(V8) 368 #if USE(V8)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // TODO(pamg): Consider controlling this with a user preference, when we have 425 // TODO(pamg): Consider controlling this with a user preference, when we have
428 // a preference system in place. 426 // a preference system in place.
429 // For now Chrome will allow link to take focus if we're not running layout 427 // For now Chrome will allow link to take focus if we're not running layout
430 // tests. 428 // tests.
431 return !WebKit::layoutTestMode(); 429 return !WebKit::layoutTestMode();
432 } 430 }
433 431
434 WebCore::IntRect ChromeClientImpl::windowResizerRect() const { 432 WebCore::IntRect ChromeClientImpl::windowResizerRect() const {
435 WebCore::IntRect result; 433 WebCore::IntRect result;
436 if (webview_->delegate()) { 434 if (webview_->delegate()) {
437 WebRect resizer_rect; 435 result = webkit_glue::WebRectToIntRect(
438 webview_->delegate()->GetRootWindowResizerRect(webview_, &resizer_rect); 436 webview_->delegate()->windowResizerRect());
439 result = webkit_glue::WebRectToIntRect(resizer_rect);
440 } 437 }
441 return result; 438 return result;
442 } 439 }
443 440
444 void ChromeClientImpl::repaint( 441 void ChromeClientImpl::repaint(
445 const WebCore::IntRect& paint_rect, bool content_changed, bool immediate, 442 const WebCore::IntRect& paint_rect, bool content_changed, bool immediate,
446 bool repaint_content_only) { 443 bool repaint_content_only) {
447 // Ignore spurious calls. 444 // Ignore spurious calls.
448 if (!content_changed || paint_rect.isEmpty()) 445 if (!content_changed || paint_rect.isEmpty())
449 return; 446 return;
450 WebViewDelegate* delegate = webview_->delegate(); 447 WebViewDelegate* delegate = webview_->delegate();
451 if (delegate) 448 if (delegate)
452 delegate->DidInvalidateRect(webview_, 449 delegate->didInvalidateRect(webkit_glue::IntRectToWebRect(paint_rect));
453 webkit_glue::IntRectToWebRect(paint_rect));
454 } 450 }
455 451
456 void ChromeClientImpl::scroll( 452 void ChromeClientImpl::scroll(
457 const WebCore::IntSize& scroll_delta, const WebCore::IntRect& scroll_rect, 453 const WebCore::IntSize& scroll_delta, const WebCore::IntRect& scroll_rect,
458 const WebCore::IntRect& clip_rect) { 454 const WebCore::IntRect& clip_rect) {
459 WebViewDelegate* delegate = webview_->delegate(); 455 WebViewDelegate* delegate = webview_->delegate();
460 if (delegate) { 456 if (delegate) {
461 int dx = scroll_delta.width(); 457 int dx = scroll_delta.width();
462 int dy = scroll_delta.height(); 458 int dy = scroll_delta.height();
463 delegate->DidScrollRect(webview_, dx, dy, 459 delegate->didScrollRect(
464 webkit_glue::IntRectToWebRect(clip_rect)); 460 dx, dy, webkit_glue::IntRectToWebRect(clip_rect));
465 } 461 }
466 } 462 }
467 463
468 WebCore::IntPoint ChromeClientImpl::screenToWindow( 464 WebCore::IntPoint ChromeClientImpl::screenToWindow(
469 const WebCore::IntPoint&) const { 465 const WebCore::IntPoint&) const {
470 NOTIMPLEMENTED(); 466 NOTIMPLEMENTED();
471 return WebCore::IntPoint(); 467 return WebCore::IntPoint();
472 } 468 }
473 469
474 WebCore::IntRect ChromeClientImpl::windowToScreen( 470 WebCore::IntRect ChromeClientImpl::windowToScreen(
475 const WebCore::IntRect& rect) const { 471 const WebCore::IntRect& rect) const {
476 WebCore::IntRect screen_rect(rect); 472 WebCore::IntRect screen_rect(rect);
477 473
478 WebViewDelegate* delegate = webview_->delegate(); 474 WebViewDelegate* delegate = webview_->delegate();
479 if (delegate) { 475 if (delegate) {
480 WebRect window_rect; 476 WebRect window_rect = delegate->windowRect();
481 delegate->GetWindowRect(webview_, &window_rect);
482 screen_rect.move(window_rect.x, window_rect.y); 477 screen_rect.move(window_rect.x, window_rect.y);
483 } 478 }
484 479
485 return screen_rect; 480 return screen_rect;
486 } 481 }
487 482
488 PlatformWidget ChromeClientImpl::platformWindow() const { 483 PlatformWidget ChromeClientImpl::platformWindow() const {
489 return NULL; 484 return NULL;
490 } 485 }
491 486
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 555
561 WebWidget* webwidget; 556 WebWidget* webwidget;
562 if (handle_externally) { 557 if (handle_externally) {
563 WebPopupMenuInfo popup_info; 558 WebPopupMenuInfo popup_info;
564 GetPopupMenuInfo(popup_container, &popup_info); 559 GetPopupMenuInfo(popup_container, &popup_info);
565 webwidget = delegate->CreatePopupWidgetWithInfo(webview_, popup_info); 560 webwidget = delegate->CreatePopupWidgetWithInfo(webview_, popup_info);
566 } else { 561 } else {
567 webwidget = delegate->CreatePopupWidget(webview_, activatable); 562 webwidget = delegate->CreatePopupWidget(webview_, activatable);
568 } 563 }
569 564
570 static_cast<WebWidgetImpl*>(webwidget)->Init( 565 static_cast<WebPopupMenuImpl*>(webwidget)->Init(
571 popup_container, webkit_glue::IntRectToWebRect(bounds)); 566 popup_container, webkit_glue::IntRectToWebRect(bounds));
572 } 567 }
573 568
574 void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) { 569 void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) {
575 if (ignore_next_set_cursor_) { 570 if (ignore_next_set_cursor_) {
576 ignore_next_set_cursor_ = false; 571 ignore_next_set_cursor_ = false;
577 return; 572 return;
578 } 573 }
579 574
580 WebViewDelegate* delegate = webview_->delegate(); 575 WebViewDelegate* delegate = webview_->delegate();
581 if (delegate) 576 if (delegate)
582 delegate->SetCursor(webview_, cursor); 577 delegate->didChangeCursor(cursor);
583 } 578 }
584 579
585 void ChromeClientImpl::SetCursorForPlugin(const WebCursorInfo& cursor) { 580 void ChromeClientImpl::SetCursorForPlugin(const WebCursorInfo& cursor) {
586 SetCursor(cursor); 581 SetCursor(cursor);
587 // Currently, Widget::setCursor is always called after this function in 582 // Currently, Widget::setCursor is always called after this function in
588 // EventHandler.cpp and since we don't want that we set a flag indicating 583 // EventHandler.cpp and since we don't want that we set a flag indicating
589 // that the next SetCursor call is to be ignored. 584 // that the next SetCursor call is to be ignored.
590 ignore_next_set_cursor_ = true; 585 ignore_next_set_cursor_ = true;
591 } 586 }
592 587
(...skipping 28 matching lines...) Expand all
621 break; 616 break;
622 default: 617 default:
623 NOTREACHED(); 618 NOTREACHED();
624 } 619 }
625 } 620 }
626 621
627 info->itemHeight = popup_container->menuItemHeight(); 622 info->itemHeight = popup_container->menuItemHeight();
628 info->selectedIndex = popup_container->selectedIndex(); 623 info->selectedIndex = popup_container->selectedIndex();
629 info->items.swap(output_items); 624 info->items.swap(output_items);
630 } 625 }
OLDNEW
« no previous file with comments | « webkit/api/public/WebWidgetClient.h ('k') | webkit/glue/chromium_bridge_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698