static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item) { // Original url write_string(v, item->originalURLString()); // Url write_string(v, item->urlString()); // Title write_string(v, item->title()); // Form content type write_string(v, item->formContentType()); // Form data const WebCore::FormData* formData = item->formData(); if (formData) { write_string(v, formData->flattenToString()); // save the identifier as it is not included in the flatten data int64_t id = formData->identifier(); v.append((char*)&id, sizeof(int64_t)); } else write_string(v, WebCore::String()); // Empty constructor does not allocate a buffer. // Target write_string(v, item->target()); AndroidWebHistoryBridge* bridge = item->bridge(); LOG_ASSERT(bridge, "We should have a bridge here!"); // Screen scale const int scale = bridge->scale(); LOGV("Writing scale %d", scale); v.append((char*)&scale, sizeof(int)); const int screenWidthScale = bridge->screenWidthScale(); LOGV("Writing screen width scale %d", screenWidthScale); v.append((char*)&screenWidthScale, sizeof(int)); // Document state const WTF::Vector<WebCore::String>& docState = item->documentState(); WTF::Vector<WebCore::String>::const_iterator end = docState.end(); unsigned stateSize = docState.size(); LOGV("Writing docState %d", stateSize); v.append((char*)&stateSize, sizeof(unsigned)); for (WTF::Vector<WebCore::String>::const_iterator i = docState.begin(); i != end; ++i) { write_string(v, *i); } // Is target item LOGV("Writing isTargetItem %d", item->isTargetItem()); v.append((char)item->isTargetItem()); // Children count unsigned childCount = item->children().size(); LOGV("Writing childCount %d", childCount); v.append((char*)&childCount, sizeof(unsigned)); }
void FrameLoaderClientAndroid::restoreViewState() { WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_frame->view()); HistoryItem* item = m_frame->loader()->history()->currentItem(); AndroidWebHistoryBridge* bridge = item->bridge(); // restore the scale (only) for the top frame if (!m_frame->tree()->parent()) { int scale = bridge->scale(); webViewCore->restoreScale(scale); int screenWidthScale = bridge->screenWidthScale(); if (screenWidthScale != scale) webViewCore->restoreScreenWidthScale(screenWidthScale); } }
static void writeItem(WTF::Vector<char>& vector, WebCore::HistoryItem* item) { // Original url writeString(vector, item->originalURLString()); // Url writeString(vector, item->urlString()); // Title writeString(vector, item->title()); // Form content type writeString(vector, item->formContentType()); // Form data const WebCore::FormData* formData = item->formData(); if (formData) { // write a flag means formData is not null. unsigned flag = FLAG_NOT_NULL; vector.append((char*)&flag, sizeof(unsigned)); //LOGD("Writing Form data if {} Tag"); /*guoxiaolei 20120827 end>*/ writeString(vector, formData->flattenToString()); // save the identifier as it is not included in the flatten data int64_t id = formData->identifier(); //LOGD("Writing the identifier %d ", id); /*guoxiaolei 20120827 end>*/ vector.append((char*)&id, sizeof(int64_t)); } else{ //LOGD("Writing Form data else {} Tag"); //write_string(v, WTF::String()); // Empty constructor does not allocate a buffer. // write a flag means formData is null. unsigned flag = FLAG_IS_NULL; vector.append((char*)&flag, sizeof(unsigned)); } /*guoxiaolei 20120827 end>*/ // Target writeString(vector, item->target()); AndroidWebHistoryBridge* bridge = item->bridge(); ALOG_ASSERT(bridge, "We should have a bridge here!"); // Screen scale const float scale = bridge->scale(); ALOGV("Writing scale %f", scale); vector.append((char*)&scale, sizeof(float)); const float textWrapScale = bridge->textWrapScale(); ALOGV("Writing text wrap scale %f", textWrapScale); vector.append((char*)&textWrapScale, sizeof(float)); // Scroll position. const int scrollX = item->scrollPoint().x(); vector.append((char*)&scrollX, sizeof(int)); const int scrollY = item->scrollPoint().y(); vector.append((char*)&scrollY, sizeof(int)); // Document state const WTF::Vector<WTF::String>& docState = item->documentState(); WTF::Vector<WTF::String>::const_iterator end = docState.end(); unsigned stateSize = docState.size(); ALOGV("Writing docState %d", stateSize); vector.append((char*)&stateSize, sizeof(unsigned)); for (WTF::Vector<WTF::String>::const_iterator i = docState.begin(); i != end; ++i) { writeString(vector, *i); } // Is target item ALOGV("Writing isTargetItem %d", item->isTargetItem()); vector.append((char)item->isTargetItem()); // Children count unsigned childCount = item->children().size(); ALOGV("Writing childCount %d", childCount); vector.append((char*)&childCount, sizeof(unsigned)); }