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

Side by Side Diff: chrome/views/text_field.cc

Issue 21018: Adding tracking of HWND creation/destruction (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
OLDNEW
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 "chrome/views/text_field.h" 5 #include "chrome/views/text_field.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <atlapp.h> 8 #include <atlapp.h>
9 #include <atlcrack.h> 9 #include <atlcrack.h>
10 #include <atlctrls.h> 10 #include <atlctrls.h>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 void SetEnabled(bool enabled); 64 void SetEnabled(bool enabled);
65 65
66 void SetBackgroundColor(COLORREF bg_color); 66 void SetBackgroundColor(COLORREF bg_color);
67 67
68 // CWindowImpl 68 // CWindowImpl
69 BEGIN_MSG_MAP(Edit) 69 BEGIN_MSG_MAP(Edit)
70 MSG_WM_CHAR(OnChar) 70 MSG_WM_CHAR(OnChar)
71 MSG_WM_CONTEXTMENU(OnContextMenu) 71 MSG_WM_CONTEXTMENU(OnContextMenu)
72 MSG_WM_COPY(OnCopy) 72 MSG_WM_COPY(OnCopy)
73 MSG_WM_CREATE(OnCreate)
73 MSG_WM_CUT(OnCut) 74 MSG_WM_CUT(OnCut)
75 MSG_WM_DESTROY(OnDestroy)
74 MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeStartComposition) 76 MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeStartComposition)
75 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition) 77 MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition)
76 MSG_WM_KEYDOWN(OnKeyDown) 78 MSG_WM_KEYDOWN(OnKeyDown)
77 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) 79 MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk)
78 MSG_WM_LBUTTONDOWN(OnLButtonDown) 80 MSG_WM_LBUTTONDOWN(OnLButtonDown)
79 MSG_WM_LBUTTONUP(OnLButtonUp) 81 MSG_WM_LBUTTONUP(OnLButtonUp)
80 MSG_WM_MBUTTONDOWN(OnNonLButtonDown) 82 MSG_WM_MBUTTONDOWN(OnNonLButtonDown)
81 MSG_WM_MOUSEMOVE(OnMouseMove) 83 MSG_WM_MOUSEMOVE(OnMouseMove)
82 MSG_WM_MOUSELEAVE(OnMouseLeave) 84 MSG_WM_MOUSELEAVE(OnMouseLeave)
83 MSG_WM_NCCALCSIZE(OnNCCalcSize) 85 MSG_WM_NCCALCSIZE(OnNCCalcSize)
(...skipping 25 matching lines...) Expand all
109 Edit* const edit_; 111 Edit* const edit_;
110 ITextDocument* const text_object_model_; 112 ITextDocument* const text_object_model_;
111 113
112 DISALLOW_EVIL_CONSTRUCTORS(ScopedFreeze); 114 DISALLOW_EVIL_CONSTRUCTORS(ScopedFreeze);
113 }; 115 };
114 116
115 // message handlers 117 // message handlers
116 void OnChar(TCHAR key, UINT repeat_count, UINT flags); 118 void OnChar(TCHAR key, UINT repeat_count, UINT flags);
117 void OnContextMenu(HWND window, const CPoint& point); 119 void OnContextMenu(HWND window, const CPoint& point);
118 void OnCopy(); 120 void OnCopy();
121 LRESULT OnCreate(CREATESTRUCT* create_struct);
119 void OnCut(); 122 void OnCut();
123 void OnDestroy();
120 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam); 124 LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam);
121 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam); 125 LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam);
122 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags); 126 void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags);
123 void OnLButtonDblClk(UINT keys, const CPoint& point); 127 void OnLButtonDblClk(UINT keys, const CPoint& point);
124 void OnLButtonDown(UINT keys, const CPoint& point); 128 void OnLButtonDown(UINT keys, const CPoint& point);
125 void OnLButtonUp(UINT keys, const CPoint& point); 129 void OnLButtonUp(UINT keys, const CPoint& point);
126 void OnMouseLeave(); 130 void OnMouseLeave();
127 void OnMouseMove(UINT keys, const CPoint& point); 131 void OnMouseMove(UINT keys, const CPoint& point);
128 int OnNCCalcSize(BOOL w_param, LPARAM l_param); 132 int OnNCCalcSize(BOOL w_param, LPARAM l_param);
129 void OnNCPaint(HRGN region); 133 void OnNCPaint(HRGN region);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 411
408 void TextField::Edit::OnCopy() { 412 void TextField::Edit::OnCopy() {
409 const std::wstring text(GetSelectedText()); 413 const std::wstring text(GetSelectedText());
410 414
411 if (!text.empty()) { 415 if (!text.empty()) {
412 ScopedClipboardWriter scw(g_browser_process->clipboard_service()); 416 ScopedClipboardWriter scw(g_browser_process->clipboard_service());
413 scw.WriteText(text); 417 scw.WriteText(text);
414 } 418 }
415 } 419 }
416 420
421 LRESULT TextField::Edit::OnCreate(CREATESTRUCT* create_struct) {
422 TRACK_HWND_CREATION(m_hWnd);
423 return 0;
424 }
425
417 void TextField::Edit::OnCut() { 426 void TextField::Edit::OnCut() {
418 if (parent_->IsReadOnly()) 427 if (parent_->IsReadOnly())
419 return; 428 return;
420 429
421 OnCopy(); 430 OnCopy();
422 431
423 // This replace selection will have no effect (even on the undo stack) if the 432 // This replace selection will have no effect (even on the undo stack) if the
424 // current selection is empty. 433 // current selection is empty.
425 ReplaceSel(L"", true); 434 ReplaceSel(L"", true);
426 } 435 }
427 436
437 void TextField::Edit::OnDestroy() {
438 TRACK_HWND_DESTRUCTION(m_hWnd);
439 }
440
428 LRESULT TextField::Edit::OnImeStartComposition(UINT message, 441 LRESULT TextField::Edit::OnImeStartComposition(UINT message,
429 WPARAM wparam, 442 WPARAM wparam,
430 LPARAM lparam) { 443 LPARAM lparam) {
431 // Users may press alt+shift or control+shift keys to change their keyboard 444 // Users may press alt+shift or control+shift keys to change their keyboard
432 // layouts. So, we retrieve the input locale identifier everytime we start 445 // layouts. So, we retrieve the input locale identifier everytime we start
433 // an IME composition. 446 // an IME composition.
434 int language_id = PRIMARYLANGID(GetKeyboardLayout(0)); 447 int language_id = PRIMARYLANGID(GetKeyboardLayout(0));
435 ime_discard_composition_ = 448 ime_discard_composition_ =
436 language_id == LANG_JAPANESE || language_id == LANG_CHINESE; 449 language_id == LANG_JAPANESE || language_id == LANG_CHINESE;
437 ime_composition_start_ = 0; 450 ime_composition_start_ = 0;
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1114
1102 COLORREF bg_color; 1115 COLORREF bg_color;
1103 if (!use_default_background_color_) 1116 if (!use_default_background_color_)
1104 bg_color = skia::SkColorToCOLORREF(background_color_); 1117 bg_color = skia::SkColorToCOLORREF(background_color_);
1105 else 1118 else
1106 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); 1119 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW);
1107 edit_->SetBackgroundColor(bg_color); 1120 edit_->SetBackgroundColor(bg_color);
1108 } 1121 }
1109 1122
1110 } // namespace views 1123 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698