QString DumpRenderTree::dumpBackForwardList(QWebPage* page) { QWebHistory* history = page->history(); QString result; result.append(QLatin1String("\n============== Back Forward List ==============\n")); // FORMAT: // " (file test):fast/loader/resources/click-fragment-link.html **nav target**" // "curr-> (file test):fast/loader/resources/click-fragment-link.html#testfragment **nav target**" int maxItems = history->maximumItemCount(); foreach (const QWebHistoryItem item, history->backItems(maxItems)) { if (!item.isValid()) continue; result.append(dumpHistoryItem(item, 8, false)); } QWebHistoryItem item = history->currentItem(); if (item.isValid()) result.append(dumpHistoryItem(item, 8, true)); foreach (const QWebHistoryItem item, history->forwardItems(maxItems)) { if (!item.isValid()) continue; result.append(dumpHistoryItem(item, 8, false)); } result.append(QLatin1String("===============================================\n")); return result; }
static String dumpBackForwardListForWebView() { String result = "\n============== Back Forward List ==============\n"; // FORMAT: // " (file test):fast/loader/resources/click-fragment-link.html **nav target**" // "curr-> (file test):fast/loader/resources/click-fragment-link.html#testfragment **nav target**" WebCore::BackForwardListBlackBerry* bfList = static_cast<WebCore::BackForwardListBlackBerry*>(mainFrame->page()->backForward()->client()); int maxItems = bfList->capacity(); WebCore::HistoryItemVector entries; bfList->backListWithLimit(maxItems, entries); unsigned resultSize = entries.size(); for (unsigned i = 0; i < resultSize; ++i) result = result + dumpHistoryItem(entries[i], 8, false); result = result + dumpHistoryItem(bfList->currentItem(), 8, true); bfList->forwardListWithLimit(maxItems, entries); resultSize = entries.size(); for (unsigned i = 0; i < resultSize; ++i) result = result + dumpHistoryItem(entries[i], 8, false); result = result + "===============================================\n"; return result; }
static String dumpHistoryItem(PassRefPtr<WebCore::HistoryItem> item, int indent, bool current) { String result; int start = 0; if (current) { result = result + "curr->"; start = 6; } for (int i = start; i < indent; i++) result = result + " "; String url = item->urlString(); if (url.contains("file://")) { static String layoutTestsString("/LayoutTests/"); static String fileTestString("(file test):"); String res = url.substring(url.find(layoutTestsString) + layoutTestsString.length()); if (res.isEmpty()) return result; result = result + fileTestString; result = result + res; } else result = result + url; String target = item->target(); if (!target.isEmpty()) result = result + " (in frame \"" + target + "\")"; if (item->isTargetItem()) result = result + " **nav target**"; result = result + "\n"; WebCore::HistoryItemVector children = item->children(); // Must sort to eliminate arbitrary result ordering which defeats reproducible testing. nonCopyingSort(children.begin(), children.end(), historyItemCompare); unsigned resultSize = children.size(); for (unsigned i = 0; i < resultSize; ++i) result = result + dumpHistoryItem(children[i], indent + 4, false); return result; }
static QString dumpHistoryItem(const QWebHistoryItem& item, int indent, bool current) { QString result; int start = 0; if (current) { result.append(QLatin1String("curr->")); start = 6; } for (int i = start; i < indent; i++) result.append(' '); QString url = item.url().toEncoded(); if (url.contains("file://")) { static QString layoutTestsString("/LayoutTests/"); static QString fileTestString("(file test):"); QString res = url.mid(url.indexOf(layoutTestsString) + layoutTestsString.length()); if (res.isEmpty()) return result; result.append(fileTestString); result.append(res); } else { result.append(url); } QString target = DumpRenderTreeSupportQt::historyItemTarget(item); if (!target.isEmpty()) result.append(QString(QLatin1String(" (in frame \"%1\")")).arg(target)); if (DumpRenderTreeSupportQt::isTargetItem(item)) result.append(QLatin1String(" **nav target**")); result.append(QLatin1String("\n")); QMap<QString, QWebHistoryItem> children = DumpRenderTreeSupportQt::getChildHistoryItems(item); foreach (QWebHistoryItem item, children) result += dumpHistoryItem(item, 12, false); return result; }