| 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 skia::ScopedPlatformCanvas canvas(new_size.width, new_size.height, true); |
| 71 new_size.width, new_size.height, true /* is_opaque */); | 71 |
| 72 view->paint(webkit_glue::ToWebCanvas(&canvas), | 72 view->paint(webkit_glue::ToWebCanvas(canvas), |
| 73 gfx::Rect(0, 0, new_size.width, new_size.height)); | 73 gfx::Rect(0, 0, new_size.width, new_size.height)); |
| 74 | 74 |
| 75 frame->setCanHaveScrollbars(true); | 75 frame->setCanHaveScrollbars(true); |
| 76 view->setFixedLayoutSize(fixed_size); | 76 view->setFixedLayoutSize(fixed_size); |
| 77 view->enableFixedLayoutMode(fixed_layout_enabled); | 77 view->enableFixedLayoutMode(fixed_layout_enabled); |
| 78 view->resize(old_size); | 78 view->resize(old_size); |
| 79 view->layout(); | 79 view->layout(); |
| 80 frame->setScrollOffset(WebSize(old_scroll.width - min_scroll.width, | 80 frame->setScrollOffset(WebSize(old_scroll.width - min_scroll.width, |
| 81 old_scroll.height - min_scroll.height)); | 81 old_scroll.height - min_scroll.height)); |
| 82 | 82 |
| 83 const SkBitmap& bmp = skia::GetTopDevice(canvas)->accessBitmap(false); | 83 const SkBitmap& bmp = skia::GetTopDevice(*canvas)->accessBitmap(false); |
| 84 SkAutoLockPixels lock_pixels(bmp); | 84 SkAutoLockPixels lock_pixels(bmp); |
| 85 // EncodeBGRA uses FORMAT_SkBitmap, which doesn't work on windows for some | 85 // EncodeBGRA uses FORMAT_SkBitmap, which doesn't work on windows for some |
| 86 // cases dealing with transparency. See crbug.com/96317. Use FORMAT_BGRA. | 86 // cases dealing with transparency. See crbug.com/96317. Use FORMAT_BGRA. |
| 87 bool encode_success = gfx::PNGCodec::Encode( | 87 bool encode_success = gfx::PNGCodec::Encode( |
| 88 reinterpret_cast<unsigned char*>(bmp.getPixels()), | 88 reinterpret_cast<unsigned char*>(bmp.getPixels()), |
| 89 gfx::PNGCodec::FORMAT_BGRA, | 89 gfx::PNGCodec::FORMAT_BGRA, |
| 90 gfx::Size(bmp.width(), bmp.height()), | 90 gfx::Size(bmp.width(), bmp.height()), |
| 91 bmp.rowBytes(), | 91 bmp.rowBytes(), |
| 92 true, // discard_transparency | 92 true, // discard_transparency |
| 93 std::vector<gfx::PNGCodec::Comment>(), | 93 std::vector<gfx::PNGCodec::Comment>(), |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 routing_id(), frame->identifier())); | 281 routing_id(), frame->identifier())); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void AutomationRendererHelper::OnProcessMouseEvent( | 284 void AutomationRendererHelper::OnProcessMouseEvent( |
| 285 const AutomationMouseEvent& event) { | 285 const AutomationMouseEvent& event) { |
| 286 std::string error_msg; | 286 std::string error_msg; |
| 287 bool success = ProcessMouseEvent(event, &error_msg); | 287 bool success = ProcessMouseEvent(event, &error_msg); |
| 288 Send(new AutomationMsg_ProcessMouseEventACK( | 288 Send(new AutomationMsg_ProcessMouseEventACK( |
| 289 routing_id(), success, error_msg)); | 289 routing_id(), success, error_msg)); |
| 290 } | 290 } |
| OLD | NEW |