Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 11270042: Add non-member non-mutating methods for common gfx::Rect operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 if (paint_canvas_) { 580 if (paint_canvas_) {
581 SkRect sk_clip_rect; 581 SkRect sk_clip_rect;
582 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect)) 582 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect))
583 clip_rect = gfx::SkRectToRect(sk_clip_rect); 583 clip_rect = gfx::SkRectToRect(sk_clip_rect);
584 } 584 }
585 585
586 if (!scroll_rect.IsEmpty()) 586 if (!scroll_rect.IsEmpty())
587 SchedulePaintIfNotInClip(scroll_rect, clip_rect); 587 SchedulePaintIfNotInClip(scroll_rect, clip_rect);
588 588
589 for (size_t i = 0; i < copy_rects.size(); ++i) { 589 for (size_t i = 0; i < copy_rects.size(); ++i) {
590 gfx::Rect rect = copy_rects[i]; 590 gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect);
591 rect.Subtract(scroll_rect);
592 if (rect.IsEmpty()) 591 if (rect.IsEmpty())
593 continue; 592 continue;
594 593
595 SchedulePaintIfNotInClip(rect, clip_rect); 594 SchedulePaintIfNotInClip(rect, clip_rect);
596 595
597 #if defined(OS_WIN) 596 #if defined(OS_WIN)
598 // Send the invalid rect in screen coordinates. 597 // Send the invalid rect in screen coordinates.
599 gfx::Rect screen_rect = GetViewBounds(); 598 gfx::Rect screen_rect = GetViewBounds();
600 gfx::Rect invalid_screen_rect(rect); 599 gfx::Rect invalid_screen_rect(rect);
601 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); 600 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y());
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 aura::client::GetScreenPositionClient(root_window); 1185 aura::client::GetScreenPositionClient(root_window);
1187 screen_position_client->ConvertPointToScreen(window_, &origin); 1186 screen_position_client->ConvertPointToScreen(window_, &origin);
1188 screen_position_client->ConvertPointToScreen(window_, &end); 1187 screen_position_client->ConvertPointToScreen(window_, &end);
1189 return gfx::Rect(origin.x(), 1188 return gfx::Rect(origin.x(),
1190 origin.y(), 1189 origin.y(),
1191 end.x() - origin.x(), 1190 end.x() - origin.x(),
1192 end.y() - origin.y()); 1191 end.y() - origin.y());
1193 } 1192 }
1194 1193
1195 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() { 1194 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() {
1196 gfx::Rect rect = selection_start_rect_; 1195 const gfx::Rect rect =
1197 rect.Union(selection_end_rect_); 1196 gfx::UnionRects(selection_start_rect_, selection_end_rect_);
1198 return ConvertRectToScreen(rect); 1197 return ConvertRectToScreen(rect);
1199 } 1198 }
1200 1199
1201 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(uint32 index, 1200 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(uint32 index,
1202 gfx::Rect* rect) { 1201 gfx::Rect* rect) {
1203 DCHECK(rect); 1202 DCHECK(rect);
1204 if (index >= composition_character_bounds_.size()) 1203 if (index >= composition_character_bounds_.size())
1205 return false; 1204 return false;
1206 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1205 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
1207 return true; 1206 return true;
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 } else { 1830 } else {
1832 unlocked_mouse_position_.SetPoint(event->windowX, event->windowY); 1831 unlocked_mouse_position_.SetPoint(event->windowX, event->windowY);
1833 unlocked_global_mouse_position_.SetPoint(event->globalX, event->globalY); 1832 unlocked_global_mouse_position_.SetPoint(event->globalX, event->globalY);
1834 } 1833 }
1835 } 1834 }
1836 1835
1837 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( 1836 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip(
1838 const gfx::Rect& rect, 1837 const gfx::Rect& rect,
1839 const gfx::Rect& clip) { 1838 const gfx::Rect& clip) {
1840 if (!clip.IsEmpty()) { 1839 if (!clip.IsEmpty()) {
1841 gfx::Rect to_paint = rect; 1840 gfx::Rect to_paint = gfx::SubtractRects(rect, clip);
1842 to_paint.Subtract(clip);
1843 if (!to_paint.IsEmpty()) 1841 if (!to_paint.IsEmpty())
1844 window_->SchedulePaintInRect(to_paint); 1842 window_->SchedulePaintInRect(to_paint);
1845 } else { 1843 } else {
1846 window_->SchedulePaintInRect(rect); 1844 window_->SchedulePaintInRect(rect);
1847 } 1845 }
1848 } 1846 }
1849 1847
1850 bool RenderWidgetHostViewAura::ShouldMoveToCenter() { 1848 bool RenderWidgetHostViewAura::ShouldMoveToCenter() {
1851 gfx::Rect rect = window_->bounds(); 1849 gfx::Rect rect = window_->bounds();
1852 int border_x = rect.width() * kMouseLockBorderPercentage / 100; 1850 int border_x = rect.width() * kMouseLockBorderPercentage / 100;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 RenderWidgetHost* widget) { 1916 RenderWidgetHost* widget) {
1919 return new RenderWidgetHostViewAura(widget); 1917 return new RenderWidgetHostViewAura(widget);
1920 } 1918 }
1921 1919
1922 // static 1920 // static
1923 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 1921 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
1924 GetScreenInfoForWindow(results, NULL); 1922 GetScreenInfoForWindow(results, NULL);
1925 } 1923 }
1926 1924
1927 } // namespace content 1925 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/backing_store_mac.mm ('k') | content/browser/renderer_host/render_widget_host_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698