Changeset 107058 in webkit
- Timestamp:
- Feb 8, 2012 2:39:13 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r107057 r107058 1 2012-02-08 Pablo Flouret <pablof@motorola.com> 2 3 Add state attribute to history's dom interface. 4 https://bugs.webkit.org/show_bug.cgi?id=76035 5 6 Reviewed by Kentaro Hara. 7 8 * fast/dom/Window/window-appendages-cleared-expected.txt: 9 * fast/loader/stateobjects/state-attribute-object-types-expected.txt: Added. 10 * fast/loader/stateobjects/state-attribute-object-types.html: Added. 11 * fast/loader/stateobjects/state-attribute-only-one-deserialization-expected.txt: Added. 12 * fast/loader/stateobjects/state-attribute-only-one-deserialization.html: Added. 13 1 14 2012-02-08 Nikolas Zimmermann <nzimmermann@rim.com> 2 15 -
trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt
r100164 r107058 5 5 PASS history.pushState == "LEFTOVER" is false 6 6 PASS history.replaceState == "LEFTOVER" is false 7 PASS history.state == "LEFTOVER" is false 7 8 PASS location.assign == "LEFTOVER" is false 8 9 PASS location.hash == "LEFTOVER" is false -
trunk/Source/WebCore/ChangeLog
r107057 r107058 1 2012-02-08 Pablo Flouret <pablof@motorola.com> 2 3 Add state attribute to history's dom interface. 4 https://bugs.webkit.org/show_bug.cgi?id=76035 5 6 Reviewed by Kentaro Hara. 7 8 Tests: fast/loader/stateobjects/state-attribute-object-types.html 9 fast/loader/stateobjects/state-attribute-only-one-deserialization.html 10 11 * bindings/js/JSHistoryCustom.cpp: 12 (WebCore::JSHistory::state): 13 (WebCore): 14 (WebCore::JSHistory::pushState): 15 (WebCore::JSHistory::replaceState): 16 * bindings/v8/custom/V8HistoryCustom.cpp: 17 (WebCore::V8History::stateAccessorGetter): 18 (WebCore): 19 (WebCore::V8History::pushStateCallback): 20 (WebCore::V8History::replaceStateCallback): 21 * page/History.cpp: 22 (WebCore::History::History): 23 (WebCore::History::state): 24 (WebCore): 25 (WebCore::History::stateInternal): 26 (WebCore::History::stateChanged): 27 * page/History.h: 28 (History): 29 * page/History.idl: 30 1 31 2012-02-08 Nikolas Zimmermann <nzimmermann@rim.com> 2 32 -
trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp
r106618 r107058 165 165 } 166 166 167 JSValue JSHistory::state(ExecState *exec) const 168 { 169 History* history = static_cast<History*>(impl()); 170 171 JSValue cachedValue = m_state.get(); 172 if (!cachedValue.isEmpty() && !history->stateChanged()) 173 return cachedValue; 174 175 SerializedScriptValue* serialized = history->state(); 176 JSValue result = serialized ? serialized->deserialize(exec, globalObject(), 0) : jsNull(); 177 const_cast<JSHistory*>(this)->m_state.set(exec->globalData(), this, result); 178 return result; 179 } 180 167 181 JSValue JSHistory::pushState(ExecState* exec) 168 182 { … … 186 200 setDOMException(exec, ec); 187 201 202 m_state.clear(); 203 188 204 return jsUndefined(); 189 205 } … … 210 226 setDOMException(exec, ec); 211 227 228 m_state.clear(); 229 212 230 return jsUndefined(); 213 231 } -
trunk/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp
r101118 r107058 42 42 namespace WebCore { 43 43 44 v8::Handle<v8::Value> V8History::stateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 45 { 46 INC_STATS("DOM.History.state"); 47 History* history = V8History::toNative(info.Holder()); 48 49 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("state"); 50 v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); 51 52 if (!value.IsEmpty() && !history->stateChanged()) 53 return value; 54 55 SerializedScriptValue* serialized = history->state(); 56 value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8::Null()); 57 info.Holder()->SetHiddenValue(propertyName, value); 58 59 return value; 60 } 61 44 62 v8::Handle<v8::Value> V8History::pushStateCallback(const v8::Arguments& args) 45 63 { … … 63 81 History* history = V8History::toNative(args.Holder()); 64 82 history->stateObjectAdded(historyState.release(), title, url, History::StateObjectPush, ec); 83 args.Holder()->DeleteHiddenValue(v8::String::NewSymbol("state")); 65 84 return throwError(ec); 66 85 } … … 87 106 History* history = V8History::toNative(args.Holder()); 88 107 history->stateObjectAdded(historyState.release(), title, url, History::StateObjectReplace, ec); 108 args.Holder()->DeleteHiddenValue(v8::String::NewSymbol("state")); 89 109 return throwError(ec); 90 110 } -
trunk/Source/WebCore/page/History.cpp
r104380 r107058 43 43 History::History(Frame* frame) 44 44 : DOMWindowProperty(frame) 45 , m_lastStateObjectRequested(0) 45 46 { 46 47 } … … 53 54 return 0; 54 55 return m_frame->page()->backForward()->count(); 56 } 57 58 SerializedScriptValue* History::state() 59 { 60 m_lastStateObjectRequested = stateInternal(); 61 return m_lastStateObjectRequested; 62 } 63 64 SerializedScriptValue* History::stateInternal() const 65 { 66 if (!m_frame) 67 return 0; 68 69 if (HistoryItem* historyItem = m_frame->loader()->history()->currentItem()) 70 return historyItem->stateObject(); 71 72 return 0; 73 } 74 75 bool History::stateChanged() const 76 { 77 return m_lastStateObjectRequested != stateInternal(); 55 78 } 56 79 -
trunk/Source/WebCore/page/History.h
r104380 r107058 45 45 46 46 unsigned length() const; 47 SerializedScriptValue* state(); 48 bool stateChanged() const; 47 49 void back(); 48 50 void forward(); … … 63 65 64 66 KURL urlForState(const String& url); 67 68 SerializedScriptValue* stateInternal() const; 69 70 SerializedScriptValue* m_lastStateObjectRequested; 65 71 }; 66 72 -
trunk/Source/WebCore/page/History.idl
r107051 r107058 38 38 ] History { 39 39 readonly attribute unsigned long length; 40 readonly attribute [CachedAttribute, Custom] SerializedScriptValue state; 40 41 41 42 [DoNotCheckDomainSecurity, CallWith=ScriptExecutionContext] void back();
Note: See TracChangeset
for help on using the changeset viewer.