| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/common/page_state_serialization.h" | 5 #include "content/common/page_state_serialization.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| 11 | 11 |
| 12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "ui/gfx/screen.h" | 17 #include "ui/display/screen.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
| 23 float g_device_scale_factor_for_testing = 0.0; | 23 float g_device_scale_factor_for_testing = 0.0; |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 //----------------------------------------------------------------------------- | 26 //----------------------------------------------------------------------------- |
| 27 | 27 |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 // Now-unused values that shipped in this version of Chrome for Android when | 598 // Now-unused values that shipped in this version of Chrome for Android when |
| 599 // it was on a private branch. | 599 // it was on a private branch. |
| 600 ReadReal(obj); | 600 ReadReal(obj); |
| 601 ReadBoolean(obj); | 601 ReadBoolean(obj); |
| 602 | 602 |
| 603 // In this version, page_scale_factor included device_scale_factor and | 603 // In this version, page_scale_factor included device_scale_factor and |
| 604 // scroll offsets were premultiplied by pageScaleFactor. | 604 // scroll offsets were premultiplied by pageScaleFactor. |
| 605 if (state->page_scale_factor) { | 605 if (state->page_scale_factor) { |
| 606 float device_scale_factor = g_device_scale_factor_for_testing; | 606 float device_scale_factor = g_device_scale_factor_for_testing; |
| 607 if (!device_scale_factor) { | 607 if (!device_scale_factor) { |
| 608 device_scale_factor = | 608 device_scale_factor = display::Screen::GetScreen() |
| 609 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); | 609 ->GetPrimaryDisplay() |
| 610 .device_scale_factor(); |
| 610 } | 611 } |
| 611 state->scroll_offset = | 612 state->scroll_offset = |
| 612 gfx::Point(state->scroll_offset.x() / state->page_scale_factor, | 613 gfx::Point(state->scroll_offset.x() / state->page_scale_factor, |
| 613 state->scroll_offset.y() / state->page_scale_factor); | 614 state->scroll_offset.y() / state->page_scale_factor); |
| 614 state->page_scale_factor /= device_scale_factor; | 615 state->page_scale_factor /= device_scale_factor; |
| 615 } | 616 } |
| 616 } | 617 } |
| 617 #endif | 618 #endif |
| 618 | 619 |
| 619 // Subitems | 620 // Subitems |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 float device_scale_factor, | 755 float device_scale_factor, |
| 755 ExplodedPageState* exploded) { | 756 ExplodedPageState* exploded) { |
| 756 g_device_scale_factor_for_testing = device_scale_factor; | 757 g_device_scale_factor_for_testing = device_scale_factor; |
| 757 bool rv = DecodePageState(encoded, exploded); | 758 bool rv = DecodePageState(encoded, exploded); |
| 758 g_device_scale_factor_for_testing = 0.0; | 759 g_device_scale_factor_for_testing = 0.0; |
| 759 return rv; | 760 return rv; |
| 760 } | 761 } |
| 761 #endif | 762 #endif |
| 762 | 763 |
| 763 } // namespace content | 764 } // namespace content |
| OLD | NEW |