OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "Cursor.h" | 7 #include "Cursor.h" |
8 #include "FramelessScrollView.h" | 8 #include "FramelessScrollView.h" |
9 #include "FrameView.h" | 9 #include "FrameView.h" |
10 #include "IntRect.h" | 10 #include "IntRect.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 using WebKit::WebSize; | 41 using WebKit::WebSize; |
42 using WebKit::WebString; | 42 using WebKit::WebString; |
43 using WebKit::WebTextDirection; | 43 using WebKit::WebTextDirection; |
44 using WebKit::WebWidget; | 44 using WebKit::WebWidget; |
45 using WebKit::WebWidgetClient; | 45 using WebKit::WebWidgetClient; |
46 | 46 |
47 // WebPopupMenu --------------------------------------------------------------- | 47 // WebPopupMenu --------------------------------------------------------------- |
48 | 48 |
49 // static | 49 // static |
50 WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) { | 50 WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client) { |
51 WebPopupMenuImpl* instance = new WebPopupMenuImpl(client); | 51 return new WebPopupMenuImpl(client); |
52 instance->AddRef(); | |
53 return instance; | |
54 } | 52 } |
55 | 53 |
56 // WebWidget ------------------------------------------------------------------ | 54 // WebWidget ------------------------------------------------------------------ |
57 | 55 |
58 WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) | 56 WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) |
59 : client_(client), | 57 : client_(client), |
60 widget_(NULL) { | 58 widget_(NULL) { |
61 // set to impossible point so we always get the first mouse pos | 59 // set to impossible point so we always get the first mouse pos |
62 last_mouse_position_ = WebPoint(-1, -1); | 60 last_mouse_position_ = WebPoint(-1, -1); |
63 } | 61 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 107 } |
110 | 108 |
111 // WebWidget ------------------------------------------------------------------- | 109 // WebWidget ------------------------------------------------------------------- |
112 | 110 |
113 void WebPopupMenuImpl::close() { | 111 void WebPopupMenuImpl::close() { |
114 if (widget_) | 112 if (widget_) |
115 widget_->hide(); | 113 widget_->hide(); |
116 | 114 |
117 client_ = NULL; | 115 client_ = NULL; |
118 | 116 |
119 Release(); // Balances AddRef from WebWidget::Create | 117 deref(); // Balances ref() from WebWidget::Create |
120 } | 118 } |
121 | 119 |
122 void WebPopupMenuImpl::resize(const WebSize& new_size) { | 120 void WebPopupMenuImpl::resize(const WebSize& new_size) { |
123 if (size_ == new_size) | 121 if (size_ == new_size) |
124 return; | 122 return; |
125 size_ = new_size; | 123 size_ = new_size; |
126 | 124 |
127 if (widget_) { | 125 if (widget_) { |
128 IntRect new_geometry(0, 0, size_.width, size_.height); | 126 IntRect new_geometry(0, 0, size_.width, size_.height); |
129 widget_->setFrameRect(new_geometry); | 127 widget_->setFrameRect(new_geometry); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // WebCore::FramelessScrollViewClient | 275 // WebCore::FramelessScrollViewClient |
278 | 276 |
279 void WebPopupMenuImpl::popupClosed(WebCore::FramelessScrollView* widget) { | 277 void WebPopupMenuImpl::popupClosed(WebCore::FramelessScrollView* widget) { |
280 ASSERT(widget == widget_); | 278 ASSERT(widget == widget_); |
281 if (widget_) { | 279 if (widget_) { |
282 widget_->setClient(NULL); | 280 widget_->setClient(NULL); |
283 widget_ = NULL; | 281 widget_ = NULL; |
284 } | 282 } |
285 client_->closeWidgetSoon(); | 283 client_->closeWidgetSoon(); |
286 } | 284 } |
OLD | NEW |