Implement UndoManager's item() method
[WebKit-https.git] / Source / WebCore / editing / UndoManager.cpp
index e506424..419de31 100644 (file)
@@ -160,6 +160,17 @@ void UndoManager::redo(ExceptionCode& ec)
     m_redoStack.removeLast();
 }
 
+UndoManagerEntry UndoManager::item(unsigned index) const
+{
+    ASSERT(index < length());
+    if (index < m_redoStack.size()) {
+        UndoManagerEntry entry = *m_redoStack[index];
+        entry.reverse();
+        return entry;
+    }
+    return *m_undoStack[length() - index - 1];
+}
+
 void UndoManager::registerUndoStep(PassRefPtr<UndoStep> step)
 {
     if (!m_isInProgress) {