[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

weinig at apple.com weinig at apple.com
Wed Dec 22 15:38:46 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 3443fd3e30bcc505306c7cdb3d9f5ee4ff3621e6
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 9 22:22:47 2010 +0000

    Need WebKit2 mechanism for getting the visible page text
    <rdar://problem/8646928>
    https://bugs.webkit.org/show_bug.cgi?id=49275
    
    Reviewed by Anders Carlsson.
    
    WebCore:
    
    * WebCore.exp.in: Add necessary exports.
    
    WebKit2:
    
    * UIProcess/API/C/WKPage.cpp:
    (WKPageGetContentsAsString):
    (callContentsAsStringBlockBlockAndDispose):
    (WKPageGetContentsAsString_b):
    * UIProcess/API/C/WKPage.h:
    Add GetContentsAsString callback function declaration and forwarding.
    
    * UIProcess/WebPageProxy.cpp:
    (WebKit::invalidateCallbackMap):
    (WebKit::WebPageProxy::close):
    (WebKit::WebPageProxy::getContentsAsString):
    (WebKit::WebPageProxy::didGetContentsAsString):
    (WebKit::WebPageProxy::processDidCrash):
    * UIProcess/WebPageProxy.h:
    Add GetContentsAsString callback and generalize invalidating the callback
    maps into a standalone function.
    
    * UIProcess/WebPageProxy.messages.in:
    Add DidGetContentsAsString return message.
    
    * WebProcess/WebPage/WebFrame.h:
    * WebProcess/WebPage/WebFrame.cpp:
    (WebKit::WebFrame::contentsAsString):
    Gets the string content of all the subframes.
    
    (WebKit::WebFrame::isFrameSet):
    Call through to the document.
    
    * WebProcess/WebPage/WebPage.h:
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::getContentsAsString):
    Forward to the the main frames contentsAsString function.
    
    * WebProcess/WebPage/WebPage.messages.in:
    Add GetContentsAsString and collect all callback messages together.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71678 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c7fd8b4..e0a979e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+2010-11-09  Sam Weinig  <sam at webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Need WebKit2 mechanism for getting the visible page text
+        <rdar://problem/8646928>
+        https://bugs.webkit.org/show_bug.cgi?id=49275
+
+        * WebCore.exp.in: Add necessary exports.
+
 2010-11-09  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by James Robinson.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index 7ac3035..18cc68b 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -200,8 +200,8 @@ __ZN7WebCore11HistoryItemC1ERKN3WTF6StringES4_d
 __ZN7WebCore11HistoryItemC1ERKNS_4KURLERKN3WTF6StringES7_S7_
 __ZN7WebCore11HistoryItemC1Ev
 __ZN7WebCore11HistoryItemD1Ev
-__ZN7WebCore11MemoryCache13getStatisticsEv
 __ZN7WebCore11MemoryCache11setDisabledEb
+__ZN7WebCore11MemoryCache13getStatisticsEv
 __ZN7WebCore11MemoryCache13setCapacitiesEjjj
 __ZN7WebCore11RenderLayer19scrollRectToVisibleERKNS_7IntRectEbRKNS_15ScrollAlignmentES6_
 __ZN7WebCore11globalPointERK8_NSPointP8NSWindow
@@ -479,10 +479,10 @@ __ZN7WebCore20ResourceResponseBaseC2Ev
 __ZN7WebCore20SpaceSplitStringData12createVectorEv
 __ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE
 __ZN7WebCore21BackForwardController11itemAtIndexEi
-__ZN7WebCore21ResourceLoadScheduler20servePendingRequestsENS0_8PriorityE
-__ZN7WebCore21ResourceLoadScheduler24schedulePluginStreamLoadEPNS_5FrameEPNS_32NetscapePlugInStreamLoaderClientERKNS_15ResourceRequestE
 __ZN7WebCore21PlatformKeyboardEvent24disambiguateKeyDownEventENS0_4TypeEb
 __ZN7WebCore21PlatformKeyboardEventC1EP7NSEvent
+__ZN7WebCore21ResourceLoadScheduler20servePendingRequestsENS0_8PriorityE
+__ZN7WebCore21ResourceLoadScheduler24schedulePluginStreamLoadEPNS_5FrameEPNS_32NetscapePlugInStreamLoaderClientERKNS_15ResourceRequestE
 __ZN7WebCore21SVGDocumentExtensions21sampleAnimationAtTimeERKN3WTF6StringEPNS_14SVGSMILElementEd
 __ZN7WebCore21SerializedScriptValue11deserializeEPK15OpaqueJSContextPPK13OpaqueJSValue
 __ZN7WebCore21SerializedScriptValue6createEPK15OpaqueJSContextPK13OpaqueJSValuePS6_
@@ -649,6 +649,7 @@ __ZN7WebCore5Frame9scalePageEf
 __ZN7WebCore5FrameD1Ev
 __ZN7WebCore5Image12supportsTypeERKN3WTF6StringE
 __ZN7WebCore5Image20loadPlatformResourceEPKc
+__ZN7WebCore5Range10selectNodeEPNS_4NodeERi
 __ZN7WebCore5Range6createEN3WTF10PassRefPtrINS_8DocumentEEENS2_INS_4NodeEEEiS6_i
 __ZN7WebCore5Range6setEndEN3WTF10PassRefPtrINS_4NodeEEEiRi
 __ZN7WebCore5Range8setStartEN3WTF10PassRefPtrINS_4NodeEEEiRi
@@ -903,6 +904,7 @@ __ZN7WebCore9closeFileERi
 __ZN7WebCore9fontCacheEv
 __ZN7WebCore9makeRangeERKNS_15VisiblePositionES2_
 __ZN7WebCore9pageCacheEv
+__ZN7WebCore9plainTextEPKNS_5RangeENS_20TextIteratorBehaviorE
 __ZN7WebCore9toElementEN3JSC7JSValueE
 __ZNK3JSC8Bindings10RootObject12globalObjectEv
 __ZNK3WTF6String14createCFStringEv
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index b369f8b..ca91642 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,49 @@
 2010-11-09  Sam Weinig  <sam at webkit.org>
 
+        Reviewed by Anders Carlsson.
+
+        Need WebKit2 mechanism for getting the visible page text
+        <rdar://problem/8646928>
+        https://bugs.webkit.org/show_bug.cgi?id=49275
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageGetContentsAsString):
+        (callContentsAsStringBlockBlockAndDispose):
+        (WKPageGetContentsAsString_b):
+        * UIProcess/API/C/WKPage.h:
+        Add GetContentsAsString callback function declaration and forwarding.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::invalidateCallbackMap):
+        (WebKit::WebPageProxy::close):
+        (WebKit::WebPageProxy::getContentsAsString):
+        (WebKit::WebPageProxy::didGetContentsAsString):
+        (WebKit::WebPageProxy::processDidCrash):
+        * UIProcess/WebPageProxy.h:
+        Add GetContentsAsString callback and generalize invalidating the callback
+        maps into a standalone function.
+
+        * UIProcess/WebPageProxy.messages.in:
+        Add DidGetContentsAsString return message.
+
+        * WebProcess/WebPage/WebFrame.h:
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::contentsAsString):
+        Gets the string content of all the subframes.
+
+        (WebKit::WebFrame::isFrameSet):
+        Call through to the document.
+
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::getContentsAsString):
+        Forward to the the main frames contentsAsString function.
+
+        * WebProcess/WebPage/WebPage.messages.in:
+        Add GetContentsAsString and collect all callback messages together.
+
+2010-11-09  Sam Weinig  <sam at webkit.org>
+
         Fix mac build.
 
         * WebProcess/mac/WebProcessMac.mm:
diff --git a/WebKit2/UIProcess/API/C/WKPage.cpp b/WebKit2/UIProcess/API/C/WKPage.cpp
index 4b014cd..5fe0206 100644
--- a/WebKit2/UIProcess/API/C/WKPage.cpp
+++ b/WebKit2/UIProcess/API/C/WKPage.cpp
@@ -329,3 +329,22 @@ void WKPageGetSourceForFrame_b(WKPageRef pageRef, WKFrameRef frameRef, WKPageGet
     WKPageGetSourceForFrame(pageRef, frameRef, Block_copy(block), callGetSourceForFrameBlockBlockAndDispose);
 }
 #endif
+
+void WKPageGetContentsAsString(WKPageRef pageRef, void *context, WKPageGetContentsAsStringFunction callback)
+{
+    toImpl(pageRef)->getContentsAsString(ContentsAsStringCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callContentsAsStringBlockBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
+{
+    WKPageGetContentsAsStringBlock block = (WKPageGetContentsAsStringBlock)context;
+    block(resultValue, error);
+    Block_release(block);
+}
+
+void WKPageGetContentsAsString_b(WKPageRef pageRef, WKPageGetSourceForFrameBlock block)
+{
+    WKPageGetContentsAsString(pageRef, Block_copy(block), callContentsAsStringBlockBlockAndDispose);
+}
+#endif
diff --git a/WebKit2/UIProcess/API/C/WKPage.h b/WebKit2/UIProcess/API/C/WKPage.h
index 86e58fe..d7c96d6 100644
--- a/WebKit2/UIProcess/API/C/WKPage.h
+++ b/WebKit2/UIProcess/API/C/WKPage.h
@@ -282,19 +282,26 @@ WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClient* clien
 WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClient* client);
 
 typedef void (*WKPageRunJavaScriptFunction)(WKStringRef, WKErrorRef, void*);
-WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void *context, WKPageRunJavaScriptFunction function);
+WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function);
 #ifdef __BLOCKS__
 typedef void (^WKPageRunJavaScriptBlock)(WKStringRef, WKErrorRef);
 WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block);
 #endif
 
 typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*);
-WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void *context, WKPageGetSourceForFrameFunction function);
+WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function);
 #ifdef __BLOCKS__
 typedef void (^WKPageGetSourceForFrameBlock)(WKStringRef, WKErrorRef);
 WK_EXPORT void WKPageGetSourceForFrame_b(WKPageRef page, WKFrameRef frame, WKPageGetSourceForFrameBlock block);
 #endif
 
+typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*);
+WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function);
+#ifdef __BLOCKS__
+typedef void (^WKPageGetContentsAsStringBlock)(WKStringRef, WKErrorRef);
+WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsStringBlock block);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/WebKit2/UIProcess/WebPageProxy.cpp b/WebKit2/UIProcess/WebPageProxy.cpp
index 3ce925a..68dbbf5 100644
--- a/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/WebKit2/UIProcess/WebPageProxy.cpp
@@ -70,6 +70,16 @@ namespace WebKit {
 static WTF::RefCountedLeakCounter webPageProxyCounter("WebPageProxy");
 #endif
 
+template<typename T>
+void invalidateCallbackMap(HashMap<uint64_t, RefPtr<T> >& map)
+{
+    Vector<RefPtr<T> > callbacksVector;
+    copyValuesToVector(map, callbacksVector);
+    for (size_t i = 0, size = callbacksVector.size(); i < size; ++i)
+        callbacksVector[i]->invalidate();
+    map.clear();
+}
+
 PassRefPtr<WebPageProxy> WebPageProxy::create(WebPageNamespace* pageNamespace, uint64_t pageID)
 {
     return adoptRef(new WebPageProxy(pageNamespace, pageID));
@@ -202,23 +212,10 @@ void WebPageProxy::close()
     m_pageTitle = String();
     m_toolTip = String();
 
-    Vector<RefPtr<ScriptReturnValueCallback> > scriptReturnValueCallbacks;
-    copyValuesToVector(m_scriptReturnValueCallbacks, scriptReturnValueCallbacks);
-    for (size_t i = 0, size = scriptReturnValueCallbacks.size(); i < size; ++i)
-        scriptReturnValueCallbacks[i]->invalidate();
-    m_scriptReturnValueCallbacks.clear();
-
-    Vector<RefPtr<RenderTreeExternalRepresentationCallback> > renderTreeExternalRepresentationCallbacks;
-    copyValuesToVector(m_renderTreeExternalRepresentationCallbacks, renderTreeExternalRepresentationCallbacks);
-    for (size_t i = 0, size = renderTreeExternalRepresentationCallbacks.size(); i < size; ++i)
-        renderTreeExternalRepresentationCallbacks[i]->invalidate();
-    m_renderTreeExternalRepresentationCallbacks.clear();
-
-    Vector<RefPtr<FrameSourceCallback> > frameSourceCallbacks;
-    copyValuesToVector(m_frameSourceCallbacks, frameSourceCallbacks);
-    m_frameSourceCallbacks.clear();
-    for (size_t i = 0, size = frameSourceCallbacks.size(); i < size; ++i)
-        frameSourceCallbacks[i]->invalidate();
+    invalidateCallbackMap(m_contentsAsStringCallbacks);
+    invalidateCallbackMap(m_frameSourceCallbacks);
+    invalidateCallbackMap(m_renderTreeExternalRepresentationCallbacks);
+    invalidateCallbackMap(m_scriptReturnValueCallbacks);
 
     Vector<WebEditCommandProxy*> editCommandVector;
     copyToVector(m_editCommandSet, editCommandVector);
@@ -588,6 +585,14 @@ void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<FrameSourc
     process()->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
 }
 
+void WebPageProxy::getContentsAsString(PassRefPtr<ContentsAsStringCallback> prpCallback)
+{
+    RefPtr<ContentsAsStringCallback> callback = prpCallback;
+    uint64_t callbackID = callback->callbackID();
+    m_contentsAsStringCallbacks.set(callbackID, callback.get());
+    process()->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
+}
+
 void WebPageProxy::preferencesDidChange()
 {
     if (!isValid())
@@ -1235,6 +1240,17 @@ void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
     m_uiClient.didNotHandleKeyEvent(this, event);
 }
 
+void WebPageProxy::didGetContentsAsString(const String& resultString, uint64_t callbackID)
+{
+    RefPtr<ContentsAsStringCallback> callback = m_contentsAsStringCallbacks.take(callbackID);
+    if (!callback) {
+        // FIXME: Log error or assert.
+        return;
+    }
+
+    callback->performCallbackWithReturnValue(resultString.impl());
+}
+
 void WebPageProxy::didRunJavaScriptInMainFrame(const String& resultString, uint64_t callbackID)
 {
     RefPtr<ScriptReturnValueCallback> callback = m_scriptReturnValueCallbacks.take(callbackID);
@@ -1315,23 +1331,10 @@ void WebPageProxy::processDidCrash()
     m_pageTitle = String();
     m_toolTip = String();
 
-    Vector<RefPtr<ScriptReturnValueCallback> > scriptReturnValueCallbacks;
-    copyValuesToVector(m_scriptReturnValueCallbacks, scriptReturnValueCallbacks);
-    for (size_t i = 0, size = scriptReturnValueCallbacks.size(); i < size; ++i)
-        scriptReturnValueCallbacks[i]->invalidate();
-    m_scriptReturnValueCallbacks.clear();
-
-    Vector<RefPtr<RenderTreeExternalRepresentationCallback> > renderTreeExternalRepresentationCallbacks;
-    copyValuesToVector(m_renderTreeExternalRepresentationCallbacks, renderTreeExternalRepresentationCallbacks);
-    for (size_t i = 0, size = renderTreeExternalRepresentationCallbacks.size(); i < size; ++i)
-        renderTreeExternalRepresentationCallbacks[i]->invalidate();
-    m_renderTreeExternalRepresentationCallbacks.clear();
-
-    Vector<RefPtr<FrameSourceCallback> > frameSourceCallbacks;
-    copyValuesToVector(m_frameSourceCallbacks, frameSourceCallbacks);
-    m_frameSourceCallbacks.clear();
-    for (size_t i = 0, size = frameSourceCallbacks.size(); i < size; ++i)
-        frameSourceCallbacks[i]->invalidate();
+    invalidateCallbackMap(m_contentsAsStringCallbacks);
+    invalidateCallbackMap(m_frameSourceCallbacks);
+    invalidateCallbackMap(m_renderTreeExternalRepresentationCallbacks);
+    invalidateCallbackMap(m_scriptReturnValueCallbacks);
 
     Vector<WebEditCommandProxy*> editCommandVector;
     copyToVector(m_editCommandSet, editCommandVector);
diff --git a/WebKit2/UIProcess/WebPageProxy.h b/WebKit2/UIProcess/WebPageProxy.h
index 83ca536..f86f013 100644
--- a/WebKit2/UIProcess/WebPageProxy.h
+++ b/WebKit2/UIProcess/WebPageProxy.h
@@ -96,6 +96,7 @@ struct WebPopupItem;
 typedef GenericCallback<WKStringRef, StringImpl*> FrameSourceCallback;
 typedef GenericCallback<WKStringRef, StringImpl*> RenderTreeExternalRepresentationCallback;
 typedef GenericCallback<WKStringRef, StringImpl*> ScriptReturnValueCallback;
+typedef GenericCallback<WKStringRef, StringImpl*> ContentsAsStringCallback;
 
 class WebPageProxy : public APIObject {
 public:
@@ -201,6 +202,7 @@ public:
     void runJavaScriptInMainFrame(const String&, PassRefPtr<ScriptReturnValueCallback>);
     void getRenderTreeExternalRepresentation(PassRefPtr<RenderTreeExternalRepresentationCallback>);
     void getSourceForFrame(WebFrameProxy*, PassRefPtr<FrameSourceCallback>);
+    void getContentsAsString(PassRefPtr<ContentsAsStringCallback>);
 
     void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy*, uint64_t listenerID);
 
@@ -341,6 +343,7 @@ private:
     
     void didReceiveEvent(uint32_t opaqueType, bool handled);
 
+    void didGetContentsAsString(const String&, uint64_t);
     void didRunJavaScriptInMainFrame(const String&, uint64_t);
     void didGetRenderTreeExternalRepresentation(const String&, uint64_t);
     void didGetSourceForFrame(const String&, uint64_t);
@@ -370,9 +373,10 @@ private:
 
     RefPtr<WebInspectorProxy> m_inspector;
 
-    HashMap<uint64_t, RefPtr<ScriptReturnValueCallback> > m_scriptReturnValueCallbacks;
-    HashMap<uint64_t, RefPtr<RenderTreeExternalRepresentationCallback> > m_renderTreeExternalRepresentationCallbacks;
+    HashMap<uint64_t, RefPtr<ContentsAsStringCallback> > m_contentsAsStringCallbacks;
     HashMap<uint64_t, RefPtr<FrameSourceCallback> > m_frameSourceCallbacks;
+    HashMap<uint64_t, RefPtr<RenderTreeExternalRepresentationCallback> > m_renderTreeExternalRepresentationCallbacks;
+    HashMap<uint64_t, RefPtr<ScriptReturnValueCallback> > m_scriptReturnValueCallbacks;
 
     HashSet<WebEditCommandProxy*> m_editCommandSet;
 
diff --git a/WebKit2/UIProcess/WebPageProxy.messages.in b/WebKit2/UIProcess/WebPageProxy.messages.in
index 1065432..d116d6c 100644
--- a/WebKit2/UIProcess/WebPageProxy.messages.in
+++ b/WebKit2/UIProcess/WebPageProxy.messages.in
@@ -92,6 +92,7 @@ messages -> WebPageProxy {
     WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData)
 
     # Callback messages.
+    DidGetContentsAsString(WTF::String resultString, uint64_t callbackID)
     DidGetRenderTreeExternalRepresentation(WTF::String resultString, uint64_t callbackID)
     DidGetSourceForFrame(WTF::String resultString, uint64_t callbackID)
     DidRunJavaScriptInMainFrame(WTF::String resultString, uint64_t callbackID)
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.cpp b/WebKit2/WebProcess/WebPage/WebFrame.cpp
index 10e1036..40094f5 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.cpp
+++ b/WebKit2/WebProcess/WebPage/WebFrame.cpp
@@ -47,7 +47,9 @@
 #include <WebCore/JSRange.h>
 #include <WebCore/Page.h>
 #include <WebCore/RenderTreeAsText.h>
+#include <WebCore/TextIterator.h>
 #include <WebCore/TextResourceDecoder.h>
+#include <wtf/text/StringBuilder.h>
 
 #ifndef NDEBUG
 #include <wtf/RefCountedLeakCounter.h>
@@ -234,6 +236,53 @@ String WebFrame::source() const
     return decoder->encoding().decode(mainResourceData->data(), mainResourceData->size());
 }
 
+String WebFrame::contentsAsString() const 
+{
+    if (!m_coreFrame)
+        return String();
+
+    if (isFrameSet()) {
+        StringBuilder builder;
+        for (Frame* child = m_coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
+            WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(child->loader()->client())->webFrame();
+            builder.append(webFrame->contentsAsString());
+            if (child->tree()->nextSibling())
+                builder.append(' ');
+        }
+        
+        // FIXME: It may make sense to use toStringPreserveCapacity() here.
+        return builder.toString();
+    }
+
+    Document* document = m_coreFrame->document();
+    if (!document)
+        return String();
+
+    RefPtr<Element> documentElement = document->documentElement();
+    if (!documentElement)
+        return String();
+
+    RefPtr<Range> range = document->createRange();
+
+    ExceptionCode ec = 0;
+    range->selectNode(documentElement.get(), ec);
+    if (ec)
+        return String();
+
+    return plainText(range.get());
+}
+
+bool WebFrame::isFrameSet() const
+{
+    if (!m_coreFrame)
+        return false;
+
+    Document* document = m_coreFrame->document();
+    if (!document)
+        return false;
+    return document->isFrameSet();
+}
+
 bool WebFrame::isMainFrame() const
 {
     if (WebPage* p = page())
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.h b/WebKit2/WebProcess/WebPage/WebFrame.h
index f919d4b..8986e4a 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.h
+++ b/WebKit2/WebProcess/WebPage/WebFrame.h
@@ -72,6 +72,7 @@ public:
     void startDownload(const WebCore::ResourceRequest&);
 
     String source() const;
+    String contentsAsString() const;
 
     // WKBundleFrame API and SPI functions
     bool isMainFrame() const;
@@ -116,6 +117,8 @@ private:
 
     virtual Type type() const { return APIType; }
 
+    bool isFrameSet() const;
+
     WebCore::Frame* m_coreFrame;
 
     uint64_t m_policyListenerID;
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index b5fdea7..241145e 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -762,6 +762,12 @@ void WebPage::runJavaScriptInMainFrame(const String& script, uint64_t callbackID
     send(Messages::WebPageProxy::DidRunJavaScriptInMainFrame(resultString, callbackID));
 }
 
+void WebPage::getContentsAsString(uint64_t callbackID)
+{
+    String resultString = m_mainFrame->contentsAsString();
+    send(Messages::WebPageProxy::DidGetContentsAsString(resultString, callbackID));
+}
+
 void WebPage::getRenderTreeExternalRepresentation(uint64_t callbackID)
 {
     String resultString = renderTreeExternalRepresentation();
diff --git a/WebKit2/WebProcess/WebPage/WebPage.h b/WebKit2/WebProcess/WebPage/WebPage.h
index fad5053..bc0640e 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/WebKit2/WebProcess/WebPage/WebPage.h
@@ -233,9 +233,11 @@ private:
 #if ENABLE(TOUCH_EVENTS)
     void touchEvent(const WebTouchEvent&);
 #endif
-    void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
+
+    void getContentsAsString(uint64_t callbackID);
     void getRenderTreeExternalRepresentation(uint64_t callbackID);
     void getSourceForFrame(uint64_t frameID, uint64_t callbackID);
+    void runJavaScriptInMainFrame(const String&, uint64_t callbackID);
 
     void preferencesDidChange(const WebPreferencesStore&);
     void platformPreferencesDidChange(const WebPreferencesStore&);
diff --git a/WebKit2/WebProcess/WebPage/WebPage.messages.in b/WebKit2/WebProcess/WebPage/WebPage.messages.in
index 8a783db..af07dcc 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.messages.in
+++ b/WebKit2/WebProcess/WebPage/WebPage.messages.in
@@ -45,13 +45,14 @@ messages -> WebPage {
 
     DidReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID)
 
+    # Callbacks.
     GetRenderTreeExternalRepresentation(uint64_t callbackID)
-
+    GetContentsAsString(uint64_t callbackID)
     GetSourceForFrame(uint64_t frameID, uint64_t callbackID)
+    RunJavaScriptInMainFrame(WTF::String script, uint64_t callbackID)
 
-    PreferencesDidChange(WebKit::WebPreferencesStore store)
 
-    RunJavaScriptInMainFrame(WTF::String script, uint64_t callbackID)
+    PreferencesDidChange(WebKit::WebPreferencesStore store)
 
     SetCustomUserAgent(WTF::String customUserAgent)
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list