Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (124789 => 124790)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-08-06 18:42:04 UTC (rev 124790)
@@ -1,3 +1,39 @@
+2012-08-06 Nasko Oskov <[email protected]>
+
+ Adding APIs to Chromium WebKit API to allow for creating and monitoring frame hierarchy.
+ https://bugs.webkit.org/show_bug.cgi?id=93127
+
+ Reviewed by Adam Barth.
+
+ Add support in the API to monitor and create frame hierarchy to allow replicating it
+ across different instances of WebKit.
+
+ * public/WebDocument.h:
+ (WebDocument): Added createElement.
+ * public/WebFrame.h: Added assignedName.
+ * public/WebFrameClient.h:
+ (WebFrameClient):
+ (WebKit::WebFrameClient::didCreateFrame): Added to allow embedders to know when frames are created.
+ (WebKit::WebFrameClient::willCheckAndDispatchMessageEvent): Added the target frame as a parameter.
+ * public/WebNode.h:
+ * src/FrameLoaderClientImpl.cpp:
+ (WebKit::FrameLoaderClientImpl::willCheckAndDispatchMessageEvent):
+ * src/WebDocument.cpp:
+ (WebKit::WebDocument::createElement): Added to allow for creating frame elements.
+ (WebKit):
+ * src/WebFrameImpl.cpp:
+ (WebKit::WebFrameImpl::uniqueName): Added to migrate callers to the matching WebCore API.
+ (WebKit):
+ (WebKit::WebFrameImpl::assignedName): Returns the name given to a frame, as opposed
+ to the unique name, generated by WebKit.
+ (WebKit::WebFrameImpl::createChildFrame): Added call to the frame client's didCreateFrame.
+ * src/WebFrameImpl.h:
+ (WebFrameImpl):
+ * src/WebNode.cpp:
+ (WebKit::WebNode::appendChild): Added to allow for adding elements to the DOM.
+ (WebKit):
+ * tests/WebFrameTest.cpp:
+
2012-08-06 David Reveman <[email protected]>
[Chromium] Refactor CCTextureUpdater into CCTextureUpdater and CCTextureUpdateController.
Modified: trunk/Source/WebKit/chromium/public/WebDocument.h (124789 => 124790)
--- trunk/Source/WebKit/chromium/public/WebDocument.h 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/public/WebDocument.h 2012-08-06 18:42:04 UTC (rev 124790)
@@ -105,6 +105,7 @@
WEBKIT_EXPORT WebElement fullScreenElement() const;
WEBKIT_EXPORT WebDOMEvent createEvent(const WebString& eventType);
WEBKIT_EXPORT WebReferrerPolicy referrerPolicy() const;
+ WEBKIT_EXPORT WebElement createElement(const WebString& tagName);
// Accessibility support. These methods should only be called on the
// top-level document, because one accessibility cache spans all of
Modified: trunk/Source/WebKit/chromium/public/WebFrame.h (124789 => 124790)
--- trunk/Source/WebKit/chromium/public/WebFrame.h 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/public/WebFrame.h 2012-08-06 18:42:04 UTC (rev 124790)
@@ -135,6 +135,16 @@
// The name of this frame.
virtual WebString name() const = 0;
+ // The unique name of this frame.
+ //
+ // This is temporarily identical to the above name() function. Once this
+ // change makes it over to the Chromium tree, I will change all callers to
+ // use this function and will subsequently move assignedName() to name().
+ virtual WebString uniqueName() const = 0;
+
+ // The name of this frame. If no name is given, empty string is returned.
+ virtual WebString assignedName() const = 0;
+
// Sets the name of this frame. For child frames (frames that are not a
// top-most frame) the actual name may have a suffix appended to make the
// frame name unique within the hierarchy.
Modified: trunk/Source/WebKit/chromium/public/WebFrameClient.h (124789 => 124790)
--- trunk/Source/WebKit/chromium/public/WebFrameClient.h 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/public/WebFrameClient.h 2012-08-06 18:42:04 UTC (rev 124790)
@@ -93,7 +93,7 @@
// May return null.
virtual WebApplicationCacheHost* createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient*) { return 0; }
-
+
// Services ------------------------------------------------------------
// A frame specific cookie jar. May return null, in which case
@@ -103,13 +103,15 @@
// General notifications -----------------------------------------------
- // This frame has been detached from the view.
- //
- // FIXME: Do not use this in new code. Currently this is used by code in
- // Chromium that errantly caches WebKit objects.
+ // A child frame was created in this frame. This is called when the frame
+ // is created and initialized.
+ virtual void didCreateFrame(WebFrame* parent, WebFrame* child) { }
+
+ // This frame has been detached from the view, but has not been closed yet.
virtual void frameDetached(WebFrame*) { }
- // This frame is about to be closed.
+ // This frame is about to be closed. This is called after frameDetached,
+ // when the document is being unloaded, due to new one committing.
virtual void willClose(WebFrame*) { }
// Load commands -------------------------------------------------------
@@ -406,6 +408,15 @@
WebSecurityOrigin target,
WebDOMMessageEvent) { return false; }
+ virtual bool willCheckAndDispatchMessageEvent(
+ WebFrame* sourceFrame,
+ WebFrame* targetFrame,
+ WebSecurityOrigin target,
+ WebDOMMessageEvent event)
+ {
+ return willCheckAndDispatchMessageEvent(sourceFrame, target, event);
+ }
+
// Asks the embedder if a specific user agent should be used for the given
// URL. Non-empty strings indicate an override should be used. Otherwise,
// WebKitPlatformSupport::userAgent() will be called to provide one.
Modified: trunk/Source/WebKit/chromium/public/WebNode.h (124789 => 124790)
--- trunk/Source/WebKit/chromium/public/WebNode.h 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/public/WebNode.h 2012-08-06 18:42:04 UTC (rev 124790)
@@ -98,6 +98,7 @@
WEBKIT_EXPORT WebNode nextSibling() const;
WEBKIT_EXPORT bool hasChildNodes() const;
WEBKIT_EXPORT WebNodeList childNodes();
+ WEBKIT_EXPORT bool appendChild(const WebNode& child);
WEBKIT_EXPORT WebString createMarkup() const;
WEBKIT_EXPORT bool isLink() const;
WEBKIT_EXPORT bool isTextNode() const;
Modified: trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp (124789 => 124790)
--- trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp 2012-08-06 18:42:04 UTC (rev 124790)
@@ -1606,7 +1606,7 @@
if (event && event->source() && event->source()->document())
source = WebFrameImpl::fromFrame(event->source()->document()->frame());
return m_webFrame->client()->willCheckAndDispatchMessageEvent(
- source, WebSecurityOrigin(target), WebDOMMessageEvent(event));
+ source, m_webFrame, WebSecurityOrigin(target), WebDOMMessageEvent(event));
}
#if ENABLE(WEB_INTENTS_TAG)
Modified: trunk/Source/WebKit/chromium/src/WebDocument.cpp (124789 => 124790)
--- trunk/Source/WebKit/chromium/src/WebDocument.cpp 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/src/WebDocument.cpp 2012-08-06 18:42:04 UTC (rev 124790)
@@ -229,6 +229,15 @@
return static_cast<WebReferrerPolicy>(constUnwrap<Document>()->referrerPolicy());
}
+WebElement WebDocument::createElement(const WebString& tagName)
+{
+ ExceptionCode ec = 0;
+ WebElement element(unwrap<Document>()->createElement(tagName, ec));
+ if (ec)
+ return WebElement();
+ return element;
+}
+
WebAccessibilityObject WebDocument::accessibilityObject() const
{
const Document* document = constUnwrap<Document>();
Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (124789 => 124790)
--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2012-08-06 18:42:04 UTC (rev 124790)
@@ -590,6 +590,16 @@
return m_frame->tree()->uniqueName();
}
+WebString WebFrameImpl::uniqueName() const
+{
+ return m_frame->tree()->uniqueName();
+}
+
+WebString WebFrameImpl::assignedName() const
+{
+ return m_frame->tree()->name();
+}
+
void WebFrameImpl::setName(const WebString& name)
{
m_frame->tree()->setName(name);
@@ -2152,6 +2162,9 @@
if (!childFrame->tree()->parent())
return 0;
+ if (m_client)
+ m_client->didCreateFrame(this, webframe.get());
+
return childFrame.release();
}
Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.h (124789 => 124790)
--- trunk/Source/WebKit/chromium/src/WebFrameImpl.h 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.h 2012-08-06 18:42:04 UTC (rev 124790)
@@ -72,6 +72,8 @@
public:
// WebFrame methods:
virtual WebString name() const;
+ virtual WebString uniqueName() const;
+ virtual WebString assignedName() const;
virtual void setName(const WebString&);
virtual long long identifier() const;
virtual WebVector<WebIconURL> iconURLs(int iconTypes) const;
Modified: trunk/Source/WebKit/chromium/src/WebNode.cpp (124789 => 124790)
--- trunk/Source/WebKit/chromium/src/WebNode.cpp 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/src/WebNode.cpp 2012-08-06 18:42:04 UTC (rev 124790)
@@ -136,6 +136,13 @@
return WebNodeList(m_private->childNodes());
}
+bool WebNode::appendChild(const WebNode& child)
+{
+ ExceptionCode exceptionCode = 0;
+ m_private->appendChild(child, exceptionCode);
+ return !exceptionCode;
+}
+
WebString WebNode::createMarkup() const
{
return WebCore::createMarkup(m_private.get());
Modified: trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp (124789 => 124790)
--- trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2012-08-06 18:31:44 UTC (rev 124789)
+++ trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp 2012-08-06 18:42:04 UTC (rev 124790)
@@ -804,4 +804,35 @@
EXPECT_TRUE(selectionHtml.isEmpty());
}
+class TestDidCreateFrameWebFrameClient : public WebFrameClient {
+public:
+ TestDidCreateFrameWebFrameClient() : m_frameCount(0), m_parent(0)
+ {
+ }
+
+ virtual void didCreateFrame(WebFrame* parent, WebFrame* child)
+ {
+ m_frameCount++;
+ if (!m_parent)
+ m_parent = parent;
+ }
+
+ int m_frameCount;
+ WebFrame* m_parent;
+};
+
+TEST_F(WebFrameTest, DidCreateFrame)
+{
+ registerMockedHttpURLLoad("iframes_test.html");
+ registerMockedHttpURLLoad("visible_iframe.html");
+ registerMockedHttpURLLoad("invisible_iframe.html");
+ registerMockedHttpURLLoad("zero_sized_iframe.html");
+
+ TestDidCreateFrameWebFrameClient webFrameClient;
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframes_test.html", false, &webFrameClient);
+
+ EXPECT_EQ(webFrameClient.m_frameCount, 3);
+ EXPECT_EQ(webFrameClient.m_parent, webView->mainFrame());
+}
+
} // namespace