| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // This file was forked off the Mac port. | 5 // This file was forked off the Mac port. |
| 6 | 6 |
| 7 #include "webkit/tools/test_shell/test_webview_delegate.h" | 7 #include "webkit/tools/test_shell/test_webview_delegate.h" |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 if (webwidget == shell_->webView()) { | 104 if (webwidget == shell_->webView()) { |
| 105 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction( | 105 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction( |
| 106 >k_widget_destroy, GTK_WIDGET(shell_->mainWnd()))); | 106 >k_widget_destroy, GTK_WIDGET(shell_->mainWnd()))); |
| 107 } else if (webwidget == shell_->popup()) { | 107 } else if (webwidget == shell_->popup()) { |
| 108 shell_->ClosePopup(); | 108 shell_->ClosePopup(); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 void TestWebViewDelegate::SetCursor(WebWidget* webwidget, | 112 void TestWebViewDelegate::SetCursor(WebWidget* webwidget, |
| 113 const WebCursor& cursor) { | 113 const WebCursor& cursor) { |
| 114 GdkCursorType cursor_type = cursor.GetCursorType(); | 114 current_cursor_ = cursor; |
| 115 GdkCursorType cursor_type = current_cursor_.GetCursorType(); |
| 115 GdkCursor* gdk_cursor; | 116 GdkCursor* gdk_cursor; |
| 116 if (cursor_type == GDK_CURSOR_IS_PIXMAP) { | 117 if (cursor_type == GDK_CURSOR_IS_PIXMAP) { |
| 117 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is | 118 // TODO(port): WebKit bug https://bugs.webkit.org/show_bug.cgi?id=16388 is |
| 118 // that calling gdk_window_set_cursor repeatedly is expensive. We should | 119 // that calling gdk_window_set_cursor repeatedly is expensive. We should |
| 119 // avoid it here where possible. | 120 // avoid it here where possible. |
| 120 gdk_cursor = cursor.GetCustomCursor(); | 121 gdk_cursor = current_cursor_.GetCustomCursor(); |
| 121 } else { | 122 } else { |
| 122 // Optimize the common case, where the cursor hasn't changed. | 123 // Optimize the common case, where the cursor hasn't changed. |
| 123 // However, we can switch between different pixmaps, so only on the | 124 // However, we can switch between different pixmaps, so only on the |
| 124 // non-pixmap branch. | 125 // non-pixmap branch. |
| 125 if (cursor_type_ == cursor_type) | 126 if (cursor_type_ == cursor_type) |
| 126 return; | 127 return; |
| 127 gdk_cursor = gdk_cursor_new(cursor_type); | 128 gdk_cursor = gdk_cursor_new(cursor_type); |
| 128 } | 129 } |
| 129 cursor_type_ = cursor_type; | 130 cursor_type_ = cursor_type; |
| 130 gdk_window_set_cursor(shell_->webViewWnd()->window, gdk_cursor); | 131 gdk_window_set_cursor(shell_->webViewWnd()->window, gdk_cursor); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Private methods ----------------------------------------------------------- | 214 // Private methods ----------------------------------------------------------- |
| 214 | 215 |
| 215 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { | 216 void TestWebViewDelegate::SetPageTitle(const std::wstring& title) { |
| 216 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), | 217 gtk_window_set_title(GTK_WINDOW(shell_->mainWnd()), |
| 217 ("Test Shell - " + WideToUTF8(title)).c_str()); | 218 ("Test Shell - " + WideToUTF8(title)).c_str()); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { | 221 void TestWebViewDelegate::SetAddressBarURL(const GURL& url) { |
| 221 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); | 222 gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), url.spec().c_str()); |
| 222 } | 223 } |
| OLD | NEW |