https://bugs.webkit.org/show_bug.cgi?id=68453
Reviewed by Sam Weinig.
Expose WKBundlePage methods to turn on repaint rect tracking
in WebKit2, for WebKitTestRunner.
As part of the change, expose utility methods on WebPage
to get the main Frame and FrameView, which required renaming
the exisiting method that returns a WebFrame. Fix callers
of that method to handle null when necessary.
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageGetMainFrame):
(WKBundlePageSetTracksRepaints):
(WKBundlePageIsTrackingRepaints):
(WKBundlePageResetTrackedRepaints):
(WKBundlePageCopyTrackedRepaintRects):
* WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::findLargestFrameInFrameSet):
(WebKit::WebChromeClient::closeWindowSoon):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidFirstLayout):
(WebKit::WebFrameLoaderClient::dispatchDidLayout):
(WebKit::WebFrameLoaderClient::frameLoadCompleted):
(WebKit::WebFrameLoaderClient::restoreViewState):
(WebKit::WebFrameLoaderClient::provisionalLoadStarted):
(WebKit::WebFrameLoaderClient::transitionToCommittedFromCachedFrame):
(WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage):
(WebKit::WebFrameLoaderClient::createPlugin):
* WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
(WebKit::WebEditorClient::documentFragmentFromAttributedString):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::isMainFrame):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setTracksRepaints):
(WebKit::WebPage::isTrackingRepaints):
(WebKit::WebPage::resetTrackedRepaints):
(WebKit::WebPage::trackedRepaintRects):
(WebKit::WebPage::clearMainFrameName):
(WebKit::WebPage::layoutIfNeeded):
(WebKit::WebPage::mainFrameHasCustomRepresentation):
(WebKit::WebPage::mainFrame):
(WebKit::WebPage::mainFrameView):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::mainWebFrame):
* WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm:
(-[WKAccessibilityWebPageObject accessibilityHitTest:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95968
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-09-23 Simon Fraser <simon.fraser@apple.com>
+
+ Repaint tests don't work in WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=68453
+
+ Reviewed by Sam Weinig.
+
+ Expose WKBundlePage methods to turn on repaint rect tracking
+ in WebKit2, for WebKitTestRunner.
+
+ As part of the change, expose utility methods on WebPage
+ to get the main Frame and FrameView, which required renaming
+ the exisiting method that returns a WebFrame. Fix callers
+ of that method to handle null when necessary.
+
+ * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+ (WKBundlePageGetMainFrame):
+ (WKBundlePageSetTracksRepaints):
+ (WKBundlePageIsTrackingRepaints):
+ (WKBundlePageResetTrackedRepaints):
+ (WKBundlePageCopyTrackedRepaintRects):
+ * WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::findLargestFrameInFrameSet):
+ (WebKit::WebChromeClient::closeWindowSoon):
+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+ (WebKit::WebFrameLoaderClient::dispatchDidFirstLayout):
+ (WebKit::WebFrameLoaderClient::dispatchDidLayout):
+ (WebKit::WebFrameLoaderClient::frameLoadCompleted):
+ (WebKit::WebFrameLoaderClient::restoreViewState):
+ (WebKit::WebFrameLoaderClient::provisionalLoadStarted):
+ (WebKit::WebFrameLoaderClient::transitionToCommittedFromCachedFrame):
+ (WebKit::WebFrameLoaderClient::transitionToCommittedForNewPage):
+ (WebKit::WebFrameLoaderClient::createPlugin):
+ * WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
+ (WebKit::WebEditorClient::documentFragmentFromAttributedString):
+ * WebProcess/WebPage/WebFrame.cpp:
+ (WebKit::WebFrame::isMainFrame):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::setTracksRepaints):
+ (WebKit::WebPage::isTrackingRepaints):
+ (WebKit::WebPage::resetTrackedRepaints):
+ (WebKit::WebPage::trackedRepaintRects):
+ (WebKit::WebPage::clearMainFrameName):
+ (WebKit::WebPage::layoutIfNeeded):
+ (WebKit::WebPage::mainFrameHasCustomRepresentation):
+ (WebKit::WebPage::mainFrame):
+ (WebKit::WebPage::mainFrameView):
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::mainWebFrame):
+ * WebProcess/WebPage/mac/WKAccessibilityWebPageObject.mm:
+ (-[WKAccessibilityWebPageObject accessibilityHitTest:]):
+
2011-09-25 Mark Hahnenberg <mhahnenberg@apple.com>
Add custom vtable struct to ClassInfo struct
WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef pageRef)
{
- return toAPI(toImpl(pageRef)->mainFrame());
+ return toAPI(toImpl(pageRef)->mainWebFrame());
}
void WKBundlePageStopLoading(WKBundlePageRef pageRef)
{
return toImpl(pageRef)->renderTreeSize();
}
+
+void WKBundlePageSetTracksRepaints(WKBundlePageRef pageRef, bool trackRepaints)
+{
+ toImpl(pageRef)->setTracksRepaints(trackRepaints);
+}
+
+bool WKBundlePageIsTrackingRepaints(WKBundlePageRef pageRef)
+{
+ return toImpl(pageRef)->isTrackingRepaints();
+}
+
+void WKBundlePageResetTrackedRepaints(WKBundlePageRef pageRef)
+{
+ toImpl(pageRef)->resetTrackedRepaints();
+}
+
+WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->trackedRepaintRects().releaseRef());
+}
+
WK_EXPORT uint64_t WKBundlePageGetRenderTreeSize(WKBundlePageRef page);
+WK_EXPORT void WKBundlePageSetTracksRepaints(WKBundlePageRef page, bool trackRepaints);
+WK_EXPORT bool WKBundlePageIsTrackingRepaints(WKBundlePageRef page);
+WK_EXPORT void WKBundlePageResetTrackedRepaints(WKBundlePageRef page);
+WK_EXPORT WKArrayRef WKBundlePageCopyTrackedRepaintRects(WKBundlePageRef page);
+
+
#ifdef __cplusplus
}
#endif
{
// Approximate what a user could consider a default target frame for application menu operations.
- WebFrame* mainFrame = page->mainFrame();
+ WebFrame* mainFrame = page->mainWebFrame();
if (!mainFrame->isFrameSet())
return 0;
m_page->corePage()->setGroupName(String());
- if (WebFrame* frame = m_page->mainFrame()) {
+ if (WebFrame* frame = m_page->mainWebFrame()) {
if (Frame* coreFrame = frame->coreFrame())
coreFrame->loader()->stopForUserCancel();
}
// Notify the UIProcess.
webPage->send(Messages::WebPageProxy::DidFirstLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get())));
- if (m_frame == m_frame->page()->mainFrame())
+ if (m_frame == m_frame->page()->mainWebFrame())
webPage->drawingArea()->setLayerTreeStateIsFrozen(false);
}
// the UIProcess for every call.
// FIXME: Remove at the soonest possible time.
- if (m_frame == m_frame->page()->mainFrame())
+ if (m_frame == m_frame->page()->mainWebFrame())
webPage->send(Messages::WebPageProxy::SetRenderTreeSize(webPage->renderTreeSize()));
}
if (!webPage)
return;
- if (m_frame == m_frame->page()->mainFrame())
+ if (m_frame == m_frame->page()->mainWebFrame())
webPage->drawingArea()->setLayerTreeStateIsFrozen(false);
}
// FIXME: This should not be necessary. WebCore should be correctly invalidating
// the view on restores from the back/forward cache.
- if (m_frame == m_frame->page()->mainFrame())
+ if (m_frame == m_frame->page()->mainWebFrame())
m_frame->page()->drawingArea()->setNeedsDisplay(m_frame->page()->bounds());
}
if (!webPage)
return;
- if (m_frame == m_frame->page()->mainFrame())
+ if (m_frame == m_frame->page()->mainWebFrame())
webPage->drawingArea()->setLayerTreeStateIsFrozen(true);
}
void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*)
{
WebPage* webPage = m_frame->page();
- bool isMainFrame = webPage->mainFrame() == m_frame;
+ bool isMainFrame = webPage->mainWebFrame() == m_frame;
const ResourceResponse& response = m_frame->coreFrame()->loader()->documentLoader()->response();
m_frameHasCustomRepresentation = isMainFrame && WebProcess::shared().shouldUseCustomRepresentationForResponse(response);
WebPage* webPage = m_frame->page();
Color backgroundColor = webPage->drawsTransparentBackground() ? Color::transparent : Color::white;
- bool isMainFrame = webPage->mainFrame() == m_frame;
+ bool isMainFrame = webPage->mainWebFrame() == m_frame;
#if ENABLE(TILED_BACKING_STORE)
IntSize currentVisibleContentSize = m_frame->coreFrame()->view() ? m_frame->coreFrame()->view()->visibleContentRect().size() : IntSize();
parameters.loadManually = loadManually;
parameters.documentURL = m_frame->coreFrame()->document()->url().string();
- Frame* mainFrame = webPage->mainFrame()->coreFrame();
+ Frame* mainFrame = webPage->mainWebFrame()->coreFrame();
if (m_frame->coreFrame() == mainFrame)
parameters.toplevelDocumentURL = parameters.documentURL;
else if (m_frame->coreFrame()->document()->securityOrigin()->canAccess(mainFrame->document()->securityOrigin())) {
NSExcludedElementsDocumentAttribute, nil, @"WebResourceHandler", nil];
NSArray *subResources;
+ Document* document = m_page->mainFrame() ? m_page->mainFrame()->document() : 0;
DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length])
- document:kit(m_page->mainFrame()->coreFrame()->document())
+ document:kit(document)
documentAttributes:dictionary
subresources:&subResources];
for (WebResource* resource in subResources)
bool WebFrame::isMainFrame() const
{
if (WebPage* p = page())
- return p->mainFrame() == this;
+ return p->mainWebFrame() == this;
return false;
}
#include "WebFrame.h"
#include "WebFullScreenManager.h"
#include "WebGeolocationClient.h"
+#include "WebGeometry.h"
#include "WebImage.h"
#include "WebInspector.h"
#include "WebInspectorClient.h"
return size;
}
+void WebPage::setTracksRepaints(bool trackRepaints)
+{
+ if (FrameView* view = mainFrameView())
+ view->setTracksRepaints(trackRepaints);
+}
+
+bool WebPage::isTrackingRepaints() const
+{
+ if (FrameView* view = mainFrameView())
+ return view->isTrackingRepaints();
+
+ return false;
+}
+
+void WebPage::resetTrackedRepaints()
+{
+ if (FrameView* view = mainFrameView())
+ view->resetTrackedRepaints();
+}
+
+PassRefPtr<ImmutableArray> WebPage::trackedRepaintRects()
+{
+ FrameView* view = mainFrameView();
+ if (!view)
+ return ImmutableArray::create();
+
+ const Vector<IntRect>& rects = view->trackedRepaintRects();
+ size_t size = rects.size();
+ if (!size)
+ return ImmutableArray::create();
+
+ Vector<RefPtr<APIObject> > vector;
+ vector.reserveInitialCapacity(size);
+
+ for (size_t i = 0; i < size; ++i)
+ vector.uncheckedAppend(WebRect::create(toAPI(rects[i])));
+
+ return ImmutableArray::adopt(vector);
+}
+
void WebPage::executeEditingCommand(const String& commandName, const String& argument)
{
Frame* frame = m_page->focusController()->focusedOrMainFrame();
void WebPage::clearMainFrameName()
{
- mainFrame()->coreFrame()->tree()->clearName();
+ if (Frame* frame = mainFrame())
+ frame->tree()->clearName();
}
#if USE(ACCELERATED_COMPOSITING)
m_mainFrame->coreFrame()->view()->updateLayoutAndStyleIfNeededRecursive();
if (m_underlayPage) {
- if (FrameView *frameView = m_underlayPage->mainFrame()->coreFrame()->view())
+ if (FrameView *frameView = m_underlayPage->mainFrameView())
frameView->updateLayoutAndStyleIfNeededRecursive();
}
}
bool WebPage::mainFrameHasCustomRepresentation() const
{
- return static_cast<WebFrameLoaderClient*>(mainFrame()->coreFrame()->loader()->client())->frameHasCustomRepresentation();
+ if (Frame* frame = mainFrame())
+ return static_cast<WebFrameLoaderClient*>(frame->loader()->client())->frameHasCustomRepresentation();
+
+ return false;
}
void WebPage::didChangeScrollOffsetForMainFrame()
mouseEvent(WebMouseEvent(WebMouseEvent::MouseMove, WebMouseEvent::NoButton, position, position, 0, 0, 0, 0, WebMouseEvent::Modifiers(), time));
}
+Frame* WebPage::mainFrame() const
+{
+ return m_page ? m_page->mainFrame() : 0;
+}
+
+FrameView* WebPage::mainFrameView() const
+{
+ if (Frame* frame = mainFrame())
+ return frame->view();
+
+ return 0;
+}
+
} // namespace WebKit
#include "FindController.h"
#include "GeolocationPermissionRequestManager.h"
#include "ImageOptions.h"
+#include "ImmutableArray.h"
#include "InjectedBundlePageContextMenuClient.h"
#include "InjectedBundlePageEditorClient.h"
#include "InjectedBundlePageFormClient.h"
namespace WebCore {
class GraphicsContext;
+ class Frame;
+ class FrameView;
class KeyboardEvent;
class Page;
class PrintContext;
bool findStringFromInjectedBundle(const String&, FindOptions);
- WebFrame* mainFrame() const { return m_mainFrame.get(); }
+ WebFrame* mainWebFrame() const { return m_mainFrame.get(); }
+
+ WebCore::Frame* mainFrame() const; // May return 0.
+ WebCore::FrameView* mainFrameView() const; // May return 0.
+
PassRefPtr<Plugin> createPlugin(const Plugin::Parameters&);
EditorState editorState() const;
String renderTreeExternalRepresentation() const;
uint64_t renderTreeSize() const;
+ void setTracksRepaints(bool);
+ bool isTrackingRepaints() const;
+ void resetTrackedRepaints();
+ PassRefPtr<ImmutableArray> trackedRepaintRects();
+
void executeEditingCommand(const String& commandName, const String& argument);
bool isEditingCommandEnabled(const String& commandName);
void clearMainFrameName();
point.y -= remotePosition.y;
point.x -= remotePosition.x;
- if (m_page && m_page->mainFrame() && m_page->mainFrame()->coreFrame()) {
- WebCore::FrameView* fv = m_page->mainFrame()->coreFrame()->view();
- if (fv) {
- point.y += fv->scrollPosition().y();
- point.x += fv->scrollPosition().x();
- }
+ WebCore::FrameView* frameView = m_page ? m_page->mainFrameView() : 0;
+ if (frameView) {
+ point.y += frameView->scrollPosition().y();
+ point.x += frameView->scrollPosition().x();
}
return [[self accessibilityRootObjectWrapper] accessibilityHitTest:point];