OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 gfx::Rect view_bounds = window_->GetBoundsInRootWindow(); | 430 gfx::Rect view_bounds = window_->GetBoundsInRootWindow(); |
431 std::vector<webkit::npapi::WebPluginGeometry> moves = plugin_window_moves; | 431 std::vector<webkit::npapi::WebPluginGeometry> moves = plugin_window_moves; |
432 | 432 |
433 gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(), | 433 gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(), |
434 view_bounds.height()); | 434 view_bounds.height()); |
435 | 435 |
436 for (size_t i = 0; i < moves.size(); ++i) { | 436 for (size_t i = 0; i < moves.size(); ++i) { |
437 gfx::Rect clip = moves[i].clip_rect; | 437 gfx::Rect clip = moves[i].clip_rect; |
438 clip.Offset(moves[i].window_rect.origin()); | 438 clip.Offset(moves[i].window_rect.origin()); |
439 clip.Offset(scroll_offset); | 439 clip.Offset(scroll_offset); |
440 clip = clip.Intersect(view_port); | 440 clip.Intersect(view_port); |
441 clip.Offset(-moves[i].window_rect.x(), -moves[i].window_rect.y()); | 441 clip.Offset(-moves[i].window_rect.x(), -moves[i].window_rect.y()); |
442 clip.Offset(-scroll_offset.x(), -scroll_offset.y()); | 442 clip.Offset(-scroll_offset.x(), -scroll_offset.y()); |
443 moves[i].clip_rect = clip; | 443 moves[i].clip_rect = clip; |
444 | 444 |
445 moves[i].window_rect.Offset(view_bounds.origin()); | 445 moves[i].window_rect.Offset(view_bounds.origin()); |
446 } | 446 } |
447 MovePluginWindowsHelper(parent, moves); | 447 MovePluginWindowsHelper(parent, moves); |
448 | 448 |
449 // Make sure each plugin window (or its wrapper if it exists) has a pointer to | 449 // Make sure each plugin window (or its wrapper if it exists) has a pointer to |
450 // |this|. | 450 // |this|. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 if (paint_canvas_) { | 551 if (paint_canvas_) { |
552 SkRect sk_clip_rect; | 552 SkRect sk_clip_rect; |
553 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect)) | 553 if (paint_canvas_->sk_canvas()->getClipBounds(&sk_clip_rect)) |
554 clip_rect = gfx::SkRectToRect(sk_clip_rect); | 554 clip_rect = gfx::SkRectToRect(sk_clip_rect); |
555 } | 555 } |
556 | 556 |
557 if (!scroll_rect.IsEmpty()) | 557 if (!scroll_rect.IsEmpty()) |
558 SchedulePaintIfNotInClip(scroll_rect, clip_rect); | 558 SchedulePaintIfNotInClip(scroll_rect, clip_rect); |
559 | 559 |
560 for (size_t i = 0; i < copy_rects.size(); ++i) { | 560 for (size_t i = 0; i < copy_rects.size(); ++i) { |
561 gfx::Rect rect = copy_rects[i].Subtract(scroll_rect); | 561 gfx::Rect rect = copy_rects[i]; |
| 562 rect.Subtract(scroll_rect); |
562 if (rect.IsEmpty()) | 563 if (rect.IsEmpty()) |
563 continue; | 564 continue; |
564 | 565 |
565 SchedulePaintIfNotInClip(rect, clip_rect); | 566 SchedulePaintIfNotInClip(rect, clip_rect); |
566 | 567 |
567 #if defined(OS_WIN) | 568 #if defined(OS_WIN) |
568 // Send the invalid rect in screen coordinates. | 569 // Send the invalid rect in screen coordinates. |
569 gfx::Rect screen_rect = GetViewBounds(); | 570 gfx::Rect screen_rect = GetViewBounds(); |
570 gfx::Rect invalid_screen_rect(rect); | 571 gfx::Rect invalid_screen_rect(rect); |
571 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); | 572 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( | 865 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( |
865 params_in_pixel.x, | 866 params_in_pixel.x, |
866 surface_size_in_pixel.height() - params_in_pixel.y - | 867 surface_size_in_pixel.height() - params_in_pixel.y - |
867 params_in_pixel.height, | 868 params_in_pixel.height, |
868 params_in_pixel.width, | 869 params_in_pixel.width, |
869 params_in_pixel.height)); | 870 params_in_pixel.height)); |
870 | 871 |
871 // Damage may not have been DIP aligned, so inflate damage to compensate | 872 // Damage may not have been DIP aligned, so inflate damage to compensate |
872 // for any round-off error. | 873 // for any round-off error. |
873 rect_to_paint.Inset(-1, -1); | 874 rect_to_paint.Inset(-1, -1); |
874 rect_to_paint = rect_to_paint.Intersect(window_->bounds()); | 875 rect_to_paint.Intersect(window_->bounds()); |
875 | 876 |
876 window_->SchedulePaintInRect(rect_to_paint); | 877 window_->SchedulePaintInRect(rect_to_paint); |
877 | 878 |
878 if (!resize_locks_.empty()) { | 879 if (!resize_locks_.empty()) { |
879 // If we are waiting for the resize, fast-track the ACK. | 880 // If we are waiting for the resize, fast-track the ACK. |
880 if (compositor->IsThreaded()) { | 881 if (compositor->IsThreaded()) { |
881 // We need the compositor thread to pick up the active buffer before | 882 // We need the compositor thread to pick up the active buffer before |
882 // ACKing. | 883 // ACKing. |
883 on_compositing_did_commit_callbacks_.push_back( | 884 on_compositing_did_commit_callbacks_.push_back( |
884 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, | 885 base::Bind(&RenderWidgetHostViewAura::InsertSyncPointAndACK, |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 aura::client::GetScreenPositionClient(root_window); | 1162 aura::client::GetScreenPositionClient(root_window); |
1162 screen_position_client->ConvertPointToScreen(window_, &origin); | 1163 screen_position_client->ConvertPointToScreen(window_, &origin); |
1163 screen_position_client->ConvertPointToScreen(window_, &end); | 1164 screen_position_client->ConvertPointToScreen(window_, &end); |
1164 return gfx::Rect(origin.x(), | 1165 return gfx::Rect(origin.x(), |
1165 origin.y(), | 1166 origin.y(), |
1166 end.x() - origin.x(), | 1167 end.x() - origin.x(), |
1167 end.y() - origin.y()); | 1168 end.y() - origin.y()); |
1168 } | 1169 } |
1169 | 1170 |
1170 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() { | 1171 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() { |
1171 const gfx::Rect rect = selection_start_rect_.Union(selection_end_rect_); | 1172 gfx::Rect rect = selection_start_rect_; |
| 1173 rect.Union(selection_end_rect_); |
1172 return ConvertRectToScreen(rect); | 1174 return ConvertRectToScreen(rect); |
1173 } | 1175 } |
1174 | 1176 |
1175 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(uint32 index, | 1177 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(uint32 index, |
1176 gfx::Rect* rect) { | 1178 gfx::Rect* rect) { |
1177 DCHECK(rect); | 1179 DCHECK(rect); |
1178 if (index >= composition_character_bounds_.size()) | 1180 if (index >= composition_character_bounds_.size()) |
1179 return false; | 1181 return false; |
1180 *rect = ConvertRectToScreen(composition_character_bounds_[index]); | 1182 *rect = ConvertRectToScreen(composition_character_bounds_[index]); |
1181 return true; | 1183 return true; |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 } else { | 1791 } else { |
1790 unlocked_mouse_position_.SetPoint(event->windowX, event->windowY); | 1792 unlocked_mouse_position_.SetPoint(event->windowX, event->windowY); |
1791 unlocked_global_mouse_position_.SetPoint(event->globalX, event->globalY); | 1793 unlocked_global_mouse_position_.SetPoint(event->globalX, event->globalY); |
1792 } | 1794 } |
1793 } | 1795 } |
1794 | 1796 |
1795 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( | 1797 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( |
1796 const gfx::Rect& rect, | 1798 const gfx::Rect& rect, |
1797 const gfx::Rect& clip) { | 1799 const gfx::Rect& clip) { |
1798 if (!clip.IsEmpty()) { | 1800 if (!clip.IsEmpty()) { |
1799 gfx::Rect to_paint = rect.Subtract(clip); | 1801 gfx::Rect to_paint = rect; |
| 1802 to_paint.Subtract(clip); |
1800 if (!to_paint.IsEmpty()) | 1803 if (!to_paint.IsEmpty()) |
1801 window_->SchedulePaintInRect(to_paint); | 1804 window_->SchedulePaintInRect(to_paint); |
1802 } else { | 1805 } else { |
1803 window_->SchedulePaintInRect(rect); | 1806 window_->SchedulePaintInRect(rect); |
1804 } | 1807 } |
1805 } | 1808 } |
1806 | 1809 |
1807 bool RenderWidgetHostViewAura::ShouldMoveToCenter() { | 1810 bool RenderWidgetHostViewAura::ShouldMoveToCenter() { |
1808 gfx::Rect rect = window_->bounds(); | 1811 gfx::Rect rect = window_->bounds(); |
1809 int border_x = rect.width() * kMouseLockBorderPercentage / 100; | 1812 int border_x = rect.width() * kMouseLockBorderPercentage / 100; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 RenderWidgetHost* widget) { | 1888 RenderWidgetHost* widget) { |
1886 return new RenderWidgetHostViewAura(widget); | 1889 return new RenderWidgetHostViewAura(widget); |
1887 } | 1890 } |
1888 | 1891 |
1889 // static | 1892 // static |
1890 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 1893 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
1891 GetScreenInfoForWindow(results, NULL); | 1894 GetScreenInfoForWindow(results, NULL); |
1892 } | 1895 } |
1893 | 1896 |
1894 } // namespace content | 1897 } // namespace content |
OLD | NEW |