| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/views/tabs/tab.h" | 5 #include "chrome/browser/ui/views/tabs/tab.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 private: | 314 private: |
| 315 // views::MaskedTargeterDelegate: | 315 // views::MaskedTargeterDelegate: |
| 316 View* TargetForRect(View* root, const gfx::Rect& rect) override { | 316 View* TargetForRect(View* root, const gfx::Rect& rect) override { |
| 317 CHECK_EQ(root, this); | 317 CHECK_EQ(root, this); |
| 318 | 318 |
| 319 if (!views::UsePointBasedTargeting(rect)) | 319 if (!views::UsePointBasedTargeting(rect)) |
| 320 return ViewTargeterDelegate::TargetForRect(root, rect); | 320 return ViewTargeterDelegate::TargetForRect(root, rect); |
| 321 | 321 |
| 322 // Ignore the padding set on the button. | 322 // Ignore the padding set on the button. |
| 323 gfx::Rect contents_bounds = GetContentsBounds(); | 323 gfx::Rect contents_bounds = GetMirroredRect(GetContentsBounds()); |
| 324 contents_bounds.set_x(GetMirroredXForRect(contents_bounds)); | |
| 325 | 324 |
| 326 #if defined(USE_AURA) | 325 #if defined(USE_AURA) |
| 327 // Include the padding in hit-test for touch events. | 326 // Include the padding in hit-test for touch events. |
| 328 // TODO(pkasting): It seems like touch events would generate rects rather | 327 // TODO(pkasting): It seems like touch events would generate rects rather |
| 329 // than points and thus use the TargetForRect() call above. If this is | 328 // than points and thus use the TargetForRect() call above. If this is |
| 330 // reached, it may be from someone calling GetEventHandlerForPoint() while a | 329 // reached, it may be from someone calling GetEventHandlerForPoint() while a |
| 331 // touch happens to be occurring. In such a case, maybe we don't want this | 330 // touch happens to be occurring. In such a case, maybe we don't want this |
| 332 // code to run? It's possible this block should be removed, or maybe this | 331 // code to run? It's possible this block should be removed, or maybe this |
| 333 // whole function deleted. Note that in these cases, we should probably | 332 // whole function deleted. Note that in these cases, we should probably |
| 334 // also remove the padding on the close button bounds (see Tab::Layout()), | 333 // also remove the padding on the close button bounds (see Tab::Layout()), |
| 335 // as it will be pointless. | 334 // as it will be pointless. |
| 336 if (aura::Env::GetInstance()->is_touch_down()) | 335 if (aura::Env::GetInstance()->is_touch_down()) |
| 337 contents_bounds = GetLocalBounds(); | 336 contents_bounds = GetLocalBounds(); |
| 338 #endif | 337 #endif |
| 339 | 338 |
| 340 return contents_bounds.Intersects(rect) ? this : parent(); | 339 return contents_bounds.Intersects(rect) ? this : parent(); |
| 341 } | 340 } |
| 342 | 341 |
| 343 // We need to define this so hit-testing won't include the border region. | 342 // We need to define this so hit-testing won't include the border region. |
| 344 bool GetHitTestMask(gfx::Path* mask) const override { | 343 bool GetHitTestMask(gfx::Path* mask) const override { |
| 345 gfx::Rect button_bounds(GetContentsBounds()); | 344 mask->addRect(gfx::RectToSkRect(GetMirroredRect(GetContentsBounds()))); |
| 346 button_bounds.set_x(GetMirroredXForRect(button_bounds)); | |
| 347 mask->addRect(gfx::RectToSkRect(button_bounds)); | |
| 348 return true; | 345 return true; |
| 349 } | 346 } |
| 350 | 347 |
| 351 Tab* tab_; | 348 Tab* tab_; |
| 352 | 349 |
| 353 DISALLOW_COPY_AND_ASSIGN(TabCloseButton); | 350 DISALLOW_COPY_AND_ASSIGN(TabCloseButton); |
| 354 }; | 351 }; |
| 355 | 352 |
| 356 //////////////////////////////////////////////////////////////////////////////// | 353 //////////////////////////////////////////////////////////////////////////////// |
| 357 // ThrobberView | 354 // ThrobberView |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 const int kIndicatorRadius = 3; | 1259 const int kIndicatorRadius = 3; |
| 1263 const int indicator_x = GetMirroredXWithWidthInView( | 1260 const int indicator_x = GetMirroredXWithWidthInView( |
| 1264 favicon_bounds_.right() - kIndicatorRadius, kIndicatorRadius * 2); | 1261 favicon_bounds_.right() - kIndicatorRadius, kIndicatorRadius * 2); |
| 1265 const int indicator_y = favicon_bounds_.bottom() - kIndicatorRadius; | 1262 const int indicator_y = favicon_bounds_.bottom() - kIndicatorRadius; |
| 1266 canvas->DrawCircle(gfx::Point(indicator_x + kIndicatorRadius, | 1263 canvas->DrawCircle(gfx::Point(indicator_x + kIndicatorRadius, |
| 1267 indicator_y + kIndicatorRadius), | 1264 indicator_y + kIndicatorRadius), |
| 1268 kIndicatorRadius, indicator_flags); | 1265 kIndicatorRadius, indicator_flags); |
| 1269 } | 1266 } |
| 1270 | 1267 |
| 1271 void Tab::PaintIcon(gfx::Canvas* canvas) { | 1268 void Tab::PaintIcon(gfx::Canvas* canvas) { |
| 1272 gfx::Rect bounds = favicon_bounds_; | 1269 gfx::Rect bounds = GetMirroredRect(favicon_bounds_); |
| 1273 bounds.set_x(GetMirroredXForRect(bounds)); | |
| 1274 bounds.Offset(0, favicon_hiding_offset_); | 1270 bounds.Offset(0, favicon_hiding_offset_); |
| 1275 bounds.Intersect(GetContentsBounds()); | 1271 bounds.Intersect(GetContentsBounds()); |
| 1276 if (bounds.IsEmpty()) | 1272 if (bounds.IsEmpty()) |
| 1277 return; | 1273 return; |
| 1278 | 1274 |
| 1279 // Throbber will do its own painting. | 1275 // Throbber will do its own painting. |
| 1280 if (data().network_state != TabRendererData::NETWORK_STATE_NONE && | 1276 if (data().network_state != TabRendererData::NETWORK_STATE_NONE && |
| 1281 data().network_state != TabRendererData::NETWORK_STATE_ERROR) { | 1277 data().network_state != TabRendererData::NETWORK_STATE_ERROR) { |
| 1282 return; | 1278 return; |
| 1283 } | 1279 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 } | 1435 } |
| 1440 | 1436 |
| 1441 void Tab::ScheduleIconPaint() { | 1437 void Tab::ScheduleIconPaint() { |
| 1442 gfx::Rect bounds = favicon_bounds_; | 1438 gfx::Rect bounds = favicon_bounds_; |
| 1443 if (bounds.IsEmpty()) | 1439 if (bounds.IsEmpty()) |
| 1444 return; | 1440 return; |
| 1445 | 1441 |
| 1446 // Extends the area to the bottom when the crash animation is in progress. | 1442 // Extends the area to the bottom when the crash animation is in progress. |
| 1447 if (crash_icon_animation_->is_animating()) | 1443 if (crash_icon_animation_->is_animating()) |
| 1448 bounds.set_height(height() - bounds.y()); | 1444 bounds.set_height(height() - bounds.y()); |
| 1449 bounds.set_x(GetMirroredXForRect(bounds)); | 1445 SchedulePaintInRect(GetMirroredRect(bounds)); |
| 1450 SchedulePaintInRect(bounds); | |
| 1451 } | 1446 } |
| 1452 | 1447 |
| 1453 Tab::BackgroundCache::BackgroundCache() = default; | 1448 Tab::BackgroundCache::BackgroundCache() = default; |
| 1454 Tab::BackgroundCache::~BackgroundCache() = default; | 1449 Tab::BackgroundCache::~BackgroundCache() = default; |
| OLD | NEW |