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

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

Issue 20030: Autocomplete popup uses its own style (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2007 Google Inc. All Rights Reserved. 2 * Copyright 2007 Google Inc. All Rights Reserved.
3 * 3 *
4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
5 * 5 *
6 * ***** BEGIN LICENSE BLOCK ***** 6 * ***** BEGIN LICENSE BLOCK *****
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 18 matching lines...) Expand all
29 * ***** END LICENSE BLOCK ***** 29 * ***** END LICENSE BLOCK *****
30 * 30 *
31 */ 31 */
32 32
33 #include "config.h" 33 #include "config.h"
34 #include "build/build_config.h" 34 #include "build/build_config.h"
35 35
36 #include "base/compiler_specific.h" 36 #include "base/compiler_specific.h"
37 MSVC_PUSH_WARNING_LEVEL(0); 37 MSVC_PUSH_WARNING_LEVEL(0);
38 #include "CSSStyleSelector.h" 38 #include "CSSStyleSelector.h"
39 #include "CSSValueKeywords.h"
39 #include "Cursor.h" 40 #include "Cursor.h"
40 #include "Document.h" 41 #include "Document.h"
41 #include "DocumentLoader.h" 42 #include "DocumentLoader.h"
42 #include "DragController.h" 43 #include "DragController.h"
43 #include "DragData.h" 44 #include "DragData.h"
44 #include "Editor.h" 45 #include "Editor.h"
45 #include "EventHandler.h" 46 #include "EventHandler.h"
46 #include "FocusController.h" 47 #include "FocusController.h"
47 #include "FontDescription.h" 48 #include "FontDescription.h"
48 #include "FrameLoader.h" 49 #include "FrameLoader.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 : public RefCounted<AutocompletePopupMenuClient>, 126 : public RefCounted<AutocompletePopupMenuClient>,
126 public WebCore::PopupMenuClient { 127 public WebCore::PopupMenuClient {
127 public: 128 public:
128 AutocompletePopupMenuClient(WebViewImpl* webview, 129 AutocompletePopupMenuClient(WebViewImpl* webview,
129 WebCore::HTMLInputElement* text_field, 130 WebCore::HTMLInputElement* text_field,
130 const std::vector<std::wstring>& suggestions, 131 const std::vector<std::wstring>& suggestions,
131 int default_suggestion_index) 132 int default_suggestion_index)
132 : text_field_(text_field), 133 : text_field_(text_field),
133 selected_index_(default_suggestion_index), 134 selected_index_(default_suggestion_index),
134 webview_(webview) { 135 webview_(webview) {
136 FontDescription font_description;
137 #if defined(OS_WIN)
138 theme()->systemFont(CSSValueWebkitControl, text_field->document(),
139 font_description);
140 #else
141 NOTIMPLEMENTED();
142 #endif
143 // Use a smaller font size to match IE/Firefox.
144 font_description.setComputedSize(12.0);
ojan 2009/02/04 02:12:47 Please add a TODO to make sure that this works wel
145 Font font(font_description, 0, 0);
146 font.update(text_field->document()->styleSelector()->fontSelector());
147 style_.reset(new PopupMenuStyle(Color::black, Color::white, font, true));
135 SetSuggestions(suggestions); 148 SetSuggestions(suggestions);
136 } 149 }
137 virtual ~AutocompletePopupMenuClient() { 150 virtual ~AutocompletePopupMenuClient() {
138 } 151 }
139 152
140 virtual void valueChanged(unsigned listIndex, bool fireEvents = true) { 153 virtual void valueChanged(unsigned listIndex, bool fireEvents = true) {
141 text_field_->setValue(suggestions_[listIndex]); 154 text_field_->setValue(suggestions_[listIndex]);
142 } 155 }
143 156
144 virtual WebCore::String itemText(unsigned list_index) const { 157 virtual WebCore::String itemText(unsigned list_index) const {
145 return suggestions_[list_index]; 158 return suggestions_[list_index];
146 } 159 }
147 160
148 virtual bool itemIsEnabled(unsigned listIndex) const { 161 virtual bool itemIsEnabled(unsigned listIndex) const {
149 return true; 162 return true;
150 } 163 }
151 164
152 virtual PopupMenuStyle itemStyle(unsigned listIndex) const { 165 virtual PopupMenuStyle itemStyle(unsigned listIndex) const {
153 return menuStyle(); 166 return *style_;
154 } 167 }
155 168
156 virtual PopupMenuStyle menuStyle() const { 169 virtual PopupMenuStyle menuStyle() const {
157 RenderStyle* style = text_field_->renderStyle() ? 170 return *style_;
158 text_field_->renderStyle() :
159 text_field_->computedStyle();
160 return PopupMenuStyle(style->color(), Color::white, style->font(),
161 style->visibility() == VISIBLE);
162 } 171 }
163 172
164 virtual int clientInsetLeft() const { 173 virtual int clientInsetLeft() const {
165 return 0; 174 return 0;
166 } 175 }
167 virtual int clientInsetRight() const { 176 virtual int clientInsetRight() const {
168 return 0; 177 return 0;
169 } 178 }
170 virtual int clientPaddingLeft() const { 179 virtual int clientPaddingLeft() const {
171 #if defined(OS_WIN) 180 #if defined(OS_WIN)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 252
244 WebCore::HTMLInputElement* text_field() const { 253 WebCore::HTMLInputElement* text_field() const {
245 return text_field_.get(); 254 return text_field_.get();
246 } 255 }
247 256
248 private: 257 private:
249 RefPtr<WebCore::HTMLInputElement> text_field_; 258 RefPtr<WebCore::HTMLInputElement> text_field_;
250 std::vector<WebCore::String> suggestions_; 259 std::vector<WebCore::String> suggestions_;
251 int selected_index_; 260 int selected_index_;
252 WebViewImpl* webview_; 261 WebViewImpl* webview_;
262 scoped_ptr<PopupMenuStyle> style_;
253 }; 263 };
254 264
255 // WebView ---------------------------------------------------------------- 265 // WebView ----------------------------------------------------------------
256 266
257 /*static*/ 267 /*static*/
258 WebView* WebView::Create(WebViewDelegate* delegate, 268 WebView* WebView::Create(WebViewDelegate* delegate,
259 const WebPreferences& prefs) { 269 const WebPreferences& prefs) {
260 WebViewImpl* instance = new WebViewImpl(); 270 WebViewImpl* instance = new WebViewImpl();
261 instance->AddRef(); 271 instance->AddRef();
262 instance->SetPreferences(prefs); 272 instance->SetPreferences(prefs);
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 Frame* frame = page_->focusController()->focusedFrame(); 1638 Frame* frame = page_->focusController()->focusedFrame();
1629 if (!frame) 1639 if (!frame)
1630 return NULL; 1640 return NULL;
1631 1641
1632 Document* document = frame->document(); 1642 Document* document = frame->document();
1633 if (!document) 1643 if (!document)
1634 return NULL; 1644 return NULL;
1635 1645
1636 return document->focusedNode(); 1646 return document->focusedNode();
1637 } 1647 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698