| 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/frame/glass_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( | 98 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
| 99 views::View* tabstrip) const { | 99 views::View* tabstrip) const { |
| 100 // In maximized RTL windows, don't let the tabstrip overlap the caption area, | 100 // In maximized RTL windows, don't let the tabstrip overlap the caption area, |
| 101 // or the alpha-blending it does will make things like the new avatar button | 101 // or the alpha-blending it does will make things like the new avatar button |
| 102 // look glitchy. | 102 // look glitchy. |
| 103 const int offset = | 103 const int offset = |
| 104 (ui::MaterialDesignController::IsModeMaterial() || !base::i18n::IsRTL() || | 104 (ui::MaterialDesignController::IsModeMaterial() || !base::i18n::IsRTL() || |
| 105 !frame()->IsMaximized()) ? | 105 !frame()->IsMaximized()) ? |
| 106 GetLayoutInsets(AVATAR_ICON).right() : 0; | 106 GetLayoutInsets(AVATAR_ICON).right() : 0; |
| 107 const int x = incognito_bounds_.right() + offset; | 107 const int x = incognito_bounds_.right() + offset; |
| 108 int end_x = width() - NonClientBorderThickness(); | 108 int end_x = width() - NonClientBorderThickness(false); |
| 109 if (!base::i18n::IsRTL()) { | 109 if (!base::i18n::IsRTL()) { |
| 110 end_x = std::min(frame()->GetMinimizeButtonOffset(), end_x) - | 110 end_x = std::min(frame()->GetMinimizeButtonOffset(), end_x) - |
| 111 (frame()->IsMaximized() ? | 111 (frame()->IsMaximized() ? |
| 112 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); | 112 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); |
| 113 | 113 |
| 114 // The new avatar button is optionally displayed to the left of the | 114 // The new avatar button is optionally displayed to the left of the |
| 115 // minimize button. | 115 // minimize button. |
| 116 if (new_avatar_button()) { | 116 if (new_avatar_button()) { |
| 117 const int old_end_x = end_x; | 117 const int old_end_x = end_x; |
| 118 end_x -= new_avatar_button()->width() + kNewAvatarButtonOffset; | 118 end_x -= new_avatar_button()->width() + kNewAvatarButtonOffset; |
| 119 | 119 |
| 120 // In non-maximized mode, allow the new tab button to slide completely | 120 // In non-maximized mode, allow the new tab button to slide completely |
| 121 // under the avatar button. | 121 // under the avatar button. |
| 122 if (!frame()->IsMaximized()) { | 122 if (!frame()->IsMaximized()) { |
| 123 end_x = std::min(end_x + GetLayoutConstant(NEW_TAB_BUTTON_WIDTH) + | 123 end_x = std::min(end_x + GetLayoutConstant(NEW_TAB_BUTTON_WIDTH) + |
| 124 kNewTabCaptionRestoredSpacing, | 124 kNewTabCaptionRestoredSpacing, |
| 125 old_end_x); | 125 old_end_x); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 return gfx::Rect(x, NonClientTopBorderHeight(), std::max(0, end_x - x), | 129 return gfx::Rect(x, NonClientTopBorderHeight(false), std::max(0, end_x - x), |
| 130 tabstrip->GetPreferredSize().height()); | 130 tabstrip->GetPreferredSize().height()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 int GlassBrowserFrameView::GetTopInset() const { | 133 int GlassBrowserFrameView::GetTopInset(bool restored) const { |
| 134 return GetClientAreaInsets().top(); | 134 return GetClientAreaInsets(restored).top(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 int GlassBrowserFrameView::GetThemeBackgroundXInset() const { | 137 int GlassBrowserFrameView::GetThemeBackgroundXInset() const { |
| 138 return 0; | 138 return 0; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void GlassBrowserFrameView::UpdateThrobber(bool running) { | 141 void GlassBrowserFrameView::UpdateThrobber(bool running) { |
| 142 if (throbber_running_) { | 142 if (throbber_running_) { |
| 143 if (running) { | 143 if (running) { |
| 144 DisplayNextThrobberFrame(); | 144 DisplayNextThrobberFrame(); |
| 145 } else { | 145 } else { |
| 146 StopThrobber(); | 146 StopThrobber(); |
| 147 } | 147 } |
| 148 } else if (running) { | 148 } else if (running) { |
| 149 StartThrobber(); | 149 StartThrobber(); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 gfx::Size GlassBrowserFrameView::GetMinimumSize() const { | 153 gfx::Size GlassBrowserFrameView::GetMinimumSize() const { |
| 154 gfx::Size min_size(browser_view()->GetMinimumSize()); | 154 gfx::Size min_size(browser_view()->GetMinimumSize()); |
| 155 | 155 |
| 156 // Account for the client area insets. | 156 // Account for the client area insets. |
| 157 gfx::Insets insets = GetClientAreaInsets(); | 157 gfx::Insets insets = GetClientAreaInsets(false); |
| 158 min_size.Enlarge(insets.width(), insets.height()); | 158 min_size.Enlarge(insets.width(), insets.height()); |
| 159 // Client area insets do not include the shadow thickness. | 159 // Client area insets do not include the shadow thickness. |
| 160 min_size.Enlarge(2 * kContentEdgeShadowThickness, 0); | 160 min_size.Enlarge(2 * kContentEdgeShadowThickness, 0); |
| 161 | 161 |
| 162 // Ensure that the minimum width is enough to hold a tab strip with minimum | 162 // Ensure that the minimum width is enough to hold a tab strip with minimum |
| 163 // width at its usual insets. | 163 // width at its usual insets. |
| 164 if (browser_view()->IsTabStripVisible()) { | 164 if (browser_view()->IsTabStripVisible()) { |
| 165 TabStrip* tabstrip = browser_view()->tabstrip(); | 165 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 166 int min_tabstrip_width = tabstrip->GetMinimumSize().width(); | 166 int min_tabstrip_width = tabstrip->GetMinimumSize().width(); |
| 167 int min_tabstrip_area_width = | 167 int min_tabstrip_area_width = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 186 // If we don't have a tabstrip, we're either a popup or an app window, in | 186 // If we don't have a tabstrip, we're either a popup or an app window, in |
| 187 // which case we have a standard size non-client area and can just use | 187 // which case we have a standard size non-client area and can just use |
| 188 // AdjustWindowRectEx to obtain it. We check for a non-null window handle in | 188 // AdjustWindowRectEx to obtain it. We check for a non-null window handle in |
| 189 // case this gets called before the window is actually created. | 189 // case this gets called before the window is actually created. |
| 190 RECT rect = client_bounds.ToRECT(); | 190 RECT rect = client_bounds.ToRECT(); |
| 191 AdjustWindowRectEx(&rect, GetWindowLong(hwnd, GWL_STYLE), FALSE, | 191 AdjustWindowRectEx(&rect, GetWindowLong(hwnd, GWL_STYLE), FALSE, |
| 192 GetWindowLong(hwnd, GWL_EXSTYLE)); | 192 GetWindowLong(hwnd, GWL_EXSTYLE)); |
| 193 return gfx::Rect(rect); | 193 return gfx::Rect(rect); |
| 194 } | 194 } |
| 195 | 195 |
| 196 gfx::Insets insets = GetClientAreaInsets(); | 196 gfx::Insets insets = GetClientAreaInsets(false); |
| 197 return gfx::Rect(std::max(0, client_bounds.x() - insets.left()), | 197 return gfx::Rect(std::max(0, client_bounds.x() - insets.left()), |
| 198 std::max(0, client_bounds.y() - insets.top()), | 198 std::max(0, client_bounds.y() - insets.top()), |
| 199 client_bounds.width() + insets.width(), | 199 client_bounds.width() + insets.width(), |
| 200 client_bounds.height() + insets.height()); | 200 client_bounds.height() + insets.height()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 203 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
| 204 // If the browser isn't in normal mode, we haven't customized the frame, so | 204 // If the browser isn't in normal mode, we haven't customized the frame, so |
| 205 // Windows can figure this out. If the point isn't within our bounds, then | 205 // Windows can figure this out. If the point isn't within our bounds, then |
| 206 // it's in the native portion of the frame, so again Windows can figure it | 206 // it's in the native portion of the frame, so again Windows can figure it |
| 207 // out. | 207 // out. |
| 208 if (!browser_view()->IsBrowserTypeNormal() || !bounds().Contains(point)) | 208 if (!browser_view()->IsBrowserTypeNormal() || !bounds().Contains(point)) |
| 209 return HTNOWHERE; | 209 return HTNOWHERE; |
| 210 | 210 |
| 211 // See if the point is within the incognito icon or the new avatar menu. | 211 // See if the point is within the incognito icon or the new avatar menu. |
| 212 if ((avatar_button() && | 212 if ((avatar_button() && |
| 213 avatar_button()->GetMirroredBounds().Contains(point)) || | 213 avatar_button()->GetMirroredBounds().Contains(point)) || |
| 214 (new_avatar_button() && | 214 (new_avatar_button() && |
| 215 new_avatar_button()->GetMirroredBounds().Contains(point))) | 215 new_avatar_button()->GetMirroredBounds().Contains(point))) |
| 216 return HTCLIENT; | 216 return HTCLIENT; |
| 217 | 217 |
| 218 int frame_component = frame()->client_view()->NonClientHitTest(point); | 218 int frame_component = frame()->client_view()->NonClientHitTest(point); |
| 219 | 219 |
| 220 // See if we're in the sysmenu region. We still have to check the tabstrip | 220 // See if we're in the sysmenu region. We still have to check the tabstrip |
| 221 // first so that clicks in a tab don't get treated as sysmenu clicks. | 221 // first so that clicks in a tab don't get treated as sysmenu clicks. |
| 222 int nonclient_border_thickness = NonClientBorderThickness(); | 222 int nonclient_border_thickness = NonClientBorderThickness(false); |
| 223 if (gfx::Rect(nonclient_border_thickness, | 223 if (gfx::Rect(nonclient_border_thickness, |
| 224 gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME), | 224 gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME), |
| 225 gfx::win::GetSystemMetricsInDIP(SM_CXSMICON), | 225 gfx::win::GetSystemMetricsInDIP(SM_CXSMICON), |
| 226 gfx::win::GetSystemMetricsInDIP(SM_CYSMICON)).Contains(point)) | 226 gfx::win::GetSystemMetricsInDIP(SM_CYSMICON)).Contains(point)) |
| 227 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; | 227 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; |
| 228 | 228 |
| 229 if (frame_component != HTNOWHERE) | 229 if (frame_component != HTNOWHERE) |
| 230 return frame_component; | 230 return frame_component; |
| 231 | 231 |
| 232 int frame_top_border_height = FrameTopBorderHeight(); | 232 int frame_top_border_height = FrameTopBorderHeight(false); |
| 233 // We want the resize corner behavior to apply to the kResizeCornerWidth | 233 // We want the resize corner behavior to apply to the kResizeCornerWidth |
| 234 // pixels at each end of the top and bottom edges. Because |point|'s x | 234 // pixels at each end of the top and bottom edges. Because |point|'s x |
| 235 // coordinate is based on the DWM-inset portion of the window (so, it's 0 at | 235 // coordinate is based on the DWM-inset portion of the window (so, it's 0 at |
| 236 // the first pixel inside the left DWM margin), we need to subtract the DWM | 236 // the first pixel inside the left DWM margin), we need to subtract the DWM |
| 237 // margin thickness, which we calculate as the total frame border thickness | 237 // margin thickness, which we calculate as the total frame border thickness |
| 238 // minus the nonclient border thickness. | 238 // minus the nonclient border thickness. |
| 239 const int dwm_margin = FrameBorderThickness() - nonclient_border_thickness; | 239 const int dwm_margin = FrameBorderThickness() - nonclient_border_thickness; |
| 240 int window_component = GetHTComponentForFrame(point, frame_top_border_height, | 240 int window_component = GetHTComponentForFrame(point, frame_top_border_height, |
| 241 nonclient_border_thickness, frame_top_border_height, | 241 nonclient_border_thickness, frame_top_border_height, |
| 242 kResizeCornerWidth - dwm_margin, frame()->widget_delegate()->CanResize()); | 242 kResizeCornerWidth - dwm_margin, frame()->widget_delegate()->CanResize()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 new_avatar_button()->GetMirroredBounds().Intersects(rect); | 300 new_avatar_button()->GetMirroredBounds().Intersects(rect); |
| 301 return hit_incognito_icon || hit_new_avatar_button || | 301 return hit_incognito_icon || hit_new_avatar_button || |
| 302 !frame()->client_view()->bounds().Intersects(rect); | 302 !frame()->client_view()->bounds().Intersects(rect); |
| 303 } | 303 } |
| 304 | 304 |
| 305 int GlassBrowserFrameView::FrameBorderThickness() const { | 305 int GlassBrowserFrameView::FrameBorderThickness() const { |
| 306 return (frame()->IsMaximized() || frame()->IsFullscreen()) ? | 306 return (frame()->IsMaximized() || frame()->IsFullscreen()) ? |
| 307 0 : gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME); | 307 0 : gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME); |
| 308 } | 308 } |
| 309 | 309 |
| 310 int GlassBrowserFrameView::FrameTopBorderHeight() const { | 310 int GlassBrowserFrameView::FrameTopBorderHeight(bool restored) const { |
| 311 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass | 311 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass |
| 312 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border | 312 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border |
| 313 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). | 313 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). |
| 314 return frame()->IsFullscreen() ? | 314 return (frame()->IsFullscreen() && !restored) ? |
| 315 0 : gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME); | 315 0 : gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME); |
| 316 } | 316 } |
| 317 | 317 |
| 318 int GlassBrowserFrameView::NonClientBorderThickness() const { | 318 int GlassBrowserFrameView::NonClientBorderThickness(bool restored) const { |
| 319 if (frame()->IsMaximized() || frame()->IsFullscreen()) | 319 if ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) |
| 320 return 0; | 320 return 0; |
| 321 | 321 |
| 322 return (base::win::GetVersion() <= base::win::VERSION_WIN8_1) | 322 return (base::win::GetVersion() <= base::win::VERSION_WIN8_1) |
| 323 ? kNonClientBorderThicknessPreWin10 | 323 ? kNonClientBorderThicknessPreWin10 |
| 324 : kNonClientBorderThicknessWin10; | 324 : kNonClientBorderThicknessWin10; |
| 325 } | 325 } |
| 326 | 326 |
| 327 int GlassBrowserFrameView::NonClientTopBorderHeight() const { | 327 int GlassBrowserFrameView::NonClientTopBorderHeight(bool restored) const { |
| 328 if (frame()->IsFullscreen()) | 328 if (frame()->IsFullscreen() && !restored) |
| 329 return 0; | 329 return 0; |
| 330 | 330 |
| 331 const int top = FrameTopBorderHeight(); | 331 const int top = FrameTopBorderHeight(restored); |
| 332 // The tab top inset is equal to the height of any shadow region above the | 332 // The tab top inset is equal to the height of any shadow region above the |
| 333 // tabs, plus a 1 px top stroke. In maximized mode, we want to push the | 333 // tabs, plus a 1 px top stroke. In maximized mode, we want to push the |
| 334 // shadow region off the top of the screen but leave the top stroke. | 334 // shadow region off the top of the screen but leave the top stroke. |
| 335 // Annoyingly, the pre-MD layout uses different heights for the hit-test | 335 // Annoyingly, the pre-MD layout uses different heights for the hit-test |
| 336 // exclusion region (which we want here, since we're trying to size the border | 336 // exclusion region (which we want here, since we're trying to size the border |
| 337 // so that the region above the tab's hit-test zone matches) versus the shadow | 337 // so that the region above the tab's hit-test zone matches) versus the shadow |
| 338 // thickness. | 338 // thickness. |
| 339 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT); | 339 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT); |
| 340 return frame()->IsMaximized() ? | 340 return (frame()->IsMaximized() && !restored) ? |
| 341 (top - GetLayoutInsets(TAB).top() + 1) : | 341 (top - GetLayoutInsets(TAB).top() + 1) : |
| 342 (top + kNonClientRestoredExtraThickness - exclusion); | 342 (top + kNonClientRestoredExtraThickness - exclusion); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { | 345 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) { |
| 346 ui::ThemeProvider* tp = GetThemeProvider(); | 346 ui::ThemeProvider* tp = GetThemeProvider(); |
| 347 | 347 |
| 348 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 348 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
| 349 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 349 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 350 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); | 350 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); |
| 351 toolbar_bounds.set_origin(toolbar_origin); | 351 toolbar_bounds.set_origin(toolbar_origin); |
| 352 int x = toolbar_bounds.x(); | 352 int x = toolbar_bounds.x(); |
| 353 int w = toolbar_bounds.width(); | 353 int w = toolbar_bounds.width(); |
| 354 | 354 |
| 355 // Toolbar background. | 355 // Toolbar background. |
| 356 int y = toolbar_bounds.y(); | 356 int y = toolbar_bounds.y(); |
| 357 // Tile the toolbar image starting at the frame edge on the left and where | 357 // Tile the toolbar image starting at the frame edge on the left and where |
| 358 // the tabstrip is on the top. | 358 // the tabstrip is on the top. |
| 359 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | 359 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| 360 int dest_y = y; | 360 int dest_y = y; |
| 361 // In the pre-MD world, the toolbar top edge is drawn using the | 361 // In the pre-MD world, the toolbar top edge is drawn using the |
| 362 // IDR_CONTENT_TOP_XXX images, which overlay the toolbar. The top 2 px of | 362 // IDR_CONTENT_TOP_XXX images, which overlay the toolbar. The top 2 px of |
| 363 // these images is the actual top edge, and is partly transparent, so the | 363 // these images is the actual top edge, and is partly transparent, so the |
| 364 // toolbar background shouldn't be drawn over it. | 364 // toolbar background shouldn't be drawn over it. |
| 365 const int kPreMDToolbarTopEdgeExclusion = 2; | 365 const int kPreMDToolbarTopEdgeExclusion = 2; |
| 366 if (browser_view()->IsTabStripVisible()) | 366 if (browser_view()->IsTabStripVisible()) |
| 367 dest_y += kPreMDToolbarTopEdgeExclusion; | 367 dest_y += kPreMDToolbarTopEdgeExclusion; |
| 368 canvas->TileImageInt( | 368 canvas->TileImageInt( |
| 369 *theme_toolbar, x + GetThemeBackgroundXInset(), | 369 *theme_toolbar, x + GetThemeBackgroundXInset(), |
| 370 dest_y - GetTopInset() + Tab::GetYOffsetForActiveTabBackground(), | 370 dest_y - GetTopInset(false) + Tab::GetYOffsetForActiveTabBackground(), |
| 371 x, dest_y, w, theme_toolbar->height()); | 371 x, dest_y, w, theme_toolbar->height()); |
| 372 | 372 |
| 373 // Toolbar edges. | 373 // Toolbar edges. |
| 374 if (browser_view()->IsTabStripVisible()) { | 374 if (browser_view()->IsTabStripVisible()) { |
| 375 // Pre-Windows 10, we draw toolbar left and right edges and top corners, | 375 // Pre-Windows 10, we draw toolbar left and right edges and top corners, |
| 376 // partly atop the window border. In Windows 10+, we don't draw our own | 376 // partly atop the window border. In Windows 10+, we don't draw our own |
| 377 // window border but rather go right to the system border, so we need only | 377 // window border but rather go right to the system border, so we need only |
| 378 // draw the toolbar top edge. | 378 // draw the toolbar top edge. |
| 379 int center_x = x; | 379 int center_x = x; |
| 380 int center_w = w; | 380 int center_w = w; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 430 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
| 431 ui::ThemeProvider* tp = GetThemeProvider(); | 431 ui::ThemeProvider* tp = GetThemeProvider(); |
| 432 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 432 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
| 433 | 433 |
| 434 // The client edges start below the toolbar upper corner images regardless | 434 // The client edges start below the toolbar upper corner images regardless |
| 435 // of how tall the toolbar itself is. | 435 // of how tall the toolbar itself is. |
| 436 int client_area_top = frame()->client_view()->y() + | 436 int client_area_top = frame()->client_view()->y() + |
| 437 browser_view()->GetToolbarBounds().y() + | 437 browser_view()->GetToolbarBounds().y() + |
| 438 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); | 438 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height(); |
| 439 int client_area_bottom = | 439 int client_area_bottom = |
| 440 std::max(client_area_top, height() - NonClientBorderThickness()); | 440 std::max(client_area_top, height() - NonClientBorderThickness(false)); |
| 441 int client_area_height = client_area_bottom - client_area_top; | 441 int client_area_height = client_area_bottom - client_area_top; |
| 442 | 442 |
| 443 // Draw the client edge images. | 443 // Draw the client edge images. |
| 444 gfx::ImageSkia* right = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); | 444 gfx::ImageSkia* right = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE); |
| 445 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, | 445 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, |
| 446 right->width(), client_area_height); | 446 right->width(), client_area_height); |
| 447 canvas->DrawImageInt( | 447 canvas->DrawImageInt( |
| 448 *tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), | 448 *tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER), |
| 449 client_area_bounds.right(), client_area_bottom); | 449 client_area_bounds.right(), client_area_bottom); |
| 450 gfx::ImageSkia* bottom = tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER); | 450 gfx::ImageSkia* bottom = tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // FrameTopBorderHeight() pixels from the top of the window; all those top | 495 // FrameTopBorderHeight() pixels from the top of the window; all those top |
| 496 // border pixels are offscreen, so this result in caption buttons flush with | 496 // border pixels are offscreen, so this result in caption buttons flush with |
| 497 // the top of the screen. In restored mode, the caption buttons are first | 497 // the top of the screen. In restored mode, the caption buttons are first |
| 498 // placed just below a 2 px border at the top of the window (which is the | 498 // placed just below a 2 px border at the top of the window (which is the |
| 499 // first two pixels' worth of FrameTopBorderHeight()), then extended upwards | 499 // first two pixels' worth of FrameTopBorderHeight()), then extended upwards |
| 500 // one extra pixel to overlap part of this border. | 500 // one extra pixel to overlap part of this border. |
| 501 // | 501 // |
| 502 // To match both of these, we size the button as if it's always the extra one | 502 // To match both of these, we size the button as if it's always the extra one |
| 503 // pixel in height, then we place it at the correct position in restored mode, | 503 // pixel in height, then we place it at the correct position in restored mode, |
| 504 // or one pixel above the top of the screen in maximized mode. | 504 // or one pixel above the top of the screen in maximized mode. |
| 505 int button_y = frame()->IsMaximized() ? (FrameTopBorderHeight() - 1) : 1; | 505 int button_y = frame()->IsMaximized() ? (FrameTopBorderHeight(false) - 1) : 1; |
| 506 new_avatar_button()->SetBounds( | 506 new_avatar_button()->SetBounds( |
| 507 button_x, | 507 button_x, |
| 508 button_y, | 508 button_y, |
| 509 label_size.width(), | 509 label_size.width(), |
| 510 gfx::win::GetSystemMetricsInDIP(SM_CYMENUSIZE) + 1); | 510 gfx::win::GetSystemMetricsInDIP(SM_CYMENUSIZE) + 1); |
| 511 } | 511 } |
| 512 | 512 |
| 513 void GlassBrowserFrameView::LayoutIncognitoIcon() { | 513 void GlassBrowserFrameView::LayoutIncognitoIcon() { |
| 514 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); | 514 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); |
| 515 gfx::Size size; | 515 gfx::Size size; |
| 516 // During startup it's possible to reach here before the browser view has been | 516 // During startup it's possible to reach here before the browser view has been |
| 517 // added to the view hierarchy. In this case it won't have a widget and thus | 517 // added to the view hierarchy. In this case it won't have a widget and thus |
| 518 // can't access the theme provider, which is required to get the incognito | 518 // can't access the theme provider, which is required to get the incognito |
| 519 // icon. Use an empty size in this case, which will still place the tabstrip | 519 // icon. Use an empty size in this case, which will still place the tabstrip |
| 520 // at the correct coordinates for a non-incognito window. We should get | 520 // at the correct coordinates for a non-incognito window. We should get |
| 521 // another layout call after the browser view has a widget anyway. | 521 // another layout call after the browser view has a widget anyway. |
| 522 if (browser_view()->GetWidget()) | 522 if (browser_view()->GetWidget()) |
| 523 size = browser_view()->GetOTRAvatarIcon().size(); | 523 size = browser_view()->GetOTRAvatarIcon().size(); |
| 524 int x = NonClientBorderThickness(); | 524 int x = NonClientBorderThickness(false); |
| 525 // In RTL, the icon needs to start after the caption buttons. | 525 // In RTL, the icon needs to start after the caption buttons. |
| 526 if (base::i18n::IsRTL()) { | 526 if (base::i18n::IsRTL()) { |
| 527 x = width() - frame()->GetMinimizeButtonOffset() + | 527 x = width() - frame()->GetMinimizeButtonOffset() + |
| 528 (new_avatar_button() ? | 528 (new_avatar_button() ? |
| 529 (new_avatar_button()->width() + kNewAvatarButtonOffset) : 0); | 529 (new_avatar_button()->width() + kNewAvatarButtonOffset) : 0); |
| 530 } | 530 } |
| 531 const int bottom = | 531 const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - |
| 532 GetTopInset() + browser_view()->GetTabStripHeight() - insets.bottom(); | 532 insets.bottom(); |
| 533 const int y = (ui::MaterialDesignController::IsModeMaterial() || | 533 const int y = (ui::MaterialDesignController::IsModeMaterial() || |
| 534 !frame()->IsMaximized()) ? | 534 !frame()->IsMaximized()) ? |
| 535 (bottom - size.height()) : FrameTopBorderHeight(); | 535 (bottom - size.height()) : FrameTopBorderHeight(false); |
| 536 incognito_bounds_.SetRect(x + (avatar_button() ? insets.left() : 0), y, | 536 incognito_bounds_.SetRect(x + (avatar_button() ? insets.left() : 0), y, |
| 537 avatar_button() ? size.width() : 0, bottom - y); | 537 avatar_button() ? size.width() : 0, bottom - y); |
| 538 if (avatar_button()) | 538 if (avatar_button()) |
| 539 avatar_button()->SetBoundsRect(incognito_bounds_); | 539 avatar_button()->SetBoundsRect(incognito_bounds_); |
| 540 } | 540 } |
| 541 | 541 |
| 542 void GlassBrowserFrameView::LayoutClientView() { | 542 void GlassBrowserFrameView::LayoutClientView() { |
| 543 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); | 543 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
| 544 } | 544 } |
| 545 | 545 |
| 546 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets() const { | 546 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets(bool restored) const { |
| 547 if (!browser_view()->IsTabStripVisible()) | 547 if (!browser_view()->IsTabStripVisible()) |
| 548 return gfx::Insets(); | 548 return gfx::Insets(); |
| 549 | 549 |
| 550 const int top_height = NonClientTopBorderHeight(); | 550 const int top_height = NonClientTopBorderHeight(restored); |
| 551 const int border_thickness = NonClientBorderThickness(); | 551 const int border_thickness = NonClientBorderThickness(restored); |
| 552 return gfx::Insets(top_height, | 552 return gfx::Insets(top_height, |
| 553 border_thickness, | 553 border_thickness, |
| 554 border_thickness, | 554 border_thickness, |
| 555 border_thickness); | 555 border_thickness); |
| 556 } | 556 } |
| 557 | 557 |
| 558 gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds(int width, | 558 gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds(int width, |
| 559 int height) const { | 559 int height) const { |
| 560 gfx::Rect bounds(0, 0, width, height); | 560 gfx::Rect bounds(0, 0, width, height); |
| 561 bounds.Inset(GetClientAreaInsets()); | 561 bounds.Inset(GetClientAreaInsets(false)); |
| 562 return bounds; | 562 return bounds; |
| 563 } | 563 } |
| 564 | 564 |
| 565 void GlassBrowserFrameView::StartThrobber() { | 565 void GlassBrowserFrameView::StartThrobber() { |
| 566 if (!throbber_running_) { | 566 if (!throbber_running_) { |
| 567 throbber_running_ = true; | 567 throbber_running_ = true; |
| 568 throbber_frame_ = 0; | 568 throbber_frame_ = 0; |
| 569 InitThrobberIcons(); | 569 InitThrobberIcons(); |
| 570 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, | 570 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, |
| 571 static_cast<WPARAM>(ICON_SMALL), | 571 static_cast<WPARAM>(ICON_SMALL), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 static bool initialized = false; | 634 static bool initialized = false; |
| 635 if (!initialized) { | 635 if (!initialized) { |
| 636 for (int i = 0; i < kThrobberIconCount; ++i) { | 636 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 637 throbber_icons_[i] = | 637 throbber_icons_[i] = |
| 638 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 638 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
| 639 DCHECK(throbber_icons_[i]); | 639 DCHECK(throbber_icons_[i]); |
| 640 } | 640 } |
| 641 initialized = true; | 641 initialized = true; |
| 642 } | 642 } |
| 643 } | 643 } |
| OLD | NEW |