diff options
86 files changed, 380 insertions, 279 deletions
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc index aefe985..3b15075 100644 --- a/ash/desktop_background/desktop_background_view.cc +++ b/ash/desktop_background/desktop_background_view.cc @@ -134,7 +134,8 @@ void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { RoundPositive(static_cast<double>(height()) / horizontal_ratio)); } - gfx::Rect wallpaper_cropped_rect = wallpaper_rect.Center(cropped_size); + gfx::Rect wallpaper_cropped_rect = wallpaper_rect; + wallpaper_cropped_rect.ClampToCenteredSize(cropped_size); canvas->DrawImageInt(wallpaper, wallpaper_cropped_rect.x(), wallpaper_cropped_rect.y(), wallpaper_cropped_rect.width(), wallpaper_cropped_rect.height(), diff --git a/ash/display/multi_display_manager.cc b/ash/display/multi_display_manager.cc index a1f26ba..7386115 100644 --- a/ash/display/multi_display_manager.cc +++ b/ash/display/multi_display_manager.cc @@ -346,7 +346,8 @@ const gfx::Display& MultiDisplayManager::GetDisplayMatching( for (std::vector<gfx::Display>::const_iterator iter = displays_.begin(); iter != displays_.end(); ++iter) { const gfx::Display& display = *iter; - gfx::Rect intersect = display.bounds().Intersect(rect); + gfx::Rect intersect = display.bounds(); + intersect.Intersect(rect); int area = intersect.width() * intersect.height(); if (area > max) { max = area; diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc index b7c94e8..bbc3975 100644 --- a/ash/drag_drop/drag_drop_controller_unittest.cc +++ b/ash/drag_drop/drag_drop_controller_unittest.cc @@ -207,7 +207,7 @@ void AddViewToWidgetAndResize(views::Widget* widget, views::View* view) { contents_view->AddChildView(view); view->SetBounds(contents_view->width(), 0, 100, 100); gfx::Rect contents_view_bounds = contents_view->bounds(); - contents_view_bounds = contents_view_bounds.Union(view->bounds()); + contents_view_bounds.Union(view->bounds()); contents_view->SetBoundsRect(contents_view_bounds); widget->SetBounds(contents_view_bounds); } diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index a3c2fe7..c5044ad 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -705,7 +705,7 @@ bool LauncherView::ShouldHideTooltip(const gfx::Point& cursor_location) { continue; gfx::Rect child_bounds = child->GetMirroredBounds(); - active_bounds = active_bounds.Union(child_bounds); + active_bounds.Union(child_bounds); } return !active_bounds.Contains(cursor_location); diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc index fdb062f..3e1e806 100644 --- a/ash/launcher/launcher_view_unittest.cc +++ b/ash/launcher/launcher_view_unittest.cc @@ -645,8 +645,9 @@ TEST_F(LauncherViewTest, ShouldHideTooltipTest) { gfx::Rect app_button_rect = GetButtonByID(app_button_id)->GetMirroredBounds(); gfx::Rect tab_button_rect = GetButtonByID(tab_button_id)->GetMirroredBounds(); ASSERT_FALSE(app_button_rect.Intersects(tab_button_rect)); - EXPECT_FALSE(launcher_view_->ShouldHideTooltip( - app_button_rect.Union(tab_button_rect).CenterPoint())); + gfx::Rect union_rect = app_button_rect; + union_rect.Union(tab_button_rect); + EXPECT_FALSE(launcher_view_->ShouldHideTooltip(union_rect.CenterPoint())); // The tooltip should hide if it's outside of all buttons. gfx::Rect all_area; @@ -655,10 +656,9 @@ TEST_F(LauncherViewTest, ShouldHideTooltipTest) { if (!button) continue; - all_area = all_area.Union(button->GetMirroredBounds()); + all_area.Union(button->GetMirroredBounds()); } - all_area = all_area.Union( - launcher_view_->GetAppListButtonView()->GetMirroredBounds()); + all_area.Union(launcher_view_->GetAppListButtonView()->GetMirroredBounds()); EXPECT_FALSE(launcher_view_->ShouldHideTooltip(all_area.origin())); EXPECT_FALSE(launcher_view_->ShouldHideTooltip( gfx::Point(all_area.right() - 1, all_area.bottom() - 1))); diff --git a/ash/system/drive/tray_drive.cc b/ash/system/drive/tray_drive.cc index f37ad80..489427e 100644 --- a/ash/system/drive/tray_drive.cc +++ b/ash/system/drive/tray_drive.cc @@ -220,7 +220,8 @@ class DriveDetailedView : public TrayDetailsView, kBottomPadding - status_img_->GetPreferredSize().height())/2), status_img_->GetPreferredSize()); - status_img_->SetBoundsRect(bounds_status.Intersect(child_area)); + bounds_status.Intersect(child_area); + status_img_->SetBoundsRect(bounds_status); pos_x += status_img_->bounds().width() + kHorizontalPadding; gfx::Rect bounds_label(pos_x, @@ -230,7 +231,8 @@ class DriveDetailedView : public TrayDetailsView, status_img_->GetPreferredSize().width() - cancel_button_->GetPreferredSize().width(), label_container_->GetPreferredSize().height()); - label_container_->SetBoundsRect(bounds_label.Intersect(child_area)); + bounds_label.Intersect(child_area); + label_container_->SetBoundsRect(bounds_label); pos_x += label_container_->bounds().width() + kHorizontalPadding; gfx::Rect bounds_button( @@ -239,7 +241,8 @@ class DriveDetailedView : public TrayDetailsView, kBottomPadding - cancel_button_->GetPreferredSize().height())/2), cancel_button_->GetPreferredSize()); - cancel_button_->SetBoundsRect(bounds_button.Intersect(child_area)); + bounds_button.Intersect(child_area); + cancel_button_->SetBoundsRect(bounds_button); } // views::ButtonListener overrides. diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc index ddc2b8c..3b25b38 100644 --- a/ash/system/tray/tray_views.cc +++ b/ash/system/tray/tray_views.cc @@ -622,9 +622,10 @@ void SpecialPopupRow::Layout() { gfx::Rect bounds(button_container_->GetPreferredSize()); bounds.set_height(content_bounds.height()); - bounds = content_bounds.Center(bounds.size()); - bounds.set_x(content_bounds.width() - bounds.width()); - button_container_->SetBoundsRect(bounds); + gfx::Rect container_bounds = content_bounds; + container_bounds.ClampToCenteredSize(bounds.size()); + container_bounds.set_x(content_bounds.width() - bounds.width()); + button_container_->SetBoundsRect(container_bounds); bounds = content_->bounds(); bounds.set_width(button_container_->x()); diff --git a/ash/system/user/tray_user.cc b/ash/system/user/tray_user.cc index 7b90d87..262ae6f 100644 --- a/ash/system/user/tray_user.cc +++ b/ash/system/user/tray_user.cc @@ -76,7 +76,8 @@ class RoundedImageView : public views::View { virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { View::OnPaint(canvas); gfx::Rect image_bounds(GetPreferredSize()); - image_bounds = gfx::Rect(size()).Center(image_bounds.size()); + image_bounds = gfx::Rect(size()); + image_bounds.ClampToCenteredSize(image_bounds.size()); image_bounds.Inset(GetInsets()); const SkScalar kRadius = SkIntToScalar(corner_radius_); SkPath path; @@ -220,7 +221,8 @@ class UserView : public views::View, container_->SetBoundsRect(gfx::Rect(size())); if (signout_ && user_info_) { gfx::Rect signout_bounds(signout_->GetPreferredSize()); - signout_bounds = bounds().Center(signout_bounds.size()); + signout_bounds = bounds(); + signout_bounds.ClampToCenteredSize(signout_bounds.size()); signout_bounds.set_x(width() - signout_bounds.width() - kTrayPopupPaddingHorizontal); signout_->SetBoundsRect(signout_bounds); diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc index 3bb99bc..45c4785 100644 --- a/ash/tooltips/tooltip_controller.cc +++ b/ash/tooltips/tooltip_controller.cc @@ -179,7 +179,8 @@ class TooltipController::Tooltip : public views::WidgetObserver { if (tooltip_rect.bottom() > display_bounds.bottom()) tooltip_rect.set_y(mouse_pos.y() - tooltip_height); - GetWidget()->SetBounds(tooltip_rect.AdjustToFit(display_bounds)); + tooltip_rect.AdjustToFit(display_bounds); + GetWidget()->SetBounds(tooltip_rect); } views::Widget* GetWidget() { diff --git a/ash/tooltips/tooltip_controller_unittest.cc b/ash/tooltips/tooltip_controller_unittest.cc index d48db06..9efbd75 100644 --- a/ash/tooltips/tooltip_controller_unittest.cc +++ b/ash/tooltips/tooltip_controller_unittest.cc @@ -72,7 +72,7 @@ void AddViewToWidgetAndResize(views::Widget* widget, views::View* view) { contents_view->AddChildView(view); view->SetBounds(contents_view->width(), 0, 100, 100); gfx::Rect contents_view_bounds = contents_view->bounds(); - contents_view_bounds = contents_view_bounds.Union(view->bounds()); + contents_view_bounds.Union(view->bounds()); contents_view->SetBoundsRect(contents_view_bounds); widget->SetBounds(gfx::Rect(widget->GetWindowBoundsInScreen().origin(), contents_view_bounds.size())); diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc index 1bf6434a..78019cd 100644 --- a/ash/wm/base_layout_manager.cc +++ b/ash/wm/base_layout_manager.cc @@ -224,7 +224,9 @@ void BaseLayoutManager::AdjustWindowSizesForScreenChange() { gfx::Rect display_rect = ScreenAsh::GetDisplayWorkAreaBoundsInParent(window); // Put as much of the window as possible within the display area. - window->SetBounds(window->bounds().AdjustToFit(display_rect)); + gfx::Rect bounds = window->bounds(); + bounds.AdjustToFit(display_rect); + window->SetBounds(bounds); } } } diff --git a/ash/wm/partial_screenshot_view.cc b/ash/wm/partial_screenshot_view.cc index 2c3e09d..dd0bd1da 100644 --- a/ash/wm/partial_screenshot_view.cc +++ b/ash/wm/partial_screenshot_view.cc @@ -121,8 +121,10 @@ void PartialScreenshotView::OnMouseReleased(const ui::MouseEvent& event) { is_dragging_ = false; if (screenshot_delegate_) { aura::RootWindow *root_window = Shell::GetPrimaryRootWindow(); + gfx::Rect root_window_screenshot_rect = root_window->bounds(); + root_window_screenshot_rect.Intersect(GetScreenshotRect()); screenshot_delegate_->HandleTakePartialScreenshot( - root_window, root_window->bounds().Intersect(GetScreenshotRect())); + root_window, root_window_screenshot_rect); } } diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index 8aff1ae..307c3ba 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -746,7 +746,8 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture( target_bounds->launcher_bounds_in_root.height() + move - translate); // The statusbar should be in the center. - gfx::Rect status_y = target_bounds->launcher_bounds_in_root.Center( + gfx::Rect status_y = target_bounds->launcher_bounds_in_root; + status_y.ClampToCenteredSize( target_bounds->status_bounds_in_root.size()); target_bounds->status_bounds_in_root.set_y(status_y.y()); } @@ -774,7 +775,8 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture( } // The statusbar should be in the center. - gfx::Rect status_x = target_bounds->launcher_bounds_in_root.Center( + gfx::Rect status_x = target_bounds->launcher_bounds_in_root; + status_x.ClampToCenteredSize( target_bounds->status_bounds_in_root.size()); target_bounds->status_bounds_in_root.set_x(status_x.x()); } diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc index 2bfc73a..22dadc8 100644 --- a/ash/wm/system_modal_container_layout_manager.cc +++ b/ash/wm/system_modal_container_layout_manager.cc @@ -79,7 +79,9 @@ void SystemModalContainerLayoutManager::OnWindowResized() { if (!modal_windows_.empty()) { aura::Window::Windows::iterator it = modal_windows_.begin(); for (it = modal_windows_.begin(); it != modal_windows_.end(); ++it) { - (*it)->SetBounds((*it)->bounds().AdjustToFit(container_->bounds())); + gfx::Rect bounds = (*it)->bounds(); + bounds.AdjustToFit(container_->bounds()); + (*it)->SetBounds(bounds); } } } diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc index 8b9dcb0..55513af 100644 --- a/ash/wm/window_util.cc +++ b/ash/wm/window_util.cc @@ -110,7 +110,8 @@ void ToggleMaximizedWindow(aura::Window* window) { void CenterWindow(aura::Window* window) { const gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow(window); - gfx::Rect center = display.work_area().Center(window->bounds().size()); + gfx::Rect center = display.work_area(); + center.ClampToCenteredSize(window->bounds().size()); window->SetBounds(center); } diff --git a/ash/wm/workspace/workspace_layout_manager2.cc b/ash/wm/workspace/workspace_layout_manager2.cc index 6731557..29e4c6c 100644 --- a/ash/wm/workspace/workspace_layout_manager2.cc +++ b/ash/wm/workspace/workspace_layout_manager2.cc @@ -289,7 +289,9 @@ void WorkspaceLayoutManager2::AdjustWindowSizeForScreenChange( if (reason == ADJUST_WINDOW_SCREEN_SIZE_CHANGED) { // The work area may be smaller than the full screen. Put as much of the // window as possible within the display area. - window->SetBounds(window->bounds().AdjustToFit(work_area_)); + gfx::Rect bounds = window->bounds(); + bounds.AdjustToFit(work_area_); + window->SetBounds(bounds); } else if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) { // If the window is completely outside the display work area, then move it // enough to be visible again. diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc index e16ba23..d3cc9b7 100644 --- a/ash/wm/workspace/workspace_window_resizer.cc +++ b/ash/wm/workspace/workspace_window_resizer.cc @@ -688,8 +688,8 @@ void WorkspaceWindowResizer::UpdateDragPhantomWindow(const gfx::Rect& bounds, const gfx::Rect root_bounds_in_screen(another_root->GetBoundsInScreen()); const gfx::Rect bounds_in_screen = ScreenAsh::ConvertRectToScreen(window()->parent(), bounds); - const gfx::Rect bounds_in_another_root = - root_bounds_in_screen.Intersect(bounds_in_screen); + gfx::Rect bounds_in_another_root = root_bounds_in_screen; + bounds_in_another_root.Intersect(bounds_in_screen); const float fraction_in_another_window = (bounds_in_another_root.width() * bounds_in_another_root.height()) / diff --git a/cc/delegated_renderer_layer_impl.cc b/cc/delegated_renderer_layer_impl.cc index 3f77a55..4101ab7 100644 --- a/cc/delegated_renderer_layer_impl.cc +++ b/cc/delegated_renderer_layer_impl.cc @@ -58,7 +58,8 @@ void DelegatedRendererLayerImpl::setRenderPasses(ScopedPtrVector<RenderPass>& re if (!m_renderPassesInDrawOrder.isEmpty()) { gfx::RectF newRootDamage = m_renderPassesInDrawOrder.last()->damageRect(); - m_renderPassesInDrawOrder.last()->setDamageRect(oldRootDamage.Union(newRootDamage)); + newRootDamage.Union(oldRootDamage); + m_renderPassesInDrawOrder.last()->setDamageRect(newRootDamage); } } diff --git a/cc/direct_renderer.cc b/cc/direct_renderer.cc index 907850b..d38834d 100644 --- a/cc/direct_renderer.cc +++ b/cc/direct_renderer.cc @@ -160,7 +160,7 @@ void DirectRenderer::drawFrame(const RenderPassList& renderPassesInDrawOrder, co frame.renderPassesById = &renderPassesById; frame.rootRenderPass = rootRenderPass; frame.rootDamageRect = capabilities().usingPartialSwap ? rootRenderPass->damageRect() : rootRenderPass->outputRect(); - frame.rootDamageRect = frame.rootDamageRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); + frame.rootDamageRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); beginDrawingFrame(frame); for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) @@ -177,7 +177,7 @@ void DirectRenderer::drawRenderPass(DrawingFrame& frame, const RenderPass* rende if (frame.rootDamageRect != frame.rootRenderPass->outputRect()) { WebTransformationMatrix inverseTransformToRoot = frame.currentRenderPass->transformToRootTarget().inverse(); gfx::RectF damageRectInRenderPassSpace = MathUtil::projectClippedRect(inverseTransformToRoot, cc::FloatRect(frame.rootDamageRect)); - frame.scissorRectInRenderPassSpace = frame.scissorRectInRenderPassSpace.Intersect(damageRectInRenderPassSpace); + frame.scissorRectInRenderPassSpace.Intersect(damageRectInRenderPassSpace); } enableScissorTestRect(moveScissorToWindowSpace(frame, frame.scissorRectInRenderPassSpace)); @@ -185,7 +185,8 @@ void DirectRenderer::drawRenderPass(DrawingFrame& frame, const RenderPass* rende const QuadList& quadList = renderPass->quadList(); for (QuadList::constBackToFrontIterator it = quadList.backToFrontBegin(); it != quadList.backToFrontEnd(); ++it) { - gfx::RectF quadScissorRect = frame.scissorRectInRenderPassSpace.Intersect((*it)->clippedRectInTarget()); + gfx::RectF quadScissorRect = frame.scissorRectInRenderPassSpace; + quadScissorRect.Intersect((*it)->clippedRectInTarget()); if (!quadScissorRect.IsEmpty()) { enableScissorTestRect(moveScissorToWindowSpace(frame, quadScissorRect)); drawQuad(frame, *it); diff --git a/cc/draw_quad.cc b/cc/draw_quad.cc index 9671b11..9250274 100644 --- a/cc/draw_quad.cc +++ b/cc/draw_quad.cc @@ -43,7 +43,8 @@ gfx::Rect DrawQuad::opaqueRect() const void DrawQuad::setQuadVisibleRect(gfx::Rect quadVisibleRect) { - m_quadVisibleRect = quadVisibleRect.Intersect(m_quadRect); + m_quadVisibleRect = quadVisibleRect; + m_quadVisibleRect.Intersect(m_quadRect); } unsigned DrawQuad::size() const diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc index 042410a..361ced1 100644 --- a/cc/gl_renderer.cc +++ b/cc/gl_renderer.cc @@ -453,7 +453,7 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(DrawingFrame& frame, filters.getOutsets(top, right, bottom, left); deviceRect.Inset(-left, -top, -right, -bottom); - deviceRect = deviceRect.Intersect(frame.currentRenderPass->outputRect()); + deviceRect.Intersect(frame.currentRenderPass->outputRect()); scoped_ptr<ScopedTexture> deviceBackgroundTexture = ScopedTexture::create(m_resourceProvider); if (!getFramebufferTexture(deviceBackgroundTexture.get(), cc::IntRect(deviceRect))) @@ -1013,7 +1013,7 @@ void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra void GLRenderer::finishDrawingFrame(DrawingFrame& frame) { m_currentFramebufferLock.reset(); - m_swapBufferRect = m_swapBufferRect.Union(gfx::ToEnclosingRect(frame.rootDamageRect)); + m_swapBufferRect.Union(gfx::ToEnclosingRect(frame.rootDamageRect)); GLC(m_context, m_context->disable(GL_SCISSOR_TEST)); GLC(m_context, m_context->disable(GL_BLEND)); @@ -1111,7 +1111,7 @@ bool GLRenderer::swapBuffers() if (m_capabilities.usingPartialSwap) { // If supported, we can save significant bandwidth by only swapping the damaged/scissored region (clamped to the viewport) - m_swapBufferRect = m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); + m_swapBufferRect.Intersect(gfx::Rect(gfx::Point(), viewportSize())); int flippedYPosOfRectBottom = viewportHeight() - m_swapBufferRect.y() - m_swapBufferRect.height(); m_context->postSubBufferCHROMIUM(m_swapBufferRect.x(), flippedYPosOfRectBottom, m_swapBufferRect.width(), m_swapBufferRect.height()); } else { diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc index 4720b04..05b7a11 100644 --- a/cc/software_renderer.cc +++ b/cc/software_renderer.cc @@ -255,7 +255,8 @@ void SoftwareRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureD // FIXME: Add support for non-premultiplied alpha. ResourceProvider::ScopedReadLockSoftware quadResourceLock(m_resourceProvider, quad->resourceId()); - gfx::RectF uvRect = quad->uvRect().Scale(quad->quadRect().width(), quad->quadRect().height()); + gfx::RectF uvRect = quad->uvRect(); + uvRect.Scale(quad->quadRect().width(), quad->quadRect().height()); SkIRect skUvRect = toSkIRect(gfx::ToEnclosingRect(uvRect)); if (quad->flipped()) m_skCurrentCanvas->scale(1, -1); diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc index e4a3a4e..a05c8ede 100644 --- a/chrome/browser/instant/instant_controller.cc +++ b/chrome/browser/instant/instant_controller.cc @@ -751,7 +751,8 @@ void InstantController::SendBoundsToPage() { last_omnibox_bounds_ = omnibox_bounds_; gfx::Rect preview_bounds = delegate_->GetInstantBounds(); - gfx::Rect intersection = omnibox_bounds_.Intersect(preview_bounds); + gfx::Rect intersection = omnibox_bounds_; + intersection.Intersect(preview_bounds); // Translate into window coordinates. if (!intersection.IsEmpty()) { diff --git a/chrome/browser/notifications/balloon_collection_impl.cc b/chrome/browser/notifications/balloon_collection_impl.cc index f845149..4057eef 100644 --- a/chrome/browser/notifications/balloon_collection_impl.cc +++ b/chrome/browser/notifications/balloon_collection_impl.cc @@ -218,7 +218,7 @@ gfx::Rect BalloonCollectionImpl::GetBalloonsBoundingBox() const { for (iter = balloons.begin(); iter != balloons.end(); ++iter) { gfx::Rect balloon_box = gfx::Rect((*iter)->GetPosition(), (*iter)->GetViewSize()); - bounds = bounds.Union(balloon_box); + bounds.Union(balloon_box); } return bounds; diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc index 0579c03..d272e1e 100644 --- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc @@ -524,7 +524,8 @@ gboolean BrowserToolbarGtk::OnAlignmentExpose(GtkWidget* widget, if (window_->ShouldDrawContentDropShadow()) { // Leave room to draw rounded corners. - area = area.Subtract(right).Subtract(left); + area.Subtract(right); + area.Subtract(left); } gfx::Image background = theme_service_->GetImageNamed(IDR_THEME_TOOLBAR); diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc index d7800d3..d17b05b 100644 --- a/chrome/browser/ui/panels/panel_manager.cc +++ b/chrome/browser/ui/panels/panel_manager.cc @@ -187,7 +187,7 @@ Panel* PanelManager::CreatePanel(const std::string& app_name, bounds.set_origin(docked_strip_->GetDefaultPositionForPanel(bounds.size())); } else { bounds.set_origin(requested_bounds.origin()); - bounds = bounds.AdjustToFit(display_settings_provider_->GetDisplayArea()); + bounds.AdjustToFit(display_settings_provider_->GetDisplayArea()); } // Create the panel. diff --git a/chrome/browser/ui/tabs/dock_info.cc b/chrome/browser/ui/tabs/dock_info.cc index 73879f8..dd6de54 100644 --- a/chrome/browser/ui/tabs/dock_info.cc +++ b/chrome/browser/ui/tabs/dock_info.cc @@ -224,7 +224,7 @@ gfx::Rect DockInfo::GetPopupRect() const { case BOTTOM_OF_WINDOW: { // Constrain the popup to the monitor's bounds. gfx::Rect ideal_bounds(x, y, popup_width(), popup_height()); - ideal_bounds = ideal_bounds.AdjustToFit(monitor_bounds_); + ideal_bounds.AdjustToFit(monitor_bounds_); return ideal_bounds; } case DockInfo::MAXIMIZE: diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc index 3ac069e..5ba5bd1 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc @@ -1497,7 +1497,8 @@ class BookmarkBarViewTest17 : public BookmarkBarViewEventTestBase { // sure the click is always on the child menu. gfx::Rect context_rect = context_menu->GetSubmenu()->GetBoundsInScreen(); gfx::Rect child_menu_rect = child_menu->GetBoundsInScreen(); - gfx::Rect clickable_rect = child_menu_rect.Subtract(context_rect); + gfx::Rect clickable_rect = child_menu_rect; + clickable_rect.Subtract(context_rect); ASSERT_FALSE(clickable_rect.IsEmpty()); observer_.set_task(CreateEventTask(this, &BookmarkBarViewTest17::Step4)); MoveMouseAndPress(clickable_rect.CenterPoint(), ui_controls::RIGHT, diff --git a/chrome/browser/ui/views/extensions/extension_dialog.cc b/chrome/browser/ui/views/extensions/extension_dialog.cc index c290fc1..095760c 100644 --- a/chrome/browser/ui/views/extensions/extension_dialog.cc +++ b/chrome/browser/ui/views/extensions/extension_dialog.cc @@ -167,7 +167,7 @@ void ExtensionDialog::InitWindow(BaseWindow* base_window, gfx::Rect screen_rect = gfx::Screen::GetScreenFor(parent)-> GetDisplayNearestPoint(center).bounds(); gfx::Rect bounds_rect = gfx::Rect(x, y, width, height); - bounds_rect = bounds_rect.AdjustToFit(screen_rect); + bounds_rect.AdjustToFit(screen_rect); window_->SetBounds(bounds_rect); window_->Show(); diff --git a/chrome/browser/ui/views/notifications/balloon_view_views.cc b/chrome/browser/ui/views/notifications/balloon_view_views.cc index a9d7c66..7975143 100644 --- a/chrome/browser/ui/views/notifications/balloon_view_views.cc +++ b/chrome/browser/ui/views/notifications/balloon_view_views.cc @@ -260,7 +260,8 @@ gfx::Rect BalloonViewImpl::GetCloseButtonBounds() const { const gfx::Size& pref_size(close_button_->GetPreferredSize()); bounds.Inset(bounds.width() - kShelfMargin - pref_size.width(), 0, kShelfMargin, 0); - return bounds.Center(pref_size); + bounds.ClampToCenteredSize(pref_size); + return bounds; } gfx::Rect BalloonViewImpl::GetOptionsButtonBounds() const { @@ -270,7 +271,8 @@ gfx::Rect BalloonViewImpl::GetOptionsButtonBounds() const { bounds.set_x(GetCloseButtonBounds().x() - kOptionsDismissSpacing - pref_size.width()); bounds.set_width(pref_size.width()); - return bounds.Center(pref_size); + bounds.ClampToCenteredSize(pref_size); + return bounds; } gfx::Rect BalloonViewImpl::GetLabelBounds() const { @@ -280,7 +282,8 @@ gfx::Rect BalloonViewImpl::GetLabelBounds() const { bounds.Inset(kLabelLeftMargin, 0, bounds.width() - GetOptionsButtonBounds().x() + kLabelOptionsSpacing, 0); pref_size.set_width(bounds.width()); - return bounds.Center(pref_size); + bounds.ClampToCenteredSize(pref_size); + return bounds; } void BalloonViewImpl::Show(Balloon* balloon) { diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc index 67eae60..72ee51c 100644 --- a/chrome/browser/ui/views/toolbar_view.cc +++ b/chrome/browser/ui/views/toolbar_view.cc @@ -444,7 +444,8 @@ void ToolbarView::LayoutForSearch() { // Note that parent of |location_bar_container_| i.e. BrowserView can't clip // its children, else it loses the 3D shadows. gfx::Rect parent_rect = location_bar_container_->parent()->GetLocalBounds(); - gfx::Rect intersect_rect = parent_rect.Intersect(location_container_bounds); + gfx::Rect intersect_rect = parent_rect; + intersect_rect.Intersect(location_container_bounds); // If the two bounds don't intersect, set bounds of |location_bar_container_| // to 0. location_bar_container_->SetBoundsRect(intersect_rect); diff --git a/chrome/browser/ui/window_sizer/window_sizer.cc b/chrome/browser/ui/window_sizer/window_sizer.cc index 4cee759..f966981 100644 --- a/chrome/browser/ui/window_sizer/window_sizer.cc +++ b/chrome/browser/ui/window_sizer/window_sizer.cc @@ -218,7 +218,7 @@ void WindowSizer::DetermineWindowBoundsAndShowState( gfx::Rect work_area = monitor_info_provider_->GetMonitorWorkAreaMatching(*bounds); // Resize so that it fits. - *bounds = bounds->AdjustToFit(work_area); + bounds->AdjustToFit(work_area); } } diff --git a/chrome/browser/ui/window_sizer/window_sizer_common_unittest.cc b/chrome/browser/ui/window_sizer/window_sizer_common_unittest.cc index c460f9c..23b056b 100644 --- a/chrome/browser/ui/window_sizer/window_sizer_common_unittest.cc +++ b/chrome/browser/ui/window_sizer/window_sizer_common_unittest.cc @@ -44,7 +44,8 @@ size_t TestMonitorInfoProvider::GetMonitorIndexMatchingBounds( // Loop through all the monitors, finding the one that intersects the // largest area of the supplied match rect. for (size_t i = 0; i < work_areas_.size(); ++i) { - gfx::Rect overlap(match_rect.Intersect(work_areas_[i])); + gfx::Rect overlap = work_areas_[i]; + overlap.Intersect(match_rect); int area = overlap.width() * overlap.height(); if (area > max_area) { max_area = area; diff --git a/content/browser/renderer_host/accelerated_surface_container_mac.cc b/content/browser/renderer_host/accelerated_surface_container_mac.cc index 40115e7..5009b53 100644 --- a/content/browser/renderer_host/accelerated_surface_container_mac.cc +++ b/content/browser/renderer_host/accelerated_surface_container_mac.cc @@ -228,7 +228,7 @@ void AcceleratedSurfaceContainerMac::set_was_painted_to( uint64 surface_handle, const gfx::Rect& update_rect) { set_was_painted_to_common(surface_handle); - update_rect_ = update_rect_.Union(update_rect); + update_rect_.Union(update_rect); } void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() { diff --git a/content/browser/renderer_host/backing_store_aura.cc b/content/browser/renderer_host/backing_store_aura.cc index 4a7adaf..5d1149a 100644 --- a/content/browser/renderer_host/backing_store_aura.cc +++ b/content/browser/renderer_host/backing_store_aura.cc @@ -91,8 +91,9 @@ void BackingStoreAura::PaintToBackingStore( if (bitmap_rect.IsEmpty()) return; - gfx::Rect pixel_bitmap_rect = - gfx::ToEnclosedRect(bitmap_rect.Scale(scale_factor)); + gfx::RectF scaled_bitmap_rect = bitmap_rect; + scaled_bitmap_rect.Scale(scale_factor); + gfx::Rect pixel_bitmap_rect = gfx::ToEnclosedRect(scaled_bitmap_rect); const int width = pixel_bitmap_rect.width(); const int height = pixel_bitmap_rect.height(); @@ -112,16 +113,19 @@ void BackingStoreAura::PaintToBackingStore( sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); sk_bitmap.setPixels(dib->memory()); for (size_t i = 0; i < copy_rects.size(); i++) { - const gfx::Rect pixel_copy_rect = - gfx::ToEnclosingRect(copy_rects[i].Scale(scale_factor)); + gfx::RectF scaled_copy_rect = copy_rects[i]; + scaled_copy_rect.Scale(scale_factor); + const gfx::Rect pixel_copy_rect = gfx::ToEnclosingRect(scaled_copy_rect); int x = pixel_copy_rect.x() - pixel_bitmap_rect.x(); int y = pixel_copy_rect.y() - pixel_bitmap_rect.y(); SkIRect srcrect = SkIRect::MakeXYWH(x, y, pixel_copy_rect.width(), pixel_copy_rect.height()); + gfx::RectF scaled_copy_dst_rect = copy_rects[i]; + scaled_copy_dst_rect.Scale(device_scale_factor_); const gfx::Rect pixel_copy_dst_rect = - gfx::ToEnclosingRect(copy_rects[i].Scale(device_scale_factor_)); + gfx::ToEnclosingRect(scaled_copy_dst_rect); SkRect dstrect = SkRect::MakeXYWH( SkIntToScalar(pixel_copy_dst_rect.x()), SkIntToScalar(pixel_copy_dst_rect.y()), @@ -134,8 +138,9 @@ void BackingStoreAura::PaintToBackingStore( void BackingStoreAura::ScrollBackingStore(int dx, int dy, const gfx::Rect& clip_rect, const gfx::Size& view_size) { - gfx::Rect pixel_rect = - gfx::ToEnclosingRect(clip_rect.Scale(device_scale_factor_)); + gfx::RectF scaled_clip_rect = clip_rect; + scaled_clip_rect.Scale(device_scale_factor_); + gfx::Rect pixel_rect = gfx::ToEnclosingRect(scaled_clip_rect); int pixel_dx = dx * device_scale_factor_; int pixel_dy = dy * device_scale_factor_; diff --git a/content/browser/renderer_host/backing_store_mac.mm b/content/browser/renderer_host/backing_store_mac.mm index 0cb5a3b..d8513e4 100644 --- a/content/browser/renderer_host/backing_store_mac.mm +++ b/content/browser/renderer_host/backing_store_mac.mm @@ -101,8 +101,9 @@ void BackingStoreMac::PaintToBackingStore( gfx::Size pixel_size = gfx::ToFlooredSize( size().Scale(device_scale_factor_)); - gfx::Rect pixel_bitmap_rect = - ToFlooredRect(bitmap_rect.Scale(scale_factor)); + gfx::RectF scaled_bitmap_rect = bitmap_rect; + scaled_bitmap_rect.Scale(scale_factor); + gfx::Rect pixel_bitmap_rect = ToFlooredRect(scaled_bitmap_rect); size_t bitmap_byte_count = pixel_bitmap_rect.width() * pixel_bitmap_rect.height() * 4; @@ -121,8 +122,9 @@ void BackingStoreMac::PaintToBackingStore( for (size_t i = 0; i < copy_rects.size(); i++) { const gfx::Rect& copy_rect = copy_rects[i]; - gfx::Rect pixel_copy_rect = - ToFlooredRect(copy_rect.Scale(scale_factor)); + gfx::RectF scaled_copy_rect = copy_rect; + scaled_copy_rect.Scale(scale_factor); + gfx::Rect pixel_copy_rect = ToFlooredRect(scaled_copy_rect); // Only the subpixels given by copy_rect have pixels to copy. base::mac::ScopedCFTypeRef<CGImageRef> image( diff --git a/content/browser/renderer_host/backing_store_win.cc b/content/browser/renderer_host/backing_store_win.cc index 2c8d435..a16bd80 100644 --- a/content/browser/renderer_host/backing_store_win.cc +++ b/content/browser/renderer_host/backing_store_win.cc @@ -143,7 +143,8 @@ void BackingStoreWin::PaintToBackingStore( gfx::Rect view_rect(size()); for (size_t i = 0; i < copy_rects.size(); i++) { - gfx::Rect paint_rect = view_rect.Intersect(copy_rects[i]); + gfx::Rect paint_rect = view_rect; + paint_rect.Intersect(copy_rects[i]); CallStretchDIBits(hdc_, paint_rect.x(), paint_rect.y(), diff --git a/content/browser/renderer_host/gtk_window_utils.cc b/content/browser/renderer_host/gtk_window_utils.cc index de62f45..c47972a 100644 --- a/content/browser/renderer_host/gtk_window_utils.cc +++ b/content/browser/renderer_host/gtk_window_utils.cc @@ -63,7 +63,7 @@ void GetScreenInfoFromNativeWindow( gfx::Rect available_rect = results->rect; gfx::Rect work_area = GetWorkArea(GDK_WINDOW_XID(gdk_window)); if (!work_area.IsEmpty()) - available_rect = available_rect.Intersect(work_area); + available_rect.Intersect(work_area); results->availableRect = available_rect; } diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 4d497cf..6896797 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -437,7 +437,7 @@ void RenderWidgetHostViewAura::MovePluginWindows( gfx::Rect clip = moves[i].clip_rect; clip.Offset(moves[i].window_rect.origin()); clip.Offset(scroll_offset); - clip = clip.Intersect(view_port); + clip.Intersect(view_port); clip.Offset(-moves[i].window_rect.x(), -moves[i].window_rect.y()); clip.Offset(-scroll_offset.x(), -scroll_offset.y()); moves[i].clip_rect = clip; @@ -558,7 +558,8 @@ void RenderWidgetHostViewAura::DidUpdateBackingStore( SchedulePaintIfNotInClip(scroll_rect, clip_rect); for (size_t i = 0; i < copy_rects.size(); ++i) { - gfx::Rect rect = copy_rects[i].Subtract(scroll_rect); + gfx::Rect rect = copy_rects[i]; + rect.Subtract(scroll_rect); if (rect.IsEmpty()) continue; @@ -871,7 +872,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( // Damage may not have been DIP aligned, so inflate damage to compensate // for any round-off error. rect_to_paint.Inset(-1, -1); - rect_to_paint = rect_to_paint.Intersect(window_->bounds()); + rect_to_paint.Intersect(window_->bounds()); window_->SchedulePaintInRect(rect_to_paint); @@ -1168,7 +1169,8 @@ gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(const gfx::Rect& rect) { } gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() { - const gfx::Rect rect = selection_start_rect_.Union(selection_end_rect_); + gfx::Rect rect = selection_start_rect_; + rect.Union(selection_end_rect_); return ConvertRectToScreen(rect); } @@ -1796,7 +1798,8 @@ void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( const gfx::Rect& rect, const gfx::Rect& clip) { if (!clip.IsEmpty()) { - gfx::Rect to_paint = rect.Subtract(clip); + gfx::Rect to_paint = rect; + to_paint.Subtract(clip); if (!to_paint.IsEmpty()) window_->SchedulePaintInRect(to_paint); } else { diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index c68dfb1..dbe534d4 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -858,19 +858,20 @@ void RenderWidgetHostViewGtk::DidUpdateBackingStore( // be done using XCopyArea? Perhaps similar to // BackingStore::ScrollBackingStore? if (about_to_validate_and_paint_) - invalid_rect_ = invalid_rect_.Union(scroll_rect); + invalid_rect_.Union(scroll_rect); else Paint(scroll_rect); for (size_t i = 0; i < copy_rects.size(); ++i) { // Avoid double painting. NOTE: This is only relevant given the call to // Paint(scroll_rect) above. - gfx::Rect rect = copy_rects[i].Subtract(scroll_rect); + gfx::Rect rect = copy_rects[i]; + rect.Subtract(scroll_rect); if (rect.IsEmpty()) continue; if (about_to_validate_and_paint_) - invalid_rect_ = invalid_rect_.Union(rect); + invalid_rect_.Union(rect); else Paint(rect); } @@ -968,7 +969,9 @@ void RenderWidgetHostViewGtk::SelectionBoundsChanged( WebKit::WebTextDirection start_direction, const gfx::Rect& end_rect, WebKit::WebTextDirection end_direction) { - im_context_->UpdateCaretBounds(start_rect.Union(end_rect)); + gfx::Rect combined_rect = start_rect; + combined_rect.Union(end_rect); + im_context_->UpdateCaretBounds(combined_rect); } GdkEventButton* RenderWidgetHostViewGtk::GetLastMouseDown() { @@ -1175,7 +1178,7 @@ void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { about_to_validate_and_paint_ = false; gfx::Rect paint_rect = gfx::Rect(0, 0, kMaxWindowWidth, kMaxWindowHeight); - paint_rect = paint_rect.Intersect(invalid_rect_); + paint_rect.Intersect(invalid_rect_); if (backing_store) { // Only render the widget if it is attached to a window; there's a short diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index a8d05a8..69bb0cf 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -852,8 +852,9 @@ void RenderWidgetHostViewMac::CopyFromCompositingSurface( gfx::Rect src_gl_subrect = src_subrect; src_gl_subrect.set_y(GetViewBounds().height() - src_subrect.bottom()); - gfx::Rect src_pixel_gl_subrect = - gfx::ToEnclosingRect(src_gl_subrect.Scale(scale)); + gfx::RectF scaled_src_gl_subrect = src_gl_subrect; + scaled_src_gl_subrect.Scale(scale); + gfx::Rect src_pixel_gl_subrect = gfx::ToEnclosingRect(scaled_src_gl_subrect); compositing_iosurface_->CopyTo( src_pixel_gl_subrect, dst_pixel_size, @@ -1118,7 +1119,7 @@ gfx::Rect RenderWidgetHostViewMac::GetFirstRectForCompositionRange( *actual_range = ui::Range(range.start(), end_idx); gfx::Rect rect = composition_bounds_[range.start()]; for (size_t i = range.start() + 1; i < end_idx; ++i) { - rect = rect.Union(composition_bounds_[i]); + rect.Union(composition_bounds_[i]); } return rect; } @@ -2269,7 +2270,8 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { // smaller and the renderer hasn't yet repainted. int yOffset = NSHeight([self bounds]) - backingStore->size().height(); - gfx::Rect paintRect = bitmapRect.Intersect(damagedRect); + gfx::Rect paintRect = bitmapRect; + paintRect.Intersect(damagedRect); if (!paintRect.IsEmpty()) { // if we have a CGLayer, draw that into the window if (backingStore->cg_layer()) { diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index 508619a..03e7d6e 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -771,7 +771,8 @@ void RenderWidgetHostViewWin::SelectionBoundsChanged( text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD); // Only update caret position if the input method is enabled. if (is_enabled) { - caret_rect_ = start_rect.Union(end_rect); + caret_rect_ = start_rect; + caret_rect_.Union(end_rect); ime_input_.UpdateCaretRect(m_hWnd, caret_rect_); } } @@ -1357,7 +1358,8 @@ void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { } for (DWORD i = 0; i < region_data->rdh.nCount; ++i) { - gfx::Rect paint_rect = bitmap_rect.Intersect(gfx::Rect(region_rects[i])); + gfx::Rect paint_rect = bitmap_rect; + paint_rect.Intersect(gfx::Rect(region_rects[i])); if (!paint_rect.IsEmpty()) { BitBlt(paint_dc.m_hDC, paint_rect.x(), diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc index 8c1241d..dce01a2 100644 --- a/content/common/gpu/image_transport_surface.cc +++ b/content/common/gpu/image_transport_surface.cc @@ -32,7 +32,8 @@ void ImageTransportSurface::GetRegionsToCopy( const gfx::Rect& previous_damage_rect, const gfx::Rect& new_damage_rect, std::vector<gfx::Rect>* regions) { - gfx::Rect intersection = previous_damage_rect.Intersect(new_damage_rect); + gfx::Rect intersection = previous_damage_rect; + intersection.Intersect(new_damage_rect); if (intersection.IsEmpty()) { regions->push_back(previous_damage_rect); diff --git a/content/plugin/webplugin_proxy.cc b/content/plugin/webplugin_proxy.cc index 364deed..c74af5b 100644 --- a/content/plugin/webplugin_proxy.cc +++ b/content/plugin/webplugin_proxy.cc @@ -176,11 +176,12 @@ void WebPluginProxy::InvalidateRect(const gfx::Rect& rect) { // offscreen, so constrain invalidates to the plugin rect. gfx::Rect plugin_rect = delegate_->GetRect(); plugin_rect.set_origin(gfx::Point(0, 0)); - const gfx::Rect invalidate_rect(rect.Intersect(plugin_rect)); + plugin_rect.Intersect(rect); + const gfx::Rect invalidate_rect(plugin_rect); #else const gfx::Rect invalidate_rect(rect); #endif - damaged_rect_ = damaged_rect_.Union(invalidate_rect); + damaged_rect_.Union(invalidate_rect); // Ignore NPN_InvalidateRect calls with empty rects. Also don't send an // invalidate if it's outside the clipping region, since if we did it won't // lead to a paint and we'll be stuck waiting forever for a DidPaint response. diff --git a/content/renderer/browser_plugin/browser_plugin_backing_store.cc b/content/renderer/browser_plugin/browser_plugin_backing_store.cc index e29d5b3..131b0d0 100644 --- a/content/renderer/browser_plugin/browser_plugin_backing_store.cc +++ b/content/renderer/browser_plugin/browser_plugin_backing_store.cc @@ -37,8 +37,9 @@ void BrowserPluginBackingStore::PaintToBackingStore( if (bitmap_rect.IsEmpty()) return; - gfx::Rect pixel_bitmap_rect = - gfx::ToEnclosingRect(bitmap_rect.Scale(scale_factor_)); + gfx::RectF scaled_bitmap_rect = bitmap_rect; + scaled_bitmap_rect.Scale(scale_factor_); + gfx::Rect pixel_bitmap_rect = gfx::ToEnclosingRect(scaled_bitmap_rect); const int width = pixel_bitmap_rect.width(); const int height = pixel_bitmap_rect.height(); @@ -57,8 +58,9 @@ void BrowserPluginBackingStore::PaintToBackingStore( sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); sk_bitmap.setPixels(dib->memory()); for (size_t i = 0; i < copy_rects.size(); i++) { - const gfx::Rect& pixel_copy_rect = - gfx::ToEnclosingRect(copy_rects[i].Scale(scale_factor_)); + gfx::RectF scaled_copy_rect = copy_rects[i]; + scaled_copy_rect.Scale(scale_factor_); + const gfx::Rect& pixel_copy_rect = gfx::ToEnclosingRect(scaled_copy_rect); int x = pixel_copy_rect.x() - pixel_bitmap_rect.x(); int y = pixel_copy_rect.y() - pixel_bitmap_rect.y(); SkIRect srcrect = SkIRect::MakeXYWH(x, y, @@ -79,7 +81,9 @@ void BrowserPluginBackingStore::ScrollBackingStore( int dy, const gfx::Rect& clip_rect, const gfx::Size& view_size) { - gfx::Rect pixel_rect = gfx::ToEnclosingRect(clip_rect.Scale(scale_factor_)); + gfx::RectF scaled_clip_rect = clip_rect; + scaled_clip_rect.Scale(scale_factor_); + gfx::Rect pixel_rect = gfx::ToEnclosingRect(scaled_clip_rect); int pixel_dx = dx * scale_factor_; int pixel_dy = dy * scale_factor_; diff --git a/content/renderer/disambiguation_popup_helper.cc b/content/renderer/disambiguation_popup_helper.cc index 1a55414..1399518 100644 --- a/content/renderer/disambiguation_popup_helper.cc +++ b/content/renderer/disambiguation_popup_helper.cc @@ -92,9 +92,9 @@ float DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( gfx::Rect* zoom_rect) { *zoom_rect = tap_rect; for (size_t i = 0; i < target_rects.size(); i++) - *zoom_rect = zoom_rect->Union(gfx::Rect(target_rects[i])); + zoom_rect->Union(gfx::Rect(target_rects[i])); zoom_rect->Inset(-kDisambiguationPopupPadding, -kDisambiguationPopupPadding); - *zoom_rect = zoom_rect->Intersect(gfx::Rect(viewport_size)); + zoom_rect->Intersect(gfx::Rect(viewport_size)); float scale = FindOptimalScaleFactor(target_rects); *zoom_rect = CropZoomArea( diff --git a/content/renderer/paint_aggregator.cc b/content/renderer/paint_aggregator.cc index 809f99b..5ed988e 100644 --- a/content/renderer/paint_aggregator.cc +++ b/content/renderer/paint_aggregator.cc @@ -77,13 +77,14 @@ gfx::Rect PaintAggregator::PendingUpdate::GetScrollDamage() const { } // In case the scroll offset exceeds the width/height of the scroll rect - return scroll_rect.Intersect(damaged_rect); + damaged_rect.Intersect(scroll_rect); + return damaged_rect; } gfx::Rect PaintAggregator::PendingUpdate::GetPaintBounds() const { gfx::Rect bounds; for (size_t i = 0; i < paint_rects.size(); ++i) - bounds = bounds.Union(paint_rects[i]); + bounds.Union(paint_rects[i]); return bounds; } @@ -104,7 +105,7 @@ void PaintAggregator::PopPendingUpdate(PendingUpdate* update) { gfx::Rect union_rect; for (size_t i = 0; i < update_.paint_rects.size(); ++i) { paint_area += update_.paint_rects[i].size().GetArea(); - union_rect = union_rect.Union(update_.paint_rects[i]); + union_rect.Union(update_.paint_rects[i]); } int union_area = union_rect.size().GetArea(); if (float(paint_area) / float(union_area) > kMaxPaintRectsAreaRatio) @@ -122,7 +123,8 @@ void PaintAggregator::InvalidateRect(const gfx::Rect& rect) { return; if (rect.Intersects(existing_rect) || rect.SharesEdgeWith(existing_rect)) { // Re-invalidate in case the union intersects other paint rects. - gfx::Rect combined_rect = existing_rect.Union(rect); + gfx::Rect combined_rect = existing_rect; + combined_rect.Union(rect); update_.paint_rects.erase(update_.paint_rects.begin() + i); InvalidateRect(combined_rect); return; @@ -139,8 +141,9 @@ void PaintAggregator::InvalidateRect(const gfx::Rect& rect) { if (ShouldInvalidateScrollRect(rect)) { InvalidateScrollRect(); } else if (update_.scroll_rect.Contains(rect)) { - update_.paint_rects[update_.paint_rects.size() - 1] = - rect.Subtract(update_.GetScrollDamage()); + gfx::Rect paint_rect = rect; + paint_rect.Subtract(update_.GetScrollDamage()); + update_.paint_rects[update_.paint_rects.size() - 1] = paint_rect; if (update_.paint_rects[update_.paint_rects.size() - 1].IsEmpty()) update_.paint_rects.erase(update_.paint_rects.end() - 1); } @@ -215,10 +218,11 @@ gfx::Rect PaintAggregator::ScrollPaintRect(const gfx::Rect& paint_rect, gfx::Rect result = paint_rect; result.Offset(dx, dy); - result = update_.scroll_rect.Intersect(result); + result.Intersect(update_.scroll_rect); // Subtract out the scroll damage rect to avoid redundant painting. - return result.Subtract(update_.GetScrollDamage()); + result.Subtract(update_.GetScrollDamage()); + return result; } bool PaintAggregator::ShouldInvalidateScrollRect(const gfx::Rect& rect) const { @@ -273,9 +277,9 @@ void PaintAggregator::CombinePaintRects() { for (size_t i = 0; i < update_.paint_rects.size(); ++i) { const gfx::Rect& existing_rect = update_.paint_rects[i]; if (update_.scroll_rect.Contains(existing_rect)) { - inner = inner.Union(existing_rect); + inner.Union(existing_rect); } else { - outer = outer.Union(existing_rect); + outer.Union(existing_rect); } } update_.paint_rects.clear(); diff --git a/content/renderer/paint_aggregator_unittest.cc b/content/renderer/paint_aggregator_unittest.cc index a651f9e..7261822 100644 --- a/content/renderer/paint_aggregator_unittest.cc +++ b/content/renderer/paint_aggregator_unittest.cc @@ -37,7 +37,8 @@ TEST(PaintAggregator, DoubleDisjointInvalidation) { greg.InvalidateRect(r1); greg.InvalidateRect(r2); - gfx::Rect expected_bounds = r1.Union(r2); + gfx::Rect expected_bounds = r1; + expected_bounds.Union(r2); EXPECT_TRUE(greg.HasPendingUpdate()); PaintAggregator::PendingUpdate update; @@ -61,7 +62,8 @@ TEST(PaintAggregator, DisjointInvalidationsCombined) { greg.InvalidateRect(r1); greg.InvalidateRect(r2); - gfx::Rect expected_bounds = r1.Union(r2); + gfx::Rect expected_bounds = r1; + expected_bounds.Union(r2); EXPECT_TRUE(greg.HasPendingUpdate()); PaintAggregator::PendingUpdate update; @@ -277,7 +279,8 @@ TEST(PaintAggregator, OverlappingPaintBeforeScroll) { gfx::Rect scroll_rect(0, 0, 10, 10); greg.ScrollRect(2, 0, scroll_rect); - gfx::Rect expected_paint_rect = scroll_rect.Union(paint_rect); + gfx::Rect expected_paint_rect = scroll_rect; + expected_paint_rect.Union(paint_rect); EXPECT_TRUE(greg.HasPendingUpdate()); PaintAggregator::PendingUpdate update; @@ -298,7 +301,8 @@ TEST(PaintAggregator, OverlappingPaintAfterScroll) { gfx::Rect paint_rect(4, 4, 10, 2); greg.InvalidateRect(paint_rect); - gfx::Rect expected_paint_rect = scroll_rect.Union(paint_rect); + gfx::Rect expected_paint_rect = scroll_rect; + expected_paint_rect.Union(paint_rect); EXPECT_TRUE(greg.HasPendingUpdate()); PaintAggregator::PendingUpdate update; diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index c7308d1..9c3872e 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -373,11 +373,13 @@ void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { if (resizer_rect_ != resizer_rect) { gfx::Rect view_rect(size_); - gfx::Rect old_damage_rect = view_rect.Intersect(resizer_rect_); + gfx::Rect old_damage_rect = view_rect; + old_damage_rect.Intersect(resizer_rect_); if (!old_damage_rect.IsEmpty()) paint_aggregator_.InvalidateRect(old_damage_rect); - gfx::Rect new_damage_rect = view_rect.Intersect(resizer_rect); + gfx::Rect new_damage_rect = view_rect; + new_damage_rect.Intersect(resizer_rect); if (!new_damage_rect.IsEmpty()) paint_aggregator_.InvalidateRect(new_damage_rect); @@ -935,7 +937,8 @@ void RenderWidget::DoDeferredUpdate() { paint_aggregator_.PopPendingUpdate(&update); gfx::Rect scroll_damage = update.GetScrollDamage(); - gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); + gfx::Rect bounds = update.GetPaintBounds(); + bounds.Union(scroll_damage); // Notify derived classes that we're about to initiate a paint. WillInitiatePaint(); @@ -974,15 +977,16 @@ void RenderWidget::DoDeferredUpdate() { &optimized_copy_rect, &dib_scale_factor)) { // Only update the part of the plugin that actually changed. - optimized_copy_rect = optimized_copy_rect.Intersect(bounds); + optimized_copy_rect.Intersect(bounds); pending_update_params_->bitmap = dib->id(); pending_update_params_->bitmap_rect = optimized_copy_location; pending_update_params_->copy_rects.push_back(optimized_copy_rect); pending_update_params_->scale_factor = dib_scale_factor; } else if (!is_accelerated_compositing_active_) { // Compute a buffer for painting and cache it. - gfx::Rect pixel_bounds = - gfx::ToEnclosingRect(bounds.Scale(device_scale_factor_)); + gfx::RectF scaled_bounds = bounds; + scaled_bounds.Scale(device_scale_factor_); + gfx::Rect pixel_bounds = gfx::ToEnclosingRect(scaled_bounds); scoped_ptr<skia::PlatformCanvas> canvas( RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, pixel_bounds)); @@ -1060,7 +1064,8 @@ void RenderWidget::DoDeferredUpdate() { void RenderWidget::didInvalidateRect(const WebRect& rect) { // The invalidated rect might be outside the bounds of the view. gfx::Rect view_rect(size_); - gfx::Rect damaged_rect = view_rect.Intersect(rect); + gfx::Rect damaged_rect = view_rect; + damaged_rect.Intersect(rect); if (damaged_rect.IsEmpty()) return; @@ -1100,7 +1105,8 @@ void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { // The scrolled rect might be outside the bounds of the view. gfx::Rect view_rect(size_); - gfx::Rect damaged_rect = view_rect.Intersect(clip_rect); + gfx::Rect damaged_rect = view_rect; + damaged_rect.Intersect(clip_rect); if (damaged_rect.IsEmpty()) return; diff --git a/content/renderer/webplugin_delegate_proxy.cc b/content/renderer/webplugin_delegate_proxy.cc index 8c23272..31365aa 100644 --- a/content/renderer/webplugin_delegate_proxy.cc +++ b/content/renderer/webplugin_delegate_proxy.cc @@ -739,7 +739,8 @@ void WebPluginDelegateProxy::Paint(WebKit::WebCanvas* canvas, const gfx::Rect& damaged_rect) { // Limit the damaged rectangle to whatever is contained inside the plugin // rectangle, as that's the rectangle that we'll actually draw. - gfx::Rect rect = damaged_rect.Intersect(plugin_rect_); + gfx::Rect rect = damaged_rect; + rect.Intersect(plugin_rect_); // If the plugin is no longer connected (channel crashed) draw a crashed // plugin bitmap @@ -853,7 +854,8 @@ bool WebPluginDelegateProxy::BackgroundChanged( // intersect their rects first. gfx::Rect bitmap_rect(static_cast<int>(-xf.eDx), static_cast<int>(-xf.eDy), bitmap.bmWidth, bitmap.bmHeight); - gfx::Rect check_rect = rect.Intersect(bitmap_rect); + gfx::Rect check_rect = rect; + check_rect.Intersect(bitmap_rect); int row_byte_size = check_rect.width() * (bitmap.bmBitsPixel / 8); for (int y = check_rect.y(); y < check_rect.bottom(); y++) { char* hdc_row_start = static_cast<char*>(bitmap.bmBits) + @@ -898,7 +900,8 @@ bool WebPluginDelegateProxy::BackgroundChanged( #endif // According to comments in the Windows code, the damage rect that we're given // may project outside the image, so intersect their rects. - gfx::Rect content_rect = rect.Intersect(full_content_rect); + gfx::Rect content_rect = rect; + content_rect.Intersect(full_content_rect); #if defined(OS_MACOSX) const unsigned char* page_bytes = static_cast<const unsigned char*>( @@ -1188,7 +1191,8 @@ void WebPluginDelegateProxy::OnInvalidateRect(const gfx::Rect& rect) { // Clip the invalidation rect to the plugin bounds; the plugin may have been // resized since the invalidate message was sent. - const gfx::Rect clipped_rect(rect.Intersect(gfx::Rect(plugin_rect_.size()))); + gfx::Rect clipped_rect = rect; + clipped_rect.Intersect(gfx::Rect(plugin_rect_.size())); invalidate_pending_ = true; // The plugin is blocked on the renderer because the invalidate message it has @@ -1309,7 +1313,7 @@ void WebPluginDelegateProxy::UpdateFrontBuffer( // Plugin has just painted "rect" into the back-buffer, so the front-buffer // no longer holds the latest content for that rectangle. - front_buffer_diff_ = front_buffer_diff_.Subtract(rect); + front_buffer_diff_.Subtract(rect); if (allow_buffer_flipping && front_buffer_diff_.IsEmpty()) { // Back-buffer contains the latest content for all areas; simply flip // the buffers. @@ -1324,7 +1328,7 @@ void WebPluginDelegateProxy::UpdateFrontBuffer( // allowed); fall back to copying the data. CopyFromBackBufferToFrontBuffer(rect); } - transport_store_painted_ = transport_store_painted_.Union(rect); + transport_store_painted_.Union(rect); } void WebPluginDelegateProxy::OnHandleURLRequest( diff --git a/ui/app_list/apps_grid_view.cc b/ui/app_list/apps_grid_view.cc index bb445d2..574938c 100644 --- a/ui/app_list/apps_grid_view.cc +++ b/ui/app_list/apps_grid_view.cc @@ -404,7 +404,7 @@ void AppsGridView::CalculateIdealBounds() { gfx::Rect grid_rect(gfx::Size(tile_size.width() * cols_, tile_size.height() * rows_per_page_)); - grid_rect = grid_rect.Intersect(rect); + grid_rect.Intersect(rect); // Page width including padding pixels. A tile.x + page_width means the same // tile slot in the next page. diff --git a/ui/app_list/page_switcher.cc b/ui/app_list/page_switcher.cc index b6a3b7a..ba98671 100644 --- a/ui/app_list/page_switcher.cc +++ b/ui/app_list/page_switcher.cc @@ -67,8 +67,8 @@ class PageSwitcherButton : public views::CustomButton { private: // Paints a button that has two rounded corner at bottom. void PaintButton(gfx::Canvas* canvas, SkColor base_color) { - gfx::Rect rect(GetContentsBounds().Center( - gfx::Size(button_width_, kButtonHeight))); + gfx::Rect rect(GetContentsBounds()); + rect.ClampToCenteredSize(gfx::Size(button_width_, kButtonHeight)); SkPath path; path.addRoundRect(gfx::RectToSkRect(rect), @@ -189,7 +189,8 @@ void PageSwitcher::Layout() { rect.y(), buttons_size.width(), rect.height()); - buttons_->SetBoundsRect(rect.Intersect(buttons_bounds)); + rect.Intersect(buttons_bounds); + buttons_->SetBoundsRect(rect); } void PageSwitcher::CalculateButtonWidthAndSpacing(int contents_width) { diff --git a/ui/app_list/search_result_view.cc b/ui/app_list/search_result_view.cc index 321b3a5b..7e4559d 100644 --- a/ui/app_list/search_result_view.cc +++ b/ui/app_list/search_result_view.cc @@ -168,7 +168,8 @@ void SearchResultView::Layout() { gfx::Rect icon_bounds(rect); icon_bounds.set_width(kIconViewWidth); icon_bounds.Inset(kIconPadding, (rect.height() - kIconDimension) / 2); - icon_->SetBoundsRect(icon_bounds.Intersect(rect)); + icon_bounds.Intersect(rect); + icon_->SetBoundsRect(icon_bounds); size_t num_buttons = action_buttons_.size(); for (size_t i = 0; i < num_buttons; ++i) { @@ -199,7 +200,8 @@ void SearchResultView::OnPaint(gfx::Canvas* canvas) { canvas->FillRect(content_rect, kHoverAndPushedColor); } - gfx::Rect border_bottom = rect.Subtract(content_rect); + gfx::Rect border_bottom(rect); + border_bottom.Subtract(content_rect); canvas->FillRect(border_bottom, selected ? kSelectedBorderColor : kBorderColor); @@ -231,7 +233,9 @@ void SearchResultView::OnPaint(gfx::Canvas* canvas) { } else if (title_text_.get()) { gfx::Size title_size(text_bounds.width(), title_text_->GetStringSize().height()); - title_text_->SetDisplayRect(text_bounds.Center(title_size)); + gfx::Rect centered_title_rect(text_bounds); + centered_title_rect.ClampToCenteredSize(title_size); + title_text_->SetDisplayRect(centered_title_rect); title_text_->Draw(canvas); } } diff --git a/ui/base/gestures/gesture_point.cc b/ui/base/gestures/gesture_point.cc index 1447a43..31d9e91 100644 --- a/ui/base/gestures/gesture_point.cc +++ b/ui/base/gestures/gesture_point.cc @@ -191,7 +191,7 @@ void GesturePoint::UpdateEnclosingRectangle(const TouchEvent& event) { radius * 2, radius * 2); if (IsInClickWindow(event)) - enclosing_rect_ = enclosing_rect_.Union(rect); + enclosing_rect_.Union(rect); else enclosing_rect_ = rect; } diff --git a/ui/base/native_theme/native_theme_base.cc b/ui/base/native_theme/native_theme_base.cc index 96c4a3c..df9b7bf 100644 --- a/ui/base/native_theme/native_theme_base.cc +++ b/ui/base/native_theme/native_theme_base.cc @@ -504,7 +504,8 @@ void NativeThemeBase::PaintCheckbox(SkCanvas* canvas, rb.GetImageSkiaNamed(IDR_CHECKBOX_OFF); } - gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height())); + gfx::Rect bounds = rect; + bounds.ClampToCenteredSize(gfx::Size(image->width(), image->height())); DrawImageInt(canvas, *image, 0, 0, image->width(), image->height(), bounds.x(), bounds.y(), bounds.width(), bounds.height()); } @@ -655,7 +656,8 @@ void NativeThemeBase::PaintRadio(SkCanvas* canvas, rb.GetImageSkiaNamed(IDR_RADIO_OFF); } - gfx::Rect bounds = rect.Center(gfx::Size(image->width(), image->height())); + gfx::Rect bounds = rect; + bounds.ClampToCenteredSize(gfx::Size(image->width(), image->height())); DrawImageInt(canvas, *image, 0, 0, image->width(), image->height(), bounds.x(), bounds.y(), bounds.width(), bounds.height()); } diff --git a/ui/base/win/hwnd_util.cc b/ui/base/win/hwnd_util.cc index 60efa0c..b6fc171 100644 --- a/ui/base/win/hwnd_util.cc +++ b/ui/base/win/hwnd_util.cc @@ -25,7 +25,8 @@ void AdjustWindowToFit(HWND hwnd, const RECT& bounds, bool fit_to_monitor) { GetMonitorInfo(hmon, &mi); gfx::Rect window_rect(bounds); gfx::Rect monitor_rect(mi.rcWork); - gfx::Rect new_window_rect = window_rect.AdjustToFit(monitor_rect); + gfx::Rect new_window_rect = window_rect; + new_window_rect.AdjustToFit(monitor_rect); if (new_window_rect != window_rect) { // Window doesn't fit on monitor, move and possibly resize. SetWindowPos(hwnd, 0, new_window_rect.x(), new_window_rect.y(), diff --git a/ui/gfx/blit.cc b/ui/gfx/blit.cc index 25d0ebe..0c6e6b6 100644 --- a/ui/gfx/blit.cc +++ b/ui/gfx/blit.cc @@ -152,13 +152,13 @@ void ScrollCanvas(SkCanvas* canvas, SkAutoLockPixels lock(bitmap); // We expect all coords to be inside the canvas, so clip here. - gfx::Rect clip = in_clip.Intersect( - gfx::Rect(0, 0, bitmap.width(), bitmap.height())); + gfx::Rect clip = in_clip; + clip.Intersect(gfx::Rect(0, 0, bitmap.width(), bitmap.height())); // Compute the set of pixels we'll actually end up painting. gfx::Rect dest_rect = clip; dest_rect.Offset(amount); - dest_rect = dest_rect.Intersect(clip); + dest_rect.Intersect(clip); if (dest_rect.size() == gfx::Size()) return; // Nothing to do. diff --git a/ui/gfx/image/image_skia_operations.cc b/ui/gfx/image/image_skia_operations.cc index 8afaf87..0dcc4d8 100644 --- a/ui/gfx/image/image_skia_operations.cc +++ b/ui/gfx/image/image_skia_operations.cc @@ -288,9 +288,11 @@ class ExtractSubsetImageSource: public gfx::ImageSkiaSource { // gfx::ImageSkiaSource overrides: virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE { ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor); + gfx::RectF scaled_subset_bounds = subset_bounds_; + scaled_subset_bounds.Scale( + ui::GetScaleFactorScale(image_rep.scale_factor())); SkIRect subset_bounds_in_pixel = RectToSkIRect( - ToEnclosingRect(subset_bounds_.Scale( - ui::GetScaleFactorScale(image_rep.scale_factor())))); + ToEnclosingRect(scaled_subset_bounds)); SkBitmap dst; bool success = image_rep.sk_bitmap().extractSubset(&dst, subset_bounds_in_pixel); @@ -430,7 +432,8 @@ ImageSkia ImageSkiaOperations::CreateButtonBackground(SkColor color, // static ImageSkia ImageSkiaOperations::ExtractSubset(const ImageSkia& image, const Rect& subset_bounds) { - gfx::Rect clipped_bounds = subset_bounds.Intersect(gfx::Rect(image.size())); + gfx::Rect clipped_bounds = subset_bounds; + clipped_bounds.Intersect(gfx::Rect(image.size())); if (image.isNull() || clipped_bounds.IsEmpty()) { return ImageSkia(); } diff --git a/ui/gfx/rect.h b/ui/gfx/rect.h index 7d73f4d8..2eab239 100644 --- a/ui/gfx/rect.h +++ b/ui/gfx/rect.h @@ -64,15 +64,6 @@ class UI_EXPORT Rect : public RectBase<Rect, Point, Size, Insets, int> { return RectF(origin().x(), origin().y(), size().width(), size().height()); } - RectF Scale(float scale) const WARN_UNUSED_RESULT { - return Scale(scale, scale); - } - - RectF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT { - RectF original = *this; - return original.Scale(x_scale, y_scale); - } - std::string ToString() const; }; diff --git a/ui/gfx/rect_base.h b/ui/gfx/rect_base.h index 08c9121..a9ddda4 100644 --- a/ui/gfx/rect_base.h +++ b/ui/gfx/rect_base.h @@ -100,31 +100,31 @@ class UI_EXPORT RectBase { bool Intersects(const Class& rect) const; // Computes the intersection of this rectangle with the given rectangle. - Class Intersect(const Class& rect) const WARN_UNUSED_RESULT; + void Intersect(const Class& rect); // Computes the union of this rectangle with the given rectangle. The union // is the smallest rectangle containing both rectangles. - Class Union(const Class& rect) const WARN_UNUSED_RESULT; + void Union(const Class& rect); // Computes the rectangle resulting from subtracting |rect| from |this|. If // |rect| does not intersect completely in either the x- or y-direction, then - // |*this| is returned. If |rect| contains |this|, then an empty Rect is - // returned. - Class Subtract(const Class& rect) const WARN_UNUSED_RESULT; + // |*this| does not change. If |rect| contains |this|, then an empty Rect is + // the result. + void Subtract(const Class& rect); // Fits as much of the receiving rectangle into the supplied rectangle as - // possible, returning the result. For example, if the receiver had + // possible, becoming the result. For example, if the receiver had // a x-location of 2 and a width of 4, and the supplied rectangle had // an x-location of 0 with a width of 5, the returned rectangle would have // an x-location of 1 with a width of 4. - Class AdjustToFit(const Class& rect) const WARN_UNUSED_RESULT; + void AdjustToFit(const Class& rect); // Returns the center of this rectangle. PointClass CenterPoint() const; - // Return a rectangle that has the same center point but with a size capped + // Becomes a rectangle that has the same center point but with a size capped // at given |size|. - Class Center(const SizeClass& size) const WARN_UNUSED_RESULT; + void ClampToCenteredSize(const SizeClass& size); // Splits |this| in two halves, |left_half| and |right_half|. void SplitVertically(Class* left_half, Class* right_half) const; diff --git a/ui/gfx/rect_base_impl.h b/ui/gfx/rect_base_impl.h index ab71f42..291929d 100644 --- a/ui/gfx/rect_base_impl.h +++ b/ui/gfx/rect_base_impl.h @@ -165,8 +165,13 @@ template<typename Class, typename SizeClass, typename InsetsClass, typename Type> -Class RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Intersect( - const Class& rect) const { +void RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Intersect( + const Class& rect) { + if (IsEmpty() || rect.IsEmpty()) { + SetRect(0, 0, 0, 0); + return; + } + Type rx = std::max(x(), rect.x()); Type ry = std::max(y(), rect.y()); Type rr = std::min(right(), rect.right()); @@ -175,7 +180,7 @@ Class RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Intersect( if (rx >= rr || ry >= rb) rx = ry = rr = rb = 0; // non-intersecting - return Class(rx, ry, rr - rx, rb - ry); + SetRect(rx, ry, rr - rx, rb - ry); } template<typename Class, @@ -183,20 +188,21 @@ template<typename Class, typename SizeClass, typename InsetsClass, typename Type> -Class RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Union( - const Class& rect) const { - // special case empty rects... - if (IsEmpty()) - return rect; +void RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Union( + const Class& rect) { + if (IsEmpty()) { + *this = rect; + return; + } if (rect.IsEmpty()) - return *static_cast<const Class*>(this); + return; Type rx = std::min(x(), rect.x()); Type ry = std::min(y(), rect.y()); Type rr = std::max(right(), rect.right()); Type rb = std::max(bottom(), rect.bottom()); - return Class(rx, ry, rr - rx, rb - ry); + SetRect(rx, ry, rr - rx, rb - ry); } template<typename Class, @@ -204,13 +210,14 @@ template<typename Class, typename SizeClass, typename InsetsClass, typename Type> -Class RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Subtract( - const Class& rect) const { - // boundary cases: +void RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Subtract( + const Class& rect) { if (!Intersects(rect)) - return *static_cast<const Class*>(this); - if (rect.Contains(*static_cast<const Class*>(this))) - return Class(); + return; + if (rect.Contains(*static_cast<const Class*>(this))) { + SetRect(0, 0, 0, 0); + return; + } Type rx = x(); Type ry = y(); @@ -232,7 +239,7 @@ Class RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Subtract( rb = rect.y(); } } - return Class(rx, ry, rr - rx, rb - ry); + SetRect(rx, ry, rr - rx, rb - ry); } template<typename Class, @@ -240,15 +247,15 @@ template<typename Class, typename SizeClass, typename InsetsClass, typename Type> -Class RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::AdjustToFit( - const Class& rect) const { +void RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::AdjustToFit( + const Class& rect) { Type new_x = x(); Type new_y = y(); Type new_width = width(); Type new_height = height(); AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width); AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height); - return Class(new_x, new_y, new_width, new_height); + SetRect(new_x, new_y, new_width, new_height); } template<typename Class, @@ -266,13 +273,13 @@ template<typename Class, typename SizeClass, typename InsetsClass, typename Type> -Class RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Center( - const SizeClass& size) const { +void RectBase<Class, PointClass, SizeClass, InsetsClass, Type>:: + ClampToCenteredSize(const SizeClass& size) { Type new_width = std::min(width(), size.width()); Type new_height = std::min(height(), size.height()); Type new_x = x() + (width() - new_width) / 2; Type new_y = y() + (height() - new_height) / 2; - return Class(new_x, new_y, new_width, new_height); + SetRect(new_x, new_y, new_width, new_height); } template<typename Class, diff --git a/ui/gfx/rect_f.h b/ui/gfx/rect_f.h index fbdeb4e..4ee1098 100644 --- a/ui/gfx/rect_f.h +++ b/ui/gfx/rect_f.h @@ -27,14 +27,15 @@ class UI_EXPORT RectF : public RectBase<RectF, PointF, SizeF, InsetsF, float> { ~RectF(); /// Scales the rectangle by |scale|. - RectF Scale(float scale) const WARN_UNUSED_RESULT { - return Scale(scale, scale); + void Scale(float scale) { + Scale(scale, scale); } - RectF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT { + void Scale(float x_scale, float y_scale) { SizeF newSize = size().Scale(x_scale, y_scale); newSize.ClampToNonNegative(); - return RectF(origin().Scale(x_scale, y_scale), newSize); + set_origin(origin().Scale(x_scale, y_scale)); + set_size(newSize); } std::string ToString() const; diff --git a/ui/gfx/rect_unittest.cc b/ui/gfx/rect_unittest.cc index 6697e08..bc73bf3 100644 --- a/ui/gfx/rect_unittest.cc +++ b/ui/gfx/rect_unittest.cc @@ -107,7 +107,8 @@ TEST(RectTest, Intersect) { gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - gfx::Rect ir = r1.Intersect(r2); + gfx::Rect ir = r1; + ir.Intersect(r2); EXPECT_EQ(r3.x(), ir.x()); EXPECT_EQ(r3.y(), ir.y()); EXPECT_EQ(r3.width(), ir.width()); @@ -156,7 +157,8 @@ TEST(RectTest, Union) { gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - gfx::Rect u = r1.Union(r2); + gfx::Rect u = r1; + u.Union(r2); EXPECT_EQ(r3.x(), u.x()); EXPECT_EQ(r3.y(), u.y()); EXPECT_EQ(r3.width(), u.width()); @@ -208,7 +210,8 @@ TEST(RectTest, AdjustToFit) { gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); gfx::Rect r3(tests[i].x3, tests[i].y3, tests[i].w3, tests[i].h3); - gfx::Rect u(r1.AdjustToFit(r2)); + gfx::Rect u = r1; + u.AdjustToFit(r2); EXPECT_EQ(r3.x(), u.x()); EXPECT_EQ(r3.y(), u.y()); EXPECT_EQ(r3.width(), u.width()); @@ -217,59 +220,52 @@ TEST(RectTest, AdjustToFit) { } TEST(RectTest, Subtract) { + gfx::Rect result; + // Matching - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(10, 10, 20, 20)) == - gfx::Rect(0, 0, 0, 0)); + result = gfx::Rect(10, 10, 20, 20); + result.Subtract(gfx::Rect(10, 10, 20, 20)); + EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), result.ToString()); // Contains - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 5, 30, 30)) == - gfx::Rect(0, 0, 0, 0)); + result = gfx::Rect(10, 10, 20, 20); + result.Subtract(gfx::Rect(5, 5, 30, 30)); + EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), result.ToString()); // No intersection - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(30, 30, 20, 20)) == - gfx::Rect(10, 10, 20, 20)); + result = gfx::Rect(10, 10, 20, 20); + result.Subtract(gfx::Rect(30, 30, 30, 30)); + EXPECT_EQ(gfx::Rect(10, 10, 20, 20).ToString(), result.ToString()); // Not a complete intersection in either direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(15, 15, 20, 20)) == - gfx::Rect(10, 10, 20, 20)); + result = gfx::Rect(10, 10, 20, 20); + result.Subtract(gfx::Rect(15, 15, 20, 20)); + EXPECT_EQ(gfx::Rect(10, 10, 20, 20).ToString(), result.ToString()); // Complete intersection in the x-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(10, 15, 20, 20)) == - gfx::Rect(10, 10, 20, 5)); + result = gfx::Rect(10, 10, 20, 20); + result.Subtract(gfx::Rect(10, 15, 20, 20)); + EXPECT_EQ(gfx::Rect(10, 10, 20, 5).ToString(), result.ToString()); // Complete intersection in the x-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 15, 30, 20)) == - gfx::Rect(10, 10, 20, 5)); + result = gfx::Rect(10, 10, 20, 20); + result.Subtract(gfx::Rect(5, 15, 30, 20)); + EXPECT_EQ(gfx::Rect(10, 10, 20, 5).ToString(), result.ToString()); // Complete intersection in the x-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 5, 30, 20)) == - gfx::Rect(10, 25, 20, 5)); + result = gfx::Rect(10, 10, 20, 20); + result.Subtract(gfx::Rect(5, 5, 30, 20)); + EXPECT_EQ(gfx::Rect(10, 25, 20, 5).ToString(), result.ToString()); // Complete intersection in the y-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(10, 10, 10, 30)) == - gfx::Rect(20, 10, 10, 20)); + result = gfx::Rect(10, 10, 20, 20); + result.Subtract(gfx::Rect(10, 10, 10, 30)); + EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), result.ToString()); // Complete intersection in the y-direction - EXPECT_TRUE( - gfx::Rect(10, 10, 20, 20).Subtract( - gfx::Rect(5, 5, 20, 30)) == - gfx::Rect(25, 10, 5, 20)); + result = gfx::Rect(10, 10, 20, 20); + result.Subtract(gfx::Rect(5, 5, 20, 30)); + EXPECT_EQ(gfx::Rect(25, 10, 5, 20).ToString(), result.ToString()); } TEST(RectTest, IsEmpty) { @@ -450,7 +446,8 @@ TEST(RectTest, ScaleRect) { gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); gfx::RectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); - gfx::RectF scaled = r1.Scale(tests[i].scale); + gfx::RectF scaled = r1; + scaled.Scale(tests[i].scale); EXPECT_FLOAT_AND_NAN_EQ(r2.x(), scaled.x()); EXPECT_FLOAT_AND_NAN_EQ(r2.y(), scaled.y()); EXPECT_FLOAT_AND_NAN_EQ(r2.width(), scaled.width()); @@ -572,7 +569,8 @@ TEST(RectTest, ToRectF) { gfx::Rect a(10, 20, 30, 40); gfx::RectF b(10, 20, 30, 40); - gfx::RectF intersect = b.Intersect(a); + gfx::RectF intersect = b; + intersect.Intersect(a); EXPECT_EQ(b.ToString(), intersect.ToString()); EXPECT_EQ(a, b); diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc index 0b72ab6..1e73d13 100644 --- a/ui/gfx/render_text_win.cc +++ b/ui/gfx/render_text_win.cc @@ -381,7 +381,7 @@ std::vector<Rect> RenderTextWin::GetSubstringBounds(const ui::Range& range) { rect.set_origin(ToViewPoint(rect.origin())); // Union this with the last rect if they're adjacent. if (!bounds.empty() && rect.SharesEdgeWith(bounds.back())) { - rect = rect.Union(bounds.back()); + rect.Union(bounds.back()); bounds.pop_back(); } bounds.push_back(rect); diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc index 30908ce4..f3c3b1b 100644 --- a/ui/gfx/screen_gtk.cc +++ b/ui/gfx/screen_gtk.cc @@ -157,7 +157,8 @@ class ScreenGtk : public gfx::Screen { gfx::Display display(0, bounds); gfx::Rect rect; if (GetScreenWorkArea(&rect)) { - display.set_work_area(rect.Intersect(bounds)); + bounds.Intersect(rect); + display.set_work_area(bounds); } else { // Return the best we've got. display.set_work_area(bounds); diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm index 986f2cd..d3301f1 100644 --- a/ui/gfx/screen_mac.mm +++ b/ui/gfx/screen_mac.mm @@ -39,7 +39,8 @@ NSScreen* GetMatchingScreen(const gfx::Rect& match_rect) { for (NSScreen* screen in [NSScreen screens]) { gfx::Rect monitor_area = ConvertCoordinateSystem([screen frame]); - gfx::Rect intersection = monitor_area.Intersect(match_rect); + gfx::Rect intersection = monitor_area; + intersection.Intersect(match_rect); int area = intersection.width() * intersection.height(); if (area > max_area) { max_area = area; diff --git a/ui/views/animation/bounds_animator.cc b/ui/views/animation/bounds_animator.cc index 2c3fd05..037b9d6 100644 --- a/ui/views/animation/bounds_animator.cc +++ b/ui/views/animation/bounds_animator.cc @@ -235,14 +235,12 @@ void BoundsAnimator::AnimationProgressed(const Animation* animation) { gfx::Rect new_bounds = animation->CurrentValueBetween(data.start_bounds, data.target_bounds); if (new_bounds != view->bounds()) { - gfx::Rect total_bounds = new_bounds.Union(view->bounds()); + gfx::Rect total_bounds = view->bounds(); + total_bounds.Union(new_bounds); // Build up the region to repaint in repaint_bounds_. We'll do the repaint // when all animations complete (in AnimationContainerProgressed). - if (repaint_bounds_.IsEmpty()) - repaint_bounds_ = total_bounds; - else - repaint_bounds_ = repaint_bounds_.Union(total_bounds); + repaint_bounds_.Union(total_bounds); view->SetBoundsRect(new_bounds); } diff --git a/ui/views/animation/bounds_animator_unittest.cc b/ui/views/animation/bounds_animator_unittest.cc index 93b13b5..2dbfc48 100644 --- a/ui/views/animation/bounds_animator_unittest.cc +++ b/ui/views/animation/bounds_animator_unittest.cc @@ -76,7 +76,7 @@ class TestView : public View { if (dirty_rect_.IsEmpty()) dirty_rect_ = r; else - dirty_rect_ = dirty_rect_.Union(r); + dirty_rect_.Union(r); } const gfx::Rect& dirty_rect() const { return dirty_rect_; } @@ -129,7 +129,8 @@ TEST_F(BoundsAnimatorTest, AnimateViewTo) { // The parent should have been told to repaint as the animation progressed. // The resulting rect is the union of the original and target bounds. - EXPECT_EQ(target_bounds.Union(initial_bounds), parent()->dirty_rect()); + target_bounds.Union(initial_bounds); + EXPECT_EQ(target_bounds, parent()->dirty_rect()); } // Make sure an AnimationDelegate is deleted when canceled. diff --git a/ui/views/layout/box_layout.cc b/ui/views/layout/box_layout.cc index 59ea091..319efa7 100644 --- a/ui/views/layout/box_layout.cc +++ b/ui/views/layout/box_layout.cc @@ -72,7 +72,8 @@ void BoxLayout::Layout(View* host) { y += size.height() + between_child_spacing_ + padding; } // Clamp child view bounds to |child_area|. - child->SetBoundsRect(bounds.Intersect(child_area)); + bounds.Intersect(child_area); + child->SetBoundsRect(bounds); } } } @@ -86,11 +87,11 @@ gfx::Size BoxLayout::GetPreferredSize(View* host) { gfx::Size size(child->GetPreferredSize()); if (orientation_ == kHorizontal) { gfx::Rect child_bounds(position, 0, size.width(), size.height()); - bounds = bounds.Union(child_bounds); + bounds.Union(child_bounds); position += size.width(); } else { gfx::Rect child_bounds(0, position, size.width(), size.height()); - bounds = bounds.Union(child_bounds); + bounds.Union(child_bounds); position += size.height(); } position += between_child_spacing_; diff --git a/ui/views/view.cc b/ui/views/view.cc index 7fc0fe6..d2830f7 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -336,7 +336,7 @@ gfx::Rect View::GetVisibleBounds() const { const View* ancestor = view->parent_; if (ancestor != NULL) { ancestor_bounds.SetRect(0, 0, ancestor->width(), ancestor->height()); - vis_bounds = vis_bounds.Intersect(ancestor_bounds); + vis_bounds.Intersect(ancestor_bounds); } else if (!view->GetWidget()) { // If the view has no Widget, we're not visible. Return an empty rect. return gfx::Rect(); diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc index 8b1d54e..484b70a 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -2019,7 +2019,7 @@ class TransformPaintView : public TestView { // Overridden from View: virtual void SchedulePaintInRect(const gfx::Rect& rect) { gfx::Rect xrect = ConvertRectToParent(rect); - scheduled_paint_rect_ = scheduled_paint_rect_.Union(xrect); + scheduled_paint_rect_.Union(xrect); } private: @@ -2325,9 +2325,8 @@ TEST_F(ViewTest, SetBoundsPaint) { EXPECT_EQ(2U, top_view.scheduled_paint_rects_.size()); // There should be 2 rects, spanning from (10, 10) to (50, 50). - gfx::Rect paint_rect = - top_view.scheduled_paint_rects_[0].Union( - top_view.scheduled_paint_rects_[1]); + gfx::Rect paint_rect = top_view.scheduled_paint_rects_[0]; + paint_rect.Union(top_view.scheduled_paint_rects_[1]); EXPECT_EQ(gfx::Rect(10, 10, 40, 40), paint_rect); } diff --git a/ui/views/widget/desktop_root_window_host_linux.cc b/ui/views/widget/desktop_root_window_host_linux.cc index 7e05d0b..6405026 100644 --- a/ui/views/widget/desktop_root_window_host_linux.cc +++ b/ui/views/widget/desktop_root_window_host_linux.cc @@ -372,7 +372,7 @@ void DesktopRootWindowHostLinux::CenterWindow(const gfx::Size& size) { size.height()); // Don't size the window bigger than the parent, otherwise the user may not be // able to close or move it. - window_bounds = window_bounds.AdjustToFit(parent_bounds); + window_bounds.AdjustToFit(parent_bounds); SetBounds(window_bounds); } diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index cd209c4..2ed70d2 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -297,13 +297,14 @@ void NativeWidgetAura::CenterWindow(const gfx::Size& size) { work_area.set_origin(origin); } - parent_bounds = parent_bounds.Intersect(work_area); + parent_bounds.Intersect(work_area); // If |window_|'s transient parent's bounds are big enough to fit it, then we // center it with respect to the transient parent. if (window_->transient_parent()) { gfx::Rect transient_parent_rect = window_->transient_parent()-> - GetBoundsInRootWindow().Intersect(work_area); + GetBoundsInRootWindow(); + transient_parent_rect.Intersect(work_area); if (transient_parent_rect.height() >= size.height() && transient_parent_rect.width() >= size.width()) parent_bounds = transient_parent_rect; @@ -316,7 +317,7 @@ void NativeWidgetAura::CenterWindow(const gfx::Size& size) { size.height()); // Don't size the window bigger than the parent, otherwise the user may not be // able to close or move it. - window_bounds = window_bounds.AdjustToFit(parent_bounds); + window_bounds.AdjustToFit(parent_bounds); // Convert the bounds back relative to the parent. gfx::Point origin = window_bounds.origin(); diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc index 2db6cb1..ec6dc50 100644 --- a/ui/views/widget/root_view.cc +++ b/ui/views/widget/root_view.cc @@ -191,7 +191,8 @@ void RootView::SchedulePaintInRect(const gfx::Rect& rect) { layer()->SchedulePaint(rect); } else { gfx::Rect xrect = ConvertRectToParent(rect); - gfx::Rect invalid_rect = GetLocalBounds().Intersect(xrect); + gfx::Rect invalid_rect = GetLocalBounds(); + invalid_rect.Intersect(xrect); if (!invalid_rect.IsEmpty()) widget_->SchedulePaintInRect(invalid_rect); } diff --git a/ui/views/widget/tooltip_manager_win.cc b/ui/views/widget/tooltip_manager_win.cc index 9688625..98891ea 100644 --- a/ui/views/widget/tooltip_manager_win.cc +++ b/ui/views/widget/tooltip_manager_win.cc @@ -366,7 +366,9 @@ void TooltipManagerWin::ShowKeyboardTooltip(View* focused_view) { line_count * tooltip_height_ }; gfx::Rect monitor_bounds = views::GetMonitorBoundsForRect(gfx::Rect(rect_bounds)); - rect_bounds = gfx::Rect(rect_bounds).AdjustToFit(monitor_bounds).ToRECT(); + gfx::Rect fitted_bounds = gfx::Rect(rect_bounds); + fitted_bounds.AdjustToFit(monitor_bounds); + rect_bounds = fitted_bounds.ToRECT(); ::SetWindowPos(keyboard_tooltip_hwnd_, NULL, rect_bounds.left, rect_bounds.top, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index 5faf58a..fef8cd2 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -474,7 +474,8 @@ void Widget::SetBoundsConstrained(const gfx::Rect& bounds) { } else { // Inset the work area slightly. work_area.Inset(10, 10, 10, 10); - SetBounds(work_area.AdjustToFit(bounds)); + work_area.AdjustToFit(bounds); + SetBounds(work_area); } } diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index c52deb5..c96a474 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -842,7 +842,7 @@ void HWNDMessageHandler::SchedulePaintInRect(const gfx::Rect& rect) { if (use_layered_buffer_) { // We must update the back-buffer immediately, since Windows' handling of // invalid rects is somewhat mysterious. - invalid_rect_ = invalid_rect_.Union(rect); + invalid_rect_.Union(rect); // In some situations, such as drag and drop, when Windows itself runs a // nested message loop our message loop appears to be starved and we don't @@ -2034,7 +2034,8 @@ void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) { int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); new_window_rect.Inset(-border_thickness, -border_thickness); } else { - new_window_rect = gfx::Rect(window_rect).AdjustToFit(work_area); + new_window_rect = gfx::Rect(window_rect); + new_window_rect.AdjustToFit(work_area); } window_pos->x = new_window_rect.x(); window_pos->y = new_window_rect.y(); diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc index 52aa70b..869ea9f 100644 --- a/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc +++ b/webkit/plugins/npapi/webplugin_delegate_impl_gtk.cc @@ -355,12 +355,13 @@ void WebPluginDelegateImpl::WindowlessPaint(cairo_t* context, // "real" means as seen by Chrome // "apparent" means as seen by the plugin. - gfx::Rect draw_rect = window_rect_.Intersect(damage_rect); + gfx::Rect draw_rect = window_rect_; + draw_rect.Intersect(damage_rect); // clip_rect_ is relative to the plugin gfx::Rect clip_rect_window = clip_rect_; clip_rect_window.Offset(window_rect_.x(), window_rect_.y()); - draw_rect = draw_rect.Intersect(clip_rect_window); + draw_rect.Intersect(clip_rect_window); // These offsets represent by how much the view is shifted to accomodate // Flash (the coordinates of X relative to O in the diagram above). diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm index 806bdeb..685d019 100644 --- a/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm +++ b/webkit/plugins/npapi/webplugin_delegate_impl_mac.mm @@ -455,16 +455,16 @@ void WebPluginDelegateImpl::WindowlessPaint(gfx::NativeDrawingContext context, base::StatsRate plugin_paint("Plugin.Paint"); base::StatsScope<base::StatsRate> scope(plugin_paint); - gfx::Rect paint_rect; + gfx::Rect paint_rect = damage_rect; if (use_buffer_context_) { // Plugin invalidates trigger asynchronous paints with the original // invalidation rect; the plugin may be resized before the paint is handled, // so we need to ensure that the damage rect is still sane. - paint_rect = damage_rect.Intersect( + paint_rect.Intersect( gfx::Rect(0, 0, window_rect_.width(), window_rect_.height())); } else { // Use the actual window region when drawing directly to the window context. - paint_rect = damage_rect.Intersect(window_rect_); + paint_rect.Intersect(window_rect_); } ScopedActiveDelegate active_delegate(this); diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 134b10e..3872805 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -1065,11 +1065,14 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint( gfx::Rect pixel_plugin_backing_store_rect( 0, 0, image_data->width(), image_data->height()); float scale = GetBoundGraphics2D()->GetScale(); + gfx::RectF scaled_backing_store_rect = pixel_plugin_backing_store_rect; + scaled_backing_store_rect.Scale(scale); gfx::Rect plugin_backing_store_rect = - gfx::ToEnclosedRect(pixel_plugin_backing_store_rect.Scale(scale)); + gfx::ToEnclosedRect(scaled_backing_store_rect); gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect); - gfx::Rect plugin_paint_rect = plugin_backing_store_rect.Intersect(clip_page); + gfx::Rect plugin_paint_rect = plugin_backing_store_rect; + plugin_paint_rect.Intersect(clip_page); if (!plugin_paint_rect.Contains(relative_paint_bounds)) return false; diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc index 85c27d9..923b88d 100644 --- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc @@ -376,7 +376,8 @@ int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback, // Set |no_update_visible| to false if the change overlaps the visible // area. - gfx::Rect visible_changed_rect = clip.Intersect(op_rect); + gfx::Rect visible_changed_rect = clip; + visible_changed_rect.Intersect(op_rect); if (!visible_changed_rect.IsEmpty()) no_update_visible = false; @@ -560,7 +561,8 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas, CGContextDrawImage(canvas, bitmap_rect, image); #else - gfx::Rect invalidate_rect = plugin_rect.Intersect(paint_rect); + gfx::Rect invalidate_rect = plugin_rect; + invalidate_rect.Intersect(paint_rect); SkRect sk_invalidate_rect = gfx::RectToSkRect(invalidate_rect); SkAutoCanvasRestore auto_restore(canvas, true); canvas->clipRect(sk_invalidate_rect); @@ -647,12 +649,17 @@ bool PPB_Graphics2D_Impl::ConvertToLogicalPixels(float scale, // Take the enclosing rectangle after scaling so a rectangle scaled down then // scaled back up by the inverse scale would fully contain the entire area // affected by the original rectangle. - *op_rect = gfx::ToEnclosingRect(op_rect->Scale(scale)); + gfx::RectF scaled_rect = *op_rect; + scaled_rect.Scale(scale); + *op_rect = gfx::ToEnclosingRect(scaled_rect); if (delta) { gfx::Point original_delta = *delta; float inverse_scale = 1.0f / scale; *delta = gfx::ToFlooredPoint(delta->Scale(scale)); - if (original_rect != gfx::ToEnclosingRect(op_rect->Scale(inverse_scale)) || + + gfx::RectF inverse_scaled_rect = *op_rect; + inverse_scaled_rect.Scale(inverse_scale); + if (original_rect != gfx::ToEnclosingRect(inverse_scaled_rect) || original_delta != gfx::ToFlooredPoint(delta->Scale(inverse_scale))) { return false; } diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc index 1a190bb..7242de6 100644 --- a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc +++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc @@ -211,7 +211,7 @@ void PPB_Scrollbar_Impl::invalidateScrollbarRect( rect.y, rect.width, rect.height); - dirty_ = dirty_.Union(gfx_rect); + dirty_.Union(gfx_rect); // Can't call into the client to tell them about the invalidate right away, // since the PPB_Scrollbar_Impl code is still in the middle of updating its // internal state. diff --git a/webkit/plugins/webview_plugin.cc b/webkit/plugins/webview_plugin.cc index 7d3dc7e..9888b73 100644 --- a/webkit/plugins/webview_plugin.cc +++ b/webkit/plugins/webview_plugin.cc @@ -120,7 +120,8 @@ bool WebViewPlugin::getFormValue(WebString& value) { } void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) { - gfx::Rect paintRect(rect_.Intersect(rect)); + gfx::Rect paintRect = rect_; + paintRect.Intersect(rect); if (paintRect.IsEmpty()) return; diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc index 6f3c8e7..8029928 100644 --- a/webkit/tools/test_shell/webwidget_host_gtk.cc +++ b/webkit/tools/test_shell/webwidget_host_gtk.cc @@ -290,7 +290,7 @@ WebWidgetHost* WebWidgetHost::Create(GtkWidget* parent_view, } void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { - paint_rect_ = paint_rect_.Union(rect); + paint_rect_.Union(rect); } void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { @@ -377,14 +377,14 @@ void WebWidgetHost::Paint() { // to update that area after we're done painting it. gfx::Rect total_paint; for (int i = 0; i < 2; ++i) { - paint_rect_ = client_rect.Intersect(paint_rect_); + paint_rect_.Intersect(client_rect); if (!paint_rect_.IsEmpty()) { gfx::Rect rect(paint_rect_); paint_rect_ = gfx::Rect(); DLOG_IF(WARNING, i == 1) << "painting caused additional invalidations"; PaintRect(rect); - total_paint = total_paint.Union(rect); + total_paint.Union(rect); } } //DCHECK(paint_rect_.IsEmpty()); diff --git a/webkit/tools/test_shell/webwidget_host_mac.mm b/webkit/tools/test_shell/webwidget_host_mac.mm index 60a10f5..795430e 100644 --- a/webkit/tools/test_shell/webwidget_host_mac.mm +++ b/webkit/tools/test_shell/webwidget_host_mac.mm @@ -97,10 +97,10 @@ void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { // If this invalidate overlaps with a pending scroll, then we have to // downgrade to invalidating the scroll rect. if (damaged_rect.Intersects(scroll_rect_)) { - paint_rect_ = paint_rect_.Union(scroll_rect_); + paint_rect_.Union(scroll_rect_); ResetScrollRect(); } - paint_rect_ = paint_rect_.Union(damaged_rect); + paint_rect_.Union(damaged_rect); NSRect r = NSRectFromCGRect(damaged_rect.ToCGRect()); // flip to cocoa coordinates @@ -114,9 +114,9 @@ void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { // If we already have a pending scroll operation or if this scroll operation // intersects the existing paint region, then just failover to invalidating. if (!scroll_rect_.IsEmpty() || paint_rect_.Intersects(clip_rect)) { - paint_rect_ = paint_rect_.Union(scroll_rect_); + paint_rect_.Union(scroll_rect_); ResetScrollRect(); - paint_rect_ = paint_rect_.Union(clip_rect); + paint_rect_.Union(clip_rect); } // We will perform scrolling lazily, when requested to actually paint. @@ -161,7 +161,7 @@ WebWidgetHost::~WebWidgetHost() { } void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { - paint_rect_ = paint_rect_.Union(rect); + paint_rect_.Union(rect); } void WebWidgetHost::Paint() { @@ -190,10 +190,10 @@ void WebWidgetHost::Paint() { webwidget_->layout(); // Scroll the canvas if necessary - scroll_rect_ = client_rect.Intersect(scroll_rect_); + scroll_rect_.Intersect(client_rect); if (!scroll_rect_.IsEmpty()) { // add to invalidate rect, since there's no equivalent of ScrollDC. - paint_rect_ = paint_rect_.Union(scroll_rect_); + paint_rect_.Union(scroll_rect_); } ResetScrollRect(); @@ -201,7 +201,7 @@ void WebWidgetHost::Paint() { // first time we call it. This is necessary because some WebCore rendering // objects update their layout only when painted. for (int i = 0; i < 2; ++i) { - paint_rect_ = client_rect.Intersect(paint_rect_); + paint_rect_.Intersect(client_rect); if (!paint_rect_.IsEmpty()) { gfx::Rect rect(paint_rect_); paint_rect_ = gfx::Rect(); diff --git a/webkit/tools/test_shell/webwidget_host_win.cc b/webkit/tools/test_shell/webwidget_host_win.cc index db5244a..b816f83 100644 --- a/webkit/tools/test_shell/webwidget_host_win.cc +++ b/webkit/tools/test_shell/webwidget_host_win.cc @@ -143,10 +143,10 @@ void WebWidgetHost::DidInvalidateRect(const gfx::Rect& damaged_rect) { // If this invalidate overlaps with a pending scroll, then we have to // downgrade to invalidating the scroll rect. if (damaged_rect.Intersects(scroll_rect_)) { - paint_rect_ = paint_rect_.Union(scroll_rect_); + paint_rect_.Union(scroll_rect_); ResetScrollRect(); } - paint_rect_ = paint_rect_.Union(damaged_rect); + paint_rect_.Union(damaged_rect); RECT r = damaged_rect.ToRECT(); InvalidateRect(view_, &r, FALSE); @@ -162,9 +162,9 @@ void WebWidgetHost::DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect) { // If we already have a pending scroll operation or if this scroll operation // intersects the existing paint region, then just failover to invalidating. if (!scroll_rect_.IsEmpty() || paint_rect_.Intersects(clip_rect)) { - paint_rect_ = paint_rect_.Union(scroll_rect_); + paint_rect_.Union(scroll_rect_); ResetScrollRect(); - paint_rect_ = paint_rect_.Union(clip_rect); + paint_rect_.Union(clip_rect); } // We will perform scrolling lazily, when requested to actually paint. @@ -227,7 +227,7 @@ bool WebWidgetHost::WndProc(UINT message, WPARAM wparam, LPARAM lparam) { } void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { - paint_rect_ = paint_rect_.Union(rect); + paint_rect_.Union(rect); } void WebWidgetHost::Paint() { @@ -249,7 +249,7 @@ void WebWidgetHost::Paint() { webwidget_->layout(); // Scroll the canvas if necessary - scroll_rect_ = client_rect.Intersect(scroll_rect_); + scroll_rect_.Intersect(client_rect); if (!scroll_rect_.IsEmpty()) { skia::ScopedPlatformPaint scoped_platform_paint(canvas_.get()); HDC hdc = scoped_platform_paint.GetPlatformSurface(); @@ -265,7 +265,7 @@ void WebWidgetHost::Paint() { // first time we call it. This is necessary because some WebCore rendering // objects update their layout only when painted. for (int i = 0; i < 2; ++i) { - paint_rect_ = client_rect.Intersect(paint_rect_); + paint_rect_.Intersect(client_rect); if (!paint_rect_.IsEmpty()) { gfx::Rect rect(paint_rect_); paint_rect_ = gfx::Rect(); |