OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/renderer/automation/automation_renderer_helper.h" | 5 #include "chrome/renderer/automation/automation_renderer_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 bool fixed_layout_enabled = view->isFixedLayoutModeEnabled(); | 60 bool fixed_layout_enabled = view->isFixedLayoutModeEnabled(); |
61 WebSize fixed_size = view->fixedLayoutSize(); | 61 WebSize fixed_size = view->fixedLayoutSize(); |
62 | 62 |
63 frame->setCanHaveScrollbars(false); | 63 frame->setCanHaveScrollbars(false); |
64 view->setFixedLayoutSize(old_size); | 64 view->setFixedLayoutSize(old_size); |
65 view->enableFixedLayoutMode(true); | 65 view->enableFixedLayoutMode(true); |
66 view->resize(new_size); | 66 view->resize(new_size); |
67 view->layout(); | 67 view->layout(); |
68 frame->setScrollOffset(WebSize(0, 0)); | 68 frame->setScrollOffset(WebSize(0, 0)); |
69 | 69 |
70 skia::PlatformCanvas canvas( | 70 SkCanvas* canvas = skia::CreatePlatformCanvas(new_size.width, new_size.height, |
sky
2012/11/01 17:41:39
Is it possible to return a value like we did befor
reed1
2012/11/01 21:07:21
Makes sense. I'll see what I can come up with.
reed1
2012/11/02 15:49:39
ScopedPlatformCanvas
Done.
| |
71 new_size.width, new_size.height, true /* is_opaque */); | 71 true /* is_opaque */); |
72 view->paint(webkit_glue::ToWebCanvas(&canvas), | 72 SkAutoUnref au(canvas); |
73 view->paint(webkit_glue::ToWebCanvas(canvas), | |
73 gfx::Rect(0, 0, new_size.width, new_size.height)); | 74 gfx::Rect(0, 0, new_size.width, new_size.height)); |
74 | 75 |
75 frame->setCanHaveScrollbars(true); | 76 frame->setCanHaveScrollbars(true); |
76 view->setFixedLayoutSize(fixed_size); | 77 view->setFixedLayoutSize(fixed_size); |
77 view->enableFixedLayoutMode(fixed_layout_enabled); | 78 view->enableFixedLayoutMode(fixed_layout_enabled); |
78 view->resize(old_size); | 79 view->resize(old_size); |
79 view->layout(); | 80 view->layout(); |
80 frame->setScrollOffset(WebSize(old_scroll.width - min_scroll.width, | 81 frame->setScrollOffset(WebSize(old_scroll.width - min_scroll.width, |
81 old_scroll.height - min_scroll.height)); | 82 old_scroll.height - min_scroll.height)); |
82 | 83 |
83 const SkBitmap& bmp = skia::GetTopDevice(canvas)->accessBitmap(false); | 84 const SkBitmap& bmp = skia::GetTopDevice(*canvas)->accessBitmap(false); |
84 SkAutoLockPixels lock_pixels(bmp); | 85 SkAutoLockPixels lock_pixels(bmp); |
85 // EncodeBGRA uses FORMAT_SkBitmap, which doesn't work on windows for some | 86 // EncodeBGRA uses FORMAT_SkBitmap, which doesn't work on windows for some |
86 // cases dealing with transparency. See crbug.com/96317. Use FORMAT_BGRA. | 87 // cases dealing with transparency. See crbug.com/96317. Use FORMAT_BGRA. |
87 bool encode_success = gfx::PNGCodec::Encode( | 88 bool encode_success = gfx::PNGCodec::Encode( |
88 reinterpret_cast<unsigned char*>(bmp.getPixels()), | 89 reinterpret_cast<unsigned char*>(bmp.getPixels()), |
89 gfx::PNGCodec::FORMAT_BGRA, | 90 gfx::PNGCodec::FORMAT_BGRA, |
90 gfx::Size(bmp.width(), bmp.height()), | 91 gfx::Size(bmp.width(), bmp.height()), |
91 bmp.rowBytes(), | 92 bmp.rowBytes(), |
92 true, // discard_transparency | 93 true, // discard_transparency |
93 std::vector<gfx::PNGCodec::Comment>(), | 94 std::vector<gfx::PNGCodec::Comment>(), |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 routing_id(), frame->identifier())); | 282 routing_id(), frame->identifier())); |
282 } | 283 } |
283 | 284 |
284 void AutomationRendererHelper::OnProcessMouseEvent( | 285 void AutomationRendererHelper::OnProcessMouseEvent( |
285 const AutomationMouseEvent& event) { | 286 const AutomationMouseEvent& event) { |
286 std::string error_msg; | 287 std::string error_msg; |
287 bool success = ProcessMouseEvent(event, &error_msg); | 288 bool success = ProcessMouseEvent(event, &error_msg); |
288 Send(new AutomationMsg_ProcessMouseEventACK( | 289 Send(new AutomationMsg_ProcessMouseEventACK( |
289 routing_id(), success, error_msg)); | 290 routing_id(), success, error_msg)); |
290 } | 291 } |
OLD | NEW |