Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: Source/bindings/core/v8/custom/V8HistoryCustom.cpp

Issue 1013823005: Remove custom implementation of History.state attribute getter (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: adjust test expectation Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 24 matching lines...) Expand all
35 #include "bindings/core/v8/SerializedScriptValue.h" 35 #include "bindings/core/v8/SerializedScriptValue.h"
36 #include "bindings/core/v8/SerializedScriptValueFactory.h" 36 #include "bindings/core/v8/SerializedScriptValueFactory.h"
37 #include "bindings/core/v8/V8Binding.h" 37 #include "bindings/core/v8/V8Binding.h"
38 #include "bindings/core/v8/V8HiddenValue.h" 38 #include "bindings/core/v8/V8HiddenValue.h"
39 #include "bindings/core/v8/V8Window.h" 39 #include "bindings/core/v8/V8Window.h"
40 #include "core/dom/ExceptionCode.h" 40 #include "core/dom/ExceptionCode.h"
41 #include "core/frame/History.h" 41 #include "core/frame/History.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 void V8History::stateAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Va lue>& info)
46 {
47 History* history = V8History::toImpl(info.Holder());
48
49 v8::Handle<v8::Value> value = V8HiddenValue::getHiddenValue(info.GetIsolate( ), info.Holder(), V8HiddenValue::state(info.GetIsolate()));
50
51 if (!value.IsEmpty() && !history->stateChanged()) {
52 v8SetReturnValue(info, value);
53 return;
54 }
55
56 RefPtr<SerializedScriptValue> serialized = history->state();
57 value = serialized ? serialized->deserialize(info.GetIsolate()) : v8::Handle <v8::Value>(v8::Null(info.GetIsolate()));
58 V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValu e::state(info.GetIsolate()), value);
59
60 v8SetReturnValue(info, value);
61 }
62
63 void V8History::pushStateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) 45 void V8History::pushStateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
64 { 46 {
65 ExceptionState exceptionState(ExceptionState::ExecutionContext, "pushState", "History", info.Holder(), info.GetIsolate()); 47 ExceptionState exceptionState(ExceptionState::ExecutionContext, "pushState", "History", info.Holder(), info.GetIsolate());
66 RefPtr<SerializedScriptValue> historyState = SerializedScriptValueFactory::i nstance().create(info[0], 0, 0, exceptionState, info.GetIsolate()); 48 RefPtr<SerializedScriptValue> historyState = SerializedScriptValueFactory::i nstance().create(info[0], 0, 0, exceptionState, info.GetIsolate());
67 if (exceptionState.throwIfNeeded()) 49 if (exceptionState.throwIfNeeded())
68 return; 50 return;
69 51
70 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, title, in fo[1]); 52 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, title, in fo[1]);
71 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, url, info [2]); 53 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, url, info [2]);
72 54
(...skipping 13 matching lines...) Expand all
86 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, title, in fo[1]); 68 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, title, in fo[1]);
87 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, url, info [2]); 69 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, url, info [2]);
88 70
89 History* history = V8History::toImpl(info.Holder()); 71 History* history = V8History::toImpl(info.Holder());
90 history->stateObjectAdded(historyState.release(), title, url, FrameLoadTypeR edirectWithLockedBackForwardList, exceptionState); 72 history->stateObjectAdded(historyState.release(), title, url, FrameLoadTypeR edirectWithLockedBackForwardList, exceptionState);
91 V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenV alue::state(info.GetIsolate())); 73 V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenV alue::state(info.GetIsolate()));
92 exceptionState.throwIfNeeded(); 74 exceptionState.throwIfNeeded();
93 } 75 }
94 76
95 } // namespace blink 77 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/webexposed/global-interface-listing-expected.txt ('k') | Source/core/frame/History.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698