OLD | NEW |
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 "AccessibilityObject.h" | 7 #include "AccessibilityObject.h" |
8 #include "AXObjectCache.h" | 8 #include "AXObjectCache.h" |
9 #include "CharacterNames.h" | 9 #include "CharacterNames.h" |
10 #include "Console.h" | 10 #include "Console.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "Node.h" | 21 #include "Node.h" |
22 #include "Page.h" | 22 #include "Page.h" |
23 #include "PopupMenuChromium.h" | 23 #include "PopupMenuChromium.h" |
24 #include "ScriptController.h" | 24 #include "ScriptController.h" |
25 #include "WindowFeatures.h" | 25 #include "WindowFeatures.h" |
26 #if USE(V8) | 26 #if USE(V8) |
27 #include "V8Proxy.h" | 27 #include "V8Proxy.h" |
28 #endif | 28 #endif |
29 #undef LOG | 29 #undef LOG |
30 | 30 |
31 #include "googleurl/src/gurl.h" | |
32 #include "webkit/api/public/WebConsoleMessage.h" | 31 #include "webkit/api/public/WebConsoleMessage.h" |
33 #include "webkit/api/public/WebCursorInfo.h" | 32 #include "webkit/api/public/WebCursorInfo.h" |
34 #include "webkit/api/public/WebFileChooserCompletion.h" | 33 #include "webkit/api/public/WebFileChooserCompletion.h" |
35 #include "webkit/api/public/WebFrameClient.h" | 34 #include "webkit/api/public/WebFrameClient.h" |
36 #include "webkit/api/public/WebInputEvent.h" | 35 #include "webkit/api/public/WebInputEvent.h" |
37 #include "webkit/api/public/WebKit.h" | 36 #include "webkit/api/public/WebKit.h" |
38 #include "webkit/api/public/WebPopupMenuInfo.h" | 37 #include "webkit/api/public/WebPopupMenuInfo.h" |
39 #include "webkit/api/public/WebRect.h" | 38 #include "webkit/api/public/WebRect.h" |
40 #include "webkit/api/public/WebTextDirection.h" | 39 #include "webkit/api/public/WebTextDirection.h" |
41 #include "webkit/api/public/WebURLRequest.h" | 40 #include "webkit/api/public/WebURLRequest.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 81 } |
83 | 82 |
84 ChromeClientImpl::~ChromeClientImpl() { | 83 ChromeClientImpl::~ChromeClientImpl() { |
85 } | 84 } |
86 | 85 |
87 void ChromeClientImpl::chromeDestroyed() { | 86 void ChromeClientImpl::chromeDestroyed() { |
88 // Our lifetime is bound to the WebViewImpl. | 87 // Our lifetime is bound to the WebViewImpl. |
89 } | 88 } |
90 | 89 |
91 void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) { | 90 void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) { |
92 WebViewDelegate* delegate = webview_->delegate(); | 91 if (webview_->client()) { |
93 if (delegate) { | 92 webview_->client()->setWindowRect( |
94 delegate->setWindowRect( | |
95 webkit_glue::IntRectToWebRect(WebCore::IntRect(r))); | 93 webkit_glue::IntRectToWebRect(WebCore::IntRect(r))); |
96 } | 94 } |
97 } | 95 } |
98 | 96 |
99 WebCore::FloatRect ChromeClientImpl::windowRect() { | 97 WebCore::FloatRect ChromeClientImpl::windowRect() { |
100 WebRect rect; | 98 WebRect rect; |
101 if (webview_->delegate()) { | 99 if (webview_->client()) { |
102 rect = webview_->delegate()->rootWindowRect(); | 100 rect = webview_->client()->rootWindowRect(); |
103 } else { | 101 } else { |
104 // These numbers will be fairly wrong. The window's x/y coordinates will | 102 // These numbers will be fairly wrong. The window's x/y coordinates will |
105 // be the top left corner of the screen and the size will be the content | 103 // be the top left corner of the screen and the size will be the content |
106 // size instead of the window size. | 104 // size instead of the window size. |
107 rect.width = webview_->size().width; | 105 rect.width = webview_->size().width; |
108 rect.height = webview_->size().height; | 106 rect.height = webview_->size().height; |
109 } | 107 } |
110 return WebCore::FloatRect(webkit_glue::WebRectToIntRect(rect)); | 108 return WebCore::FloatRect(webkit_glue::WebRectToIntRect(rect)); |
111 } | 109 } |
112 | 110 |
113 WebCore::FloatRect ChromeClientImpl::pageRect() { | 111 WebCore::FloatRect ChromeClientImpl::pageRect() { |
114 // We hide the details of the window's border thickness from the web page by | 112 // We hide the details of the window's border thickness from the web page by |
115 // simple re-using the window position here. So, from the point-of-view of | 113 // simple re-using the window position here. So, from the point-of-view of |
116 // the web page, the window has no border. | 114 // the web page, the window has no border. |
117 return windowRect(); | 115 return windowRect(); |
118 } | 116 } |
119 | 117 |
120 float ChromeClientImpl::scaleFactor() { | 118 float ChromeClientImpl::scaleFactor() { |
121 // This is supposed to return the scale factor of the web page. It looks like | 119 // This is supposed to return the scale factor of the web page. It looks like |
122 // the implementor of the graphics layer is responsible for doing most of the | 120 // the implementor of the graphics layer is responsible for doing most of the |
123 // operations associated with scaling. However, this value is used ins some | 121 // operations associated with scaling. However, this value is used ins some |
124 // cases by WebCore. For example, this is used as a scaling factor in canvas | 122 // cases by WebCore. For example, this is used as a scaling factor in canvas |
125 // so that things drawn in it are scaled just like the web page is. | 123 // so that things drawn in it are scaled just like the web page is. |
126 // | 124 // |
127 // We don't currently implement scaling, so just return 1.0 (no scaling). | 125 // We don't currently implement scaling, so just return 1.0 (no scaling). |
128 return 1.0; | 126 return 1.0; |
129 } | 127 } |
130 | 128 |
131 void ChromeClientImpl::focus() { | 129 void ChromeClientImpl::focus() { |
132 WebViewDelegate* delegate = webview_->delegate(); | 130 if (!webview_->client()) |
133 if (delegate) { | 131 return; |
134 delegate->didFocus(); | |
135 | 132 |
136 // If accessibility is enabled, we should notify assistive technology that | 133 webview_->client()->didFocus(); |
137 // the active AccessibilityObject changed. | 134 |
138 const WebCore::Frame* frame = webview_->GetFocusedWebCoreFrame(); | 135 // If accessibility is enabled, we should notify assistive technology that |
139 if (!frame) | 136 // the active AccessibilityObject changed. |
| 137 const WebCore::Frame* frame = webview_->GetFocusedWebCoreFrame(); |
| 138 if (!frame) |
| 139 return; |
| 140 |
| 141 WebCore::Document* doc = frame->document(); |
| 142 |
| 143 if (doc && doc->axObjectCache()->accessibilityEnabled()) { |
| 144 WebCore::Node* focused_node = webview_->GetFocusedNode(); |
| 145 |
| 146 if (!focused_node) { |
| 147 // Could not retrieve focused Node. |
140 return; | 148 return; |
| 149 } |
141 | 150 |
142 WebCore::Document* doc = frame->document(); | 151 // Retrieve the focused AccessibilityObject. |
| 152 WebCore::AccessibilityObject* focused_acc_obj = |
| 153 doc->axObjectCache()->getOrCreate(focused_node->renderer()); |
143 | 154 |
144 if (doc && doc->axObjectCache()->accessibilityEnabled()) { | 155 // Alert assistive technology that focus changed. |
145 WebCore::Node* focused_node = webview_->GetFocusedNode(); | 156 if (focused_acc_obj) |
146 | 157 webview_->delegate()->FocusAccessibilityObject(focused_acc_obj); |
147 if (!focused_node) { | |
148 // Could not retrieve focused Node. | |
149 return; | |
150 } | |
151 | |
152 // Retrieve the focused AccessibilityObject. | |
153 WebCore::AccessibilityObject* focused_acc_obj = | |
154 doc->axObjectCache()->getOrCreate(focused_node->renderer()); | |
155 | |
156 // Alert assistive technology that focus changed. | |
157 if (focused_acc_obj) | |
158 delegate->FocusAccessibilityObject(focused_acc_obj); | |
159 } | |
160 } | 158 } |
161 } | 159 } |
162 | 160 |
163 void ChromeClientImpl::unfocus() { | 161 void ChromeClientImpl::unfocus() { |
164 WebViewDelegate* delegate = webview_->delegate(); | 162 if (webview_->client()) |
165 if (delegate) | 163 webview_->client()->didBlur(); |
166 delegate->didBlur(); | |
167 } | 164 } |
168 | 165 |
169 bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) { | 166 bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) { |
170 // For now the browser can always take focus if we're not running layout | 167 // For now the browser can always take focus if we're not running layout |
171 // tests. | 168 // tests. |
172 return !WebKit::layoutTestMode(); | 169 return !WebKit::layoutTestMode(); |
173 } | 170 } |
174 | 171 |
175 void ChromeClientImpl::takeFocus(WebCore::FocusDirection direction) { | 172 void ChromeClientImpl::takeFocus(WebCore::FocusDirection direction) { |
176 if (!webview_->client()) | 173 if (!webview_->client()) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 policy = WebKit::WebNavigationPolicyNewPopup; | 258 policy = WebKit::WebNavigationPolicyNewPopup; |
262 if (CurrentEventShouldCauseBackgroundTab( | 259 if (CurrentEventShouldCauseBackgroundTab( |
263 WebViewImpl::current_input_event())) | 260 WebViewImpl::current_input_event())) |
264 policy = WebKit::WebNavigationPolicyNewBackgroundTab; | 261 policy = WebKit::WebNavigationPolicyNewBackgroundTab; |
265 | 262 |
266 delegate->show(policy); | 263 delegate->show(policy); |
267 } | 264 } |
268 } | 265 } |
269 | 266 |
270 bool ChromeClientImpl::canRunModal() { | 267 bool ChromeClientImpl::canRunModal() { |
271 return webview_->delegate() != NULL; | 268 return webview_->client() != NULL; |
272 } | 269 } |
273 | 270 |
274 void ChromeClientImpl::runModal() { | 271 void ChromeClientImpl::runModal() { |
275 WebViewDelegate* delegate = webview_->delegate(); | 272 if (webview_->client()) |
276 if (delegate) | 273 webview_->client()->runModal(); |
277 delegate->runModal(); | |
278 } | 274 } |
279 | 275 |
280 void ChromeClientImpl::setToolbarsVisible(bool value) { | 276 void ChromeClientImpl::setToolbarsVisible(bool value) { |
281 toolbars_visible_ = value; | 277 toolbars_visible_ = value; |
282 } | 278 } |
283 | 279 |
284 bool ChromeClientImpl::toolbarsVisible() { | 280 bool ChromeClientImpl::toolbarsVisible() { |
285 return toolbars_visible_; | 281 return toolbars_visible_; |
286 } | 282 } |
287 | 283 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 if (webview_->client()) { | 321 if (webview_->client()) { |
326 webview_->client()->didAddMessageToConsole( | 322 webview_->client()->didAddMessageToConsole( |
327 WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), | 323 WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), |
328 webkit_glue::StringToWebString(message)), | 324 webkit_glue::StringToWebString(message)), |
329 webkit_glue::StringToWebString(source_id), | 325 webkit_glue::StringToWebString(source_id), |
330 line_no); | 326 line_no); |
331 } | 327 } |
332 } | 328 } |
333 | 329 |
334 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() { | 330 bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() { |
335 return webview_->delegate() != NULL; | 331 return webview_->client() != NULL; |
336 } | 332 } |
337 | 333 |
338 bool ChromeClientImpl::runBeforeUnloadConfirmPanel( | 334 bool ChromeClientImpl::runBeforeUnloadConfirmPanel( |
339 const WebCore::String& message, | 335 const WebCore::String& message, |
340 WebCore::Frame* frame) { | 336 WebCore::Frame* frame) { |
341 if (webview_->client()) { | 337 if (webview_->client()) { |
342 return webview_->client()->runModalBeforeUnloadDialog( | 338 return webview_->client()->runModalBeforeUnloadDialog( |
343 WebFrameImpl::FromFrame(frame), | 339 WebFrameImpl::FromFrame(frame), |
344 webkit_glue::StringToWebString(message)); | 340 webkit_glue::StringToWebString(message)); |
345 } | 341 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // TODO(mbelshe): implement me | 410 // TODO(mbelshe): implement me |
415 return false; | 411 return false; |
416 } | 412 } |
417 | 413 |
418 bool ChromeClientImpl::tabsToLinks() const { | 414 bool ChromeClientImpl::tabsToLinks() const { |
419 return webview_->tabsToLinks(); | 415 return webview_->tabsToLinks(); |
420 } | 416 } |
421 | 417 |
422 WebCore::IntRect ChromeClientImpl::windowResizerRect() const { | 418 WebCore::IntRect ChromeClientImpl::windowResizerRect() const { |
423 WebCore::IntRect result; | 419 WebCore::IntRect result; |
424 if (webview_->delegate()) { | 420 if (webview_->client()) { |
425 result = webkit_glue::WebRectToIntRect( | 421 result = webkit_glue::WebRectToIntRect( |
426 webview_->delegate()->windowResizerRect()); | 422 webview_->client()->windowResizerRect()); |
427 } | 423 } |
428 return result; | 424 return result; |
429 } | 425 } |
430 | 426 |
431 void ChromeClientImpl::repaint( | 427 void ChromeClientImpl::repaint( |
432 const WebCore::IntRect& paint_rect, bool content_changed, bool immediate, | 428 const WebCore::IntRect& paint_rect, bool content_changed, bool immediate, |
433 bool repaint_content_only) { | 429 bool repaint_content_only) { |
434 // Ignore spurious calls. | 430 // Ignore spurious calls. |
435 if (!content_changed || paint_rect.isEmpty()) | 431 if (!content_changed || paint_rect.isEmpty()) |
436 return; | 432 return; |
437 WebViewDelegate* delegate = webview_->delegate(); | 433 if (webview_->client()) { |
438 if (delegate) | 434 webview_->client()->didInvalidateRect( |
439 delegate->didInvalidateRect(webkit_glue::IntRectToWebRect(paint_rect)); | 435 webkit_glue::IntRectToWebRect(paint_rect)); |
| 436 } |
440 } | 437 } |
441 | 438 |
442 void ChromeClientImpl::scroll( | 439 void ChromeClientImpl::scroll( |
443 const WebCore::IntSize& scroll_delta, const WebCore::IntRect& scroll_rect, | 440 const WebCore::IntSize& scroll_delta, const WebCore::IntRect& scroll_rect, |
444 const WebCore::IntRect& clip_rect) { | 441 const WebCore::IntRect& clip_rect) { |
445 WebViewDelegate* delegate = webview_->delegate(); | 442 if (webview_->client()) { |
446 if (delegate) { | |
447 int dx = scroll_delta.width(); | 443 int dx = scroll_delta.width(); |
448 int dy = scroll_delta.height(); | 444 int dy = scroll_delta.height(); |
449 delegate->didScrollRect( | 445 webview_->client()->didScrollRect( |
450 dx, dy, webkit_glue::IntRectToWebRect(clip_rect)); | 446 dx, dy, webkit_glue::IntRectToWebRect(clip_rect)); |
451 } | 447 } |
452 } | 448 } |
453 | 449 |
454 WebCore::IntPoint ChromeClientImpl::screenToWindow( | 450 WebCore::IntPoint ChromeClientImpl::screenToWindow( |
455 const WebCore::IntPoint&) const { | 451 const WebCore::IntPoint&) const { |
456 NOTIMPLEMENTED(); | 452 NOTIMPLEMENTED(); |
457 return WebCore::IntPoint(); | 453 return WebCore::IntPoint(); |
458 } | 454 } |
459 | 455 |
460 WebCore::IntRect ChromeClientImpl::windowToScreen( | 456 WebCore::IntRect ChromeClientImpl::windowToScreen( |
461 const WebCore::IntRect& rect) const { | 457 const WebCore::IntRect& rect) const { |
462 WebCore::IntRect screen_rect(rect); | 458 WebCore::IntRect screen_rect(rect); |
463 | 459 |
464 WebViewDelegate* delegate = webview_->delegate(); | 460 if (webview_->client()) { |
465 if (delegate) { | 461 WebRect window_rect = webview_->client()->windowRect(); |
466 WebRect window_rect = delegate->windowRect(); | |
467 screen_rect.move(window_rect.x, window_rect.y); | 462 screen_rect.move(window_rect.x, window_rect.y); |
468 } | 463 } |
469 | 464 |
470 return screen_rect; | 465 return screen_rect; |
471 } | 466 } |
472 | 467 |
473 void ChromeClientImpl::contentsSizeChanged(WebCore::Frame* frame, const | 468 void ChromeClientImpl::contentsSizeChanged(WebCore::Frame* frame, const |
474 WebCore::IntSize& size) const { | 469 WebCore::IntSize& size) const { |
475 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); | 470 WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); |
476 if (webframe->client()) { | 471 if (webframe->client()) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 static_cast<WebPopupMenuImpl*>(webwidget)->Init( | 557 static_cast<WebPopupMenuImpl*>(webwidget)->Init( |
563 popup_container, webkit_glue::IntRectToWebRect(bounds)); | 558 popup_container, webkit_glue::IntRectToWebRect(bounds)); |
564 } | 559 } |
565 | 560 |
566 void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) { | 561 void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) { |
567 if (ignore_next_set_cursor_) { | 562 if (ignore_next_set_cursor_) { |
568 ignore_next_set_cursor_ = false; | 563 ignore_next_set_cursor_ = false; |
569 return; | 564 return; |
570 } | 565 } |
571 | 566 |
572 WebViewDelegate* delegate = webview_->delegate(); | 567 if (webview_->client()) |
573 if (delegate) | 568 webview_->client()->didChangeCursor(cursor); |
574 delegate->didChangeCursor(cursor); | |
575 } | 569 } |
576 | 570 |
577 void ChromeClientImpl::SetCursorForPlugin(const WebCursorInfo& cursor) { | 571 void ChromeClientImpl::SetCursorForPlugin(const WebCursorInfo& cursor) { |
578 SetCursor(cursor); | 572 SetCursor(cursor); |
579 // Currently, Widget::setCursor is always called after this function in | 573 // Currently, Widget::setCursor is always called after this function in |
580 // EventHandler.cpp and since we don't want that we set a flag indicating | 574 // EventHandler.cpp and since we don't want that we set a flag indicating |
581 // that the next SetCursor call is to be ignored. | 575 // that the next SetCursor call is to be ignored. |
582 ignore_next_set_cursor_ = true; | 576 ignore_next_set_cursor_ = true; |
583 } | 577 } |
584 | 578 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 info->itemHeight = popup_container->menuItemHeight(); | 615 info->itemHeight = popup_container->menuItemHeight(); |
622 info->selectedIndex = popup_container->selectedIndex(); | 616 info->selectedIndex = popup_container->selectedIndex(); |
623 info->items.swap(output_items); | 617 info->items.swap(output_items); |
624 } | 618 } |
625 | 619 |
626 #if ENABLE(NOTIFICATIONS) | 620 #if ENABLE(NOTIFICATIONS) |
627 WebCore::NotificationPresenter* ChromeClientImpl::notificationPresenter() const
{ | 621 WebCore::NotificationPresenter* ChromeClientImpl::notificationPresenter() const
{ |
628 return webview_->GetNotificationPresenter(); | 622 return webview_->GetNotificationPresenter(); |
629 } | 623 } |
630 #endif | 624 #endif |
OLD | NEW |