2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "bindings/core/v8/SerializedScriptValue.h"
31 #include "core/CoreExport.h"
32 #include "core/loader/FrameLoaderTypes.h"
33 #include "platform/geometry/FloatPoint.h"
34 #include "platform/geometry/IntPoint.h"
35 #include "platform/heap/Handle.h"
36 #include "platform/weborigin/Referrer.h"
37 #include "wtf/RefCounted.h"
38 #include "wtf/text/WTFString.h"
44 class EncodedFormData
;
46 class ResourceRequest
;
48 class CORE_EXPORT HistoryItem final
: public RefCountedWillBeGarbageCollectedFinalized
<HistoryItem
> {
50 static PassRefPtrWillBeRawPtr
<HistoryItem
> create()
52 return adoptRefWillBeNoop(new HistoryItem
);
56 const String
& urlString() const;
59 const Referrer
& referrer() const;
60 const String
& target() const;
62 EncodedFormData
* formData();
63 const AtomicString
& formContentType() const;
65 const FloatPoint
& visualViewportScrollPoint() const;
66 void setVisualViewportScrollPoint(const FloatPoint
&);
67 const IntPoint
& scrollPoint() const;
68 void setScrollPoint(const IntPoint
&);
70 float pageScaleFactor() const;
71 void setPageScaleFactor(float);
73 Vector
<String
> getReferencedFilePaths();
74 const Vector
<String
>& documentState();
75 void setDocumentState(const Vector
<String
>&);
76 void setDocumentState(DocumentState
*);
77 void clearDocumentState();
79 void setURL(const KURL
&);
80 void setURLString(const String
&);
81 void setReferrer(const Referrer
&);
82 void setTarget(const String
&);
84 void setStateObject(PassRefPtr
<SerializedScriptValue
>);
85 SerializedScriptValue
* stateObject() const { return m_stateObject
.get(); }
87 void setItemSequenceNumber(long long number
) { m_itemSequenceNumber
= number
; }
88 long long itemSequenceNumber() const { return m_itemSequenceNumber
; }
90 void setDocumentSequenceNumber(long long number
) { m_documentSequenceNumber
= number
; }
91 long long documentSequenceNumber() const { return m_documentSequenceNumber
; }
93 void setScrollRestorationType(HistoryScrollRestorationType type
) { m_scrollRestorationType
= type
; }
94 HistoryScrollRestorationType
scrollRestorationType() { return m_scrollRestorationType
; }
96 void setFormInfoFromRequest(const ResourceRequest
&);
97 void setFormData(PassRefPtr
<EncodedFormData
>);
98 void setFormContentType(const AtomicString
&);
100 bool isCurrentDocument(Document
*) const;
111 FloatPoint m_visualViewportScrollPoint
;
112 IntPoint m_scrollPoint
;
113 float m_pageScaleFactor
;
114 Vector
<String
> m_documentStateVector
;
115 RefPtrWillBeMember
<DocumentState
> m_documentState
;
117 // If two HistoryItems have the same item sequence number, then they are
118 // clones of one another. Traversing history from one such HistoryItem to
119 // another is a no-op. HistoryItem clones are created for parent and
120 // sibling frames when only a subframe navigates.
121 int64_t m_itemSequenceNumber
;
123 // If two HistoryItems have the same document sequence number, then they
124 // refer to the same instance of a document. Traversing history from one
125 // such HistoryItem to another preserves the document.
126 int64_t m_documentSequenceNumber
;
128 // Type of the scroll restoration for the history item determines if scroll
129 // position should be restored when it is loaded during history traversal.
130 HistoryScrollRestorationType m_scrollRestorationType
;
132 // Support for HTML5 History
133 RefPtr
<SerializedScriptValue
> m_stateObject
;
135 // info used to repost form data
136 RefPtr
<EncodedFormData
> m_formData
;
137 AtomicString m_formContentType
;
139 }; // class HistoryItem
143 #endif // HISTORYITEM_H