diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 19:12:53 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-10 19:12:53 +0000 |
commit | db89440b21bf4950a18f4479aaa961cfe13de035 (patch) | |
tree | 751748488e9d42892835457bed3b91495bd4e1fa /ui/base | |
parent | da7582b7e45e5f0aac0a1b072580be65b1502334 (diff) | |
download | chromium_src-db89440b21bf4950a18f4479aaa961cfe13de035.zip chromium_src-db89440b21bf4950a18f4479aaa961cfe13de035.tar.gz chromium_src-db89440b21bf4950a18f4479aaa961cfe13de035.tar.bz2 |
GTK: Seal up GSEALs, focusing on GtkSelectionData.
BUG=79722
TEST=compiles
First Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=116956
Review URL: http://codereview.chromium.org/9151007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117070 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/clipboard/clipboard_gtk.cc | 33 | ||||
-rw-r--r-- | ui/base/dragdrop/gtk_dnd_util.cc | 20 | ||||
-rw-r--r-- | ui/base/gtk/focus_store_gtk.cc | 4 | ||||
-rw-r--r-- | ui/base/gtk/gtk_compat.h | 4 | ||||
-rw-r--r-- | ui/base/x/x11_util.cc | 2 |
5 files changed, 41 insertions, 22 deletions
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc index 5b6a1a9..b1ea51b 100644 --- a/ui/base/clipboard/clipboard_gtk.cc +++ b/ui/base/clipboard/clipboard_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -129,7 +129,8 @@ void GetData(GtkClipboard* clipboard, Clipboard::TargetMap* data_map = reinterpret_cast<Clipboard::TargetMap*>(user_data); - std::string target_string = GdkAtomToString(selection_data->target); + std::string target_string = GdkAtomToString( + gtk_selection_data_get_target(selection_data)); Clipboard::TargetMap::iterator iter = data_map->find(target_string); if (iter == data_map->end()) @@ -139,7 +140,8 @@ void GetData(GtkClipboard* clipboard, gtk_selection_data_set_pixbuf(selection_data, reinterpret_cast<GdkPixbuf*>(iter->second.first)); } else { - gtk_selection_data_set(selection_data, selection_data->target, 8, + gtk_selection_data_set(selection_data, + gtk_selection_data_get_target(selection_data), 8, reinterpret_cast<guchar*>(iter->second.first), iter->second.second); } @@ -421,7 +423,9 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer, clipboard, GetWebCustomDataFormatType().ToGdkAtom()); if (!data) return; - ReadCustomDataTypes(data->data, data->length, types); + ReadCustomDataTypes(gtk_selection_data_get_data(data), + gtk_selection_data_get_length(data), + types); gtk_selection_data_free(data); } @@ -484,12 +488,15 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup, // If the data starts with 0xFEFF, i.e., Byte Order Mark, assume it is // UTF-16, otherwise assume UTF-8. - if (data->length >= 2 && - reinterpret_cast<uint16_t*>(data->data)[0] == 0xFEFF) { - markup->assign(reinterpret_cast<uint16_t*>(data->data) + 1, - (data->length / 2) - 1); + gint data_length = gtk_selection_data_get_length(data); + const guchar* raw_data = gtk_selection_data_get_data(data); + + if (data_length >= 2 && + reinterpret_cast<const uint16_t*>(raw_data)[0] == 0xFEFF) { + markup->assign(reinterpret_cast<const uint16_t*>(raw_data) + 1, + (data_length / 2) - 1); } else { - UTF8ToUTF16(reinterpret_cast<char*>(data->data), data->length, markup); + UTF8ToUTF16(reinterpret_cast<const char*>(raw_data), data_length, markup); } // If there is a terminating NULL, drop it. @@ -532,7 +539,9 @@ void Clipboard::ReadCustomData(Buffer buffer, clipboard, GetWebCustomDataFormatType().ToGdkAtom()); if (!data) return; - ReadCustomDataForType(data->data, data->length, type, result); + ReadCustomDataForType(gtk_selection_data_get_data(data), + gtk_selection_data_get_length(data), + type, result); gtk_selection_data_free(data); } @@ -546,7 +555,9 @@ void Clipboard::ReadData(const FormatType& format, std::string* result) const { gtk_clipboard_wait_for_contents(clipboard_, format.ToGdkAtom()); if (!data) return; - result->assign(reinterpret_cast<char*>(data->data), data->length); + result->assign(reinterpret_cast<const char*>( + gtk_selection_data_get_data(data)), + gtk_selection_data_get_length(data)); gtk_selection_data_free(data); } diff --git a/ui/base/dragdrop/gtk_dnd_util.cc b/ui/base/dragdrop/gtk_dnd_util.cc index 165d91b..d70aac8 100644 --- a/ui/base/dragdrop/gtk_dnd_util.cc +++ b/ui/base/dragdrop/gtk_dnd_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -192,7 +192,7 @@ void WriteURLWithName(GtkSelectionData* selection_data, // _NETSCAPE_URL format is URL + \n + title. std::string utf8_text = url.spec() + "\n" + UTF16ToUTF8(title); gtk_selection_data_set(selection_data, - selection_data->target, + gtk_selection_data_get_target(selection_data), kBitsPerByte, reinterpret_cast<const guchar*>(utf8_text.c_str()), utf8_text.length()); @@ -209,11 +209,13 @@ void WriteURLWithName(GtkSelectionData* selection_data, bool ExtractNamedURL(GtkSelectionData* selection_data, GURL* url, string16* title) { - if (!selection_data || selection_data->length <= 0) + if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0) return false; - Pickle data(reinterpret_cast<char*>(selection_data->data), - selection_data->length); + Pickle data( + reinterpret_cast<const char*>( + gtk_selection_data_get_data(selection_data)), + gtk_selection_data_get_length(selection_data)); void* iter = NULL; std::string title_utf8, url_utf8; if (!data.ReadString(&iter, &title_utf8) || @@ -248,13 +250,15 @@ bool ExtractURIList(GtkSelectionData* selection_data, std::vector<GURL>* urls) { bool ExtractNetscapeURL(GtkSelectionData* selection_data, GURL* url, string16* title) { - if (!selection_data || selection_data->length <= 0) + if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0) return false; // Find the first '\n' in the data. It is the separator between the url and // the title. - std::string data(reinterpret_cast<char*>(selection_data->data), - selection_data->length); + std::string data( + reinterpret_cast<const char*>( + gtk_selection_data_get_data(selection_data)), + gtk_selection_data_get_length(selection_data)); std::string::size_type newline = data.find('\n'); if (newline == std::string::npos) return false; diff --git a/ui/base/gtk/focus_store_gtk.cc b/ui/base/gtk/focus_store_gtk.cc index b98787c..3af039d 100644 --- a/ui/base/gtk/focus_store_gtk.cc +++ b/ui/base/gtk/focus_store_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -25,7 +25,7 @@ void FocusStoreGtk::Store(GtkWidget* widget) { GtkWidget* toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW); GtkWindow* window = GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL; if (window) - focus_widget = window->focus_widget; + focus_widget = gtk_window_get_focus(window); } SetWidget(focus_widget); diff --git a/ui/base/gtk/gtk_compat.h b/ui/base/gtk/gtk_compat.h index 2372387..4ca12df 100644 --- a/ui/base/gtk/gtk_compat.h +++ b/ui/base/gtk/gtk_compat.h @@ -49,6 +49,10 @@ inline void gtk_widget_set_realized(GtkWidget* widget, else GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED); } + +inline void gtk_widget_style_attach(GtkWidget* widget) { + widget->style = gtk_style_attach(widget->style, widget->window); +} #endif // !GTK_CHECK_VERSION(2, 20, 0) || defined(GOOGLE_CHROME_BUILD) #if !GTK_CHECK_VERSION(2, 22, 0) diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index f6292b3..6b11de4 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -325,7 +325,7 @@ bool GetCurrentDesktop(int* desktop) { #if defined(TOOLKIT_USES_GTK) XID GetX11WindowFromGtkWidget(GtkWidget* widget) { - return GDK_WINDOW_XID(widget->window); + return GDK_WINDOW_XID(gtk_widget_get_window(widget)); } XID GetX11WindowFromGdkWindow(GdkWindow* window) { |