Commit a728f0bb authored by bokan@chromium.org's avatar bokan@chromium.org

Added pinch viewport offset to page state.

Added field allows Blink to properly restore pinch-zoomed page
when using new "virtual viewport" mode of pinch.

Dependent Blink patch: https://codereview.chromium.org/263853008

BUG=364112

Review URL: https://codereview.chromium.org/266673014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269724 0039d316-1c4b-4281-b951-d872f2087c98
parent 8f1f8ac1
...@@ -191,12 +191,14 @@ struct SerializeObject { ...@@ -191,12 +191,14 @@ struct SerializeObject {
// 18: Add referrer policy. // 18: Add referrer policy.
// 19: Remove target frame id, which was a bad idea, and original url string, // 19: Remove target frame id, which was a bad idea, and original url string,
// which is no longer used. // which is no longer used.
// 20: Add pinch viewport scroll offset, the offset of the pinched zoomed
// viewport within the unzoomed main frame.
// //
// NOTE: If the version is -1, then the pickle contains only a URL string. // NOTE: If the version is -1, then the pickle contains only a URL string.
// See ReadPageState. // See ReadPageState.
// //
const int kMinVersion = 11; const int kMinVersion = 11;
const int kCurrentVersion = 19; const int kCurrentVersion = 20;
// A bunch of convenience functions to read/write to SerializeObjects. The // A bunch of convenience functions to read/write to SerializeObjects. The
// de-serializers assume the input data will be in the correct format and fall // de-serializers assume the input data will be in the correct format and fall
...@@ -510,6 +512,8 @@ void WriteFrameState( ...@@ -510,6 +512,8 @@ void WriteFrameState(
WriteInteger64(state.item_sequence_number, obj); WriteInteger64(state.item_sequence_number, obj);
WriteInteger64(state.document_sequence_number, obj); WriteInteger64(state.document_sequence_number, obj);
WriteInteger(state.referrer_policy, obj); WriteInteger(state.referrer_policy, obj);
WriteReal(state.pinch_viewport_scroll_offset.x(), obj);
WriteReal(state.pinch_viewport_scroll_offset.y(), obj);
bool has_state_object = !state.state_object.is_null(); bool has_state_object = !state.state_object.is_null();
WriteBoolean(has_state_object, obj); WriteBoolean(has_state_object, obj);
...@@ -572,6 +576,14 @@ void ReadFrameState(SerializeObject* obj, bool is_top, ...@@ -572,6 +576,14 @@ void ReadFrameState(SerializeObject* obj, bool is_top,
static_cast<blink::WebReferrerPolicy>(ReadInteger(obj)); static_cast<blink::WebReferrerPolicy>(ReadInteger(obj));
} }
if (obj->version >= 20) {
double x = ReadReal(obj);
double y = ReadReal(obj);
state->pinch_viewport_scroll_offset = gfx::PointF(x, y);
} else {
state->pinch_viewport_scroll_offset = gfx::PointF(-1, -1);
}
bool has_state_object = ReadBoolean(obj); bool has_state_object = ReadBoolean(obj);
if (has_state_object) if (has_state_object)
state->state_object = ReadString(obj); state->state_object = ReadString(obj);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "third_party/WebKit/public/platform/WebHTTPBody.h" #include "third_party/WebKit/public/platform/WebHTTPBody.h"
#include "third_party/WebKit/public/platform/WebReferrerPolicy.h" #include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
#include "ui/gfx/point_f.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace content { namespace content {
...@@ -47,6 +48,7 @@ struct CONTENT_EXPORT ExplodedFrameState { ...@@ -47,6 +48,7 @@ struct CONTENT_EXPORT ExplodedFrameState {
base::NullableString16 target; base::NullableString16 target;
base::NullableString16 state_object; base::NullableString16 state_object;
std::vector<base::NullableString16> document_state; std::vector<base::NullableString16> document_state;
gfx::PointF pinch_viewport_scroll_offset;
gfx::Point scroll_offset; gfx::Point scroll_offset;
int64 item_sequence_number; int64 item_sequence_number;
int64 document_sequence_number; int64 document_sequence_number;
......
...@@ -72,6 +72,7 @@ void ExpectEquality(const ExplodedFrameState& a, const ExplodedFrameState& b) { ...@@ -72,6 +72,7 @@ void ExpectEquality(const ExplodedFrameState& a, const ExplodedFrameState& b) {
EXPECT_EQ(a.target, b.target); EXPECT_EQ(a.target, b.target);
EXPECT_EQ(a.state_object, b.state_object); EXPECT_EQ(a.state_object, b.state_object);
ExpectEquality(a.document_state, b.document_state); ExpectEquality(a.document_state, b.document_state);
EXPECT_EQ(a.pinch_viewport_scroll_offset, b.pinch_viewport_scroll_offset);
EXPECT_EQ(a.scroll_offset, b.scroll_offset); EXPECT_EQ(a.scroll_offset, b.scroll_offset);
EXPECT_EQ(a.item_sequence_number, b.item_sequence_number); EXPECT_EQ(a.item_sequence_number, b.item_sequence_number);
EXPECT_EQ(a.document_sequence_number, b.document_sequence_number); EXPECT_EQ(a.document_sequence_number, b.document_sequence_number);
...@@ -100,6 +101,7 @@ class PageStateSerializationTest : public testing::Test { ...@@ -100,6 +101,7 @@ class PageStateSerializationTest : public testing::Test {
frame_state->document_state.push_back(NS16("q")); frame_state->document_state.push_back(NS16("q"));
frame_state->document_state.push_back(NS16("text")); frame_state->document_state.push_back(NS16("text"));
frame_state->document_state.push_back(NS16("dev.chromium.org")); frame_state->document_state.push_back(NS16("dev.chromium.org"));
frame_state->pinch_viewport_scroll_offset = gfx::PointF(10, 15);
frame_state->scroll_offset = gfx::Point(0, 100); frame_state->scroll_offset = gfx::Point(0, 100);
frame_state->item_sequence_number = 1; frame_state->item_sequence_number = 1;
frame_state->document_sequence_number = 2; frame_state->document_sequence_number = 2;
...@@ -137,6 +139,7 @@ class PageStateSerializationTest : public testing::Test { ...@@ -137,6 +139,7 @@ class PageStateSerializationTest : public testing::Test {
frame_state->referrer_policy = blink::WebReferrerPolicyDefault; frame_state->referrer_policy = blink::WebReferrerPolicyDefault;
if (!is_child) if (!is_child)
frame_state->target = NS16("target"); frame_state->target = NS16("target");
frame_state->pinch_viewport_scroll_offset = gfx::PointF(-1, -1);
frame_state->scroll_offset = gfx::Point(42, -42); frame_state->scroll_offset = gfx::Point(42, -42);
frame_state->item_sequence_number = 123; frame_state->item_sequence_number = 123;
frame_state->document_sequence_number = 456; frame_state->document_sequence_number = 456;
......
...@@ -42,6 +42,7 @@ void RecursivelyRemovePasswordData(ExplodedFrameState* state) { ...@@ -42,6 +42,7 @@ void RecursivelyRemovePasswordData(ExplodedFrameState* state) {
void RecursivelyRemoveScrollOffset(ExplodedFrameState* state) { void RecursivelyRemoveScrollOffset(ExplodedFrameState* state) {
state->scroll_offset = gfx::Point(); state->scroll_offset = gfx::Point();
state->pinch_viewport_scroll_offset = gfx::PointF();
} }
void RecursivelyRemoveReferrer(ExplodedFrameState* state) { void RecursivelyRemoveReferrer(ExplodedFrameState* state) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "content/common/page_state_serialization.h" #include "content/common/page_state_serialization.h"
#include "content/public/common/page_state.h" #include "content/public/common/page_state.h"
#include "content/renderer/history_entry.h" #include "content/renderer/history_entry.h"
#include "third_party/WebKit/public/platform/WebFloatPoint.h"
#include "third_party/WebKit/public/platform/WebHTTPBody.h" #include "third_party/WebKit/public/platform/WebHTTPBody.h"
#include "third_party/WebKit/public/platform/WebPoint.h" #include "third_party/WebKit/public/platform/WebPoint.h"
#include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebString.h"
...@@ -88,6 +89,7 @@ void GenerateFrameStateFromItem(const WebHistoryItem& item, ...@@ -88,6 +89,7 @@ void GenerateFrameStateFromItem(const WebHistoryItem& item,
state->target = item.target(); state->target = item.target();
if (!item.stateObject().isNull()) if (!item.stateObject().isNull())
state->state_object = item.stateObject().toString(); state->state_object = item.stateObject().toString();
state->pinch_viewport_scroll_offset = item.pinchViewportScrollOffset();
state->scroll_offset = item.scrollOffset(); state->scroll_offset = item.scrollOffset();
state->item_sequence_number = item.itemSequenceNumber(); state->item_sequence_number = item.itemSequenceNumber();
state->document_sequence_number = state->document_sequence_number =
...@@ -131,6 +133,7 @@ void RecursivelyGenerateHistoryItem(const ExplodedFrameState& state, ...@@ -131,6 +133,7 @@ void RecursivelyGenerateHistoryItem(const ExplodedFrameState& state,
WebSerializedScriptValue::fromString(state.state_object)); WebSerializedScriptValue::fromString(state.state_object));
} }
item.setDocumentState(state.document_state); item.setDocumentState(state.document_state);
item.setPinchViewportScrollOffset(state.pinch_viewport_scroll_offset);
item.setScrollOffset(state.scroll_offset); item.setScrollOffset(state.scroll_offset);
item.setPageScaleFactor(state.page_scale_factor); item.setPageScaleFactor(state.page_scale_factor);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment