| OLD | NEW |
| 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/browser/views/tabs/tab.h" | 5 #include "chrome/browser/views/tabs/tab.h" |
| 6 | 6 |
| 7 #include "base/gfx/size.h" | 7 #include "base/gfx/size.h" |
| 8 #include "chrome/common/gfx/chrome_canvas.h" | 8 #include "chrome/common/gfx/chrome_canvas.h" |
| 9 #include "chrome/common/gfx/path.h" | 9 #include "chrome/common/gfx/path.h" |
| 10 #include "chrome/common/l10n_util.h" | 10 #include "chrome/common/l10n_util.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool Tab::OnMouseDragged(const views::MouseEvent& event) { | 173 bool Tab::OnMouseDragged(const views::MouseEvent& event) { |
| 174 delegate_->ContinueDrag(event); | 174 delegate_->ContinueDrag(event); |
| 175 return true; | 175 return true; |
| 176 } | 176 } |
| 177 | 177 |
| 178 void Tab::OnMouseReleased(const views::MouseEvent& event, bool canceled) { | 178 void Tab::OnMouseReleased(const views::MouseEvent& event, bool canceled) { |
| 179 // Notify the drag helper that we're done with any potential drag operations. | 179 // Notify the drag helper that we're done with any potential drag operations. |
| 180 // Clean up the drag helper, which is re-created on the next mouse press. | 180 // Clean up the drag helper, which is re-created on the next mouse press. |
| 181 delegate_->EndDrag(canceled); | 181 // In some cases, ending the drag will schedule the tab for destruction; if |
| 182 // so, bail immediately, since our members are already dead and we shouldn't |
| 183 // do anything else except drop the tab where it is. |
| 184 if (delegate_->EndDrag(canceled)) |
| 185 return; |
| 182 | 186 |
| 183 // Close tabs on middle click, but only if the button is released over the tab
| 187 // Close tab on middle click, but only if the button is released over the tab |
| 184 // (normal windows behavior is to discard presses of a UI element where the | 188 // (normal windows behavior is to discard presses of a UI element where the |
| 185 // releases happen off the element). | 189 // releases happen off the element). |
| 186 if (event.IsMiddleMouseButton() && HitTest(event.location())) | 190 if (event.IsMiddleMouseButton() && HitTest(event.location())) |
| 187 delegate_->CloseTab(this); | 191 delegate_->CloseTab(this); |
| 188 } | 192 } |
| 189 | 193 |
| 190 bool Tab::GetTooltipText(int x, int y, std::wstring* tooltip) { | 194 bool Tab::GetTooltipText(int x, int y, std::wstring* tooltip) { |
| 191 std::wstring title = GetTitle(); | 195 std::wstring title = GetTitle(); |
| 192 if (!title.empty()) { | 196 if (!title.empty()) { |
| 193 // Only show the tooltip if the title is truncated. | 197 // Only show the tooltip if the title is truncated. |
| 194 ChromeFont font; | 198 ChromeFont font; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 270 |
| 267 // Close out the path. | 271 // Close out the path. |
| 268 path->lineTo(0, h); | 272 path->lineTo(0, h); |
| 269 path->close(); | 273 path->close(); |
| 270 } | 274 } |
| 271 | 275 |
| 272 void Tab::ContextMenuClosed() { | 276 void Tab::ContextMenuClosed() { |
| 273 delegate()->StopAllHighlighting(); | 277 delegate()->StopAllHighlighting(); |
| 274 menu_controller_ = NULL; | 278 menu_controller_ = NULL; |
| 275 } | 279 } |
| OLD | NEW |