| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 const char kSecureSchemeColor[] = "#079500"; | 61 const char kSecureSchemeColor[] = "#079500"; |
| 62 const char kSecurityErrorSchemeColor[] = "#a20000"; | 62 const char kSecurityErrorSchemeColor[] = "#a20000"; |
| 63 | 63 |
| 64 const double kStrikethroughStrokeRed = 162.0 / 256.0; | 64 const double kStrikethroughStrokeRed = 162.0 / 256.0; |
| 65 const double kStrikethroughStrokeWidth = 2.0; | 65 const double kStrikethroughStrokeWidth = 2.0; |
| 66 | 66 |
| 67 size_t GetUTF8Offset(const string16& text, size_t text_offset) { | 67 size_t GetUTF8Offset(const string16& text, size_t text_offset) { |
| 68 return UTF16ToUTF8(text.substr(0, text_offset)).size(); | 68 return UTF16ToUTF8(text.substr(0, text_offset)).size(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // A helper method for determining a valid drag operation given the allowed | |
| 72 // operation. We prefer copy over link. | |
| 73 int CopyOrLinkDragOperation(int drag_operation) { | |
| 74 if (drag_operation & ui::DragDropTypes::DRAG_COPY) | |
| 75 return ui::DragDropTypes::DRAG_COPY; | |
| 76 if (drag_operation & ui::DragDropTypes::DRAG_LINK) | |
| 77 return ui::DragDropTypes::DRAG_LINK; | |
| 78 return ui::DragDropTypes::DRAG_NONE; | |
| 79 } | |
| 80 | |
| 81 // Stores GTK+-specific state so it can be restored after switching tabs. | 71 // Stores GTK+-specific state so it can be restored after switching tabs. |
| 82 struct ViewState { | 72 struct ViewState { |
| 83 explicit ViewState(const OmniboxViewGtk::CharRange& selection_range) | 73 explicit ViewState(const OmniboxViewGtk::CharRange& selection_range) |
| 84 : selection_range(selection_range) { | 74 : selection_range(selection_range) { |
| 85 } | 75 } |
| 86 | 76 |
| 87 // Range of selected text. | 77 // Range of selected text. |
| 88 OmniboxViewGtk::CharRange selection_range; | 78 OmniboxViewGtk::CharRange selection_range; |
| 89 }; | 79 }; |
| 90 | 80 |
| (...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 void OmniboxViewGtk::AdjustVerticalAlignmentOfGrayTextView() { | 2119 void OmniboxViewGtk::AdjustVerticalAlignmentOfGrayTextView() { |
| 2130 // By default, GtkTextView layouts an anchored child widget just above the | 2120 // By default, GtkTextView layouts an anchored child widget just above the |
| 2131 // baseline, so we need to move the |gray_text_view_| down to make sure it | 2121 // baseline, so we need to move the |gray_text_view_| down to make sure it |
| 2132 // has the same baseline as the |text_view_|. | 2122 // has the same baseline as the |text_view_|. |
| 2133 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(gray_text_view_)); | 2123 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(gray_text_view_)); |
| 2134 int height; | 2124 int height; |
| 2135 pango_layout_get_size(layout, NULL, &height); | 2125 pango_layout_get_size(layout, NULL, &height); |
| 2136 int baseline = pango_layout_get_baseline(layout); | 2126 int baseline = pango_layout_get_baseline(layout); |
| 2137 g_object_set(gray_text_anchor_tag_, "rise", baseline - height, NULL); | 2127 g_object_set(gray_text_anchor_tag_, "rise", baseline - height, NULL); |
| 2138 } | 2128 } |
| OLD | NEW |