Commit 941f96e1 authored by mitz@apple.com's avatar mitz@apple.com
Browse files

WebKit2: Injected bundle support for <rdar://problem/8710645> WebKitTestRunner...

WebKit2: Injected bundle support for <rdar://problem/8710645> WebKitTestRunner needs layoutTestController.findString
https://bugs.webkit.org/show_bug.cgi?id=50238

Reviewed by Anders Carlsson.

* Shared/API/c/WKFindOptions.h: Added. Moved the definition of WKFindOptions here from WKPage.h.
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toFindOptions): Moved from WKAPICast.h.
* UIProcess/API/C/WKAPICast.h:
* UIProcess/API/C/WKPage.h:
* WebKit2.xcodeproj/project.pbxproj: Added WKFindOptions.h.
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageFindString): Added.
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::findStringFromInjectedBundle): Added.
* WebProcess/WebPage/WebPage.h:

WebKitTools: <rdar://problem/8710645> WebKitTestRunner needs layoutTestController.findString
https://bugs.webkit.org/show_bug.cgi?id=50238

Reviewed by Anders Carlsson.

* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::findString): Added.
* WebKitTestRunner/InjectedBundle/LayoutTestController.h:

LayoutTests: <rdar://problem/8710645> WebKitTestRunner needs layoutTestController.findString
https://bugs.webkit.org/show_bug.cgi?id=50238

Reviewed by Anders Carlsson.

* platform/mac-wk2/Skipped: Removed editing/text-iterator/findString.html.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72937 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 909c112a
2010-11-30 Dan Bernstein <mitz@apple.com>
Reviewed by Anders Carlsson.
<rdar://problem/8710645> WebKitTestRunner needs layoutTestController.findString
https://bugs.webkit.org/show_bug.cgi?id=50238
* platform/mac-wk2/Skipped: Removed editing/text-iterator/findString.html.
2010-11-30 Xiaomei Ji <xji@chromium.org>
 
Reviewed by David Hyatt.
......@@ -1915,9 +1915,6 @@ fast/spatial-navigation
# WebKitTestRunner needs layoutTestController.pageSizeAndMarginsInPixels
printing/page-format-data-display-none.html
# WebKitTestRunner needs layoutTestController.findString <http://webkit.org/b/50238>
editing/text-iterator/findString.html
# WebKit2 needs support for moving/resizing and querying the location/size the window
fast/dom/Window/window-resize-and-move-arguments.html
fast/dom/Window/window-resize.html
......
2010-11-30 Dan Bernstein <mitz@apple.com>
Reviewed by Anders Carlsson.
Injected bundle support for <rdar://problem/8710645> WebKitTestRunner needs layoutTestController.findString
https://bugs.webkit.org/show_bug.cgi?id=50238
* Shared/API/c/WKFindOptions.h: Added. Moved the definition of WKFindOptions here from WKPage.h.
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toFindOptions): Moved from WKAPICast.h.
* UIProcess/API/C/WKAPICast.h:
* UIProcess/API/C/WKPage.h:
* WebKit2.xcodeproj/project.pbxproj: Added WKFindOptions.h.
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageFindString): Added.
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::findStringFromInjectedBundle): Added.
* WebProcess/WebPage/WebPage.h:
2010-11-30 Andreas Kling <kling@webkit.org>
 
Reviewed by Dirk Schulze.
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WKFindOptions_h
#define WKFindOptions_h
#ifdef __cplusplus
extern "C" {
#endif
enum {
kWKFindOptionsCaseInsensitive = 1 << 0,
kWKFindOptionsAtWordStarts = 1 << 1,
kWKFindOptionsTreatMedialCapitalAsWordStart = 1 << 2,
kWKFindOptionsBackwards = 1 << 3,
kWKFindOptionsWrapAround = 1 << 4,
kWKFindOptionsShowOverlay = 1 << 5,
kWKFindOptionsShowFindIndicator = 1 << 6
};
typedef uint32_t WKFindOptions;
#ifdef __cplusplus
}
#endif
#endif // WKFindOptions_h
......@@ -29,9 +29,11 @@
#include "WKBase.h"
#include "WKContextMenuItemTypes.h"
#include "WKEvent.h"
#include "WKFindOptions.h"
#include "WKGeometry.h"
#include "WebError.h"
#include "WebEvent.h"
#include "WebFindOptions.h"
#include "WebNumber.h"
#include "WebString.h"
#include "WebURL.h"
......@@ -619,6 +621,28 @@ inline WKContextMenuItemType toAPI(WebCore::ContextMenuItemType type)
}
}
inline FindOptions toFindOptions(WKFindOptions wkFindOptions)
{
unsigned findOptions = 0;
if (wkFindOptions & kWKFindOptionsCaseInsensitive)
findOptions |= FindOptionsCaseInsensitive;
if (wkFindOptions & kWKFindOptionsAtWordStarts)
findOptions |= FindOptionsAtWordStarts;
if (wkFindOptions & kWKFindOptionsTreatMedialCapitalAsWordStart)
findOptions |= FindOptionsTreatMedialCapitalAsWordStart;
if (wkFindOptions & kWKFindOptionsBackwards)
findOptions |= FindOptionsBackwards;
if (wkFindOptions & kWKFindOptionsWrapAround)
findOptions |= FindOptionsWrapAround;
if (wkFindOptions & kWKFindOptionsShowOverlay)
findOptions |= FindOptionsShowOverlay;
if (wkFindOptions & kWKFindOptionsShowFindIndicator)
findOptions |= FindOptionsShowFindIndicator;
return static_cast<FindOptions>(findOptions);
}
} // namespace WebKit
#endif // WKSharedAPICast_h
......@@ -32,7 +32,6 @@
#include "WKPage.h"
#include "WKPreferencesPrivate.h"
#include "WKSharedAPICast.h"
#include "WebFindOptions.h"
#include <WebCore/FrameLoaderTypes.h>
namespace WebKit {
......@@ -124,28 +123,6 @@ inline WKCacheModel toAPI(CacheModel cacheModel)
return kWKCacheModelDocumentViewer;
}
inline FindOptions toFindOptions(WKFindOptions wkFindOptions)
{
unsigned findOptions = 0;
if (wkFindOptions & kWKFindOptionsCaseInsensitive)
findOptions |= FindOptionsCaseInsensitive;
if (wkFindOptions & kWKFindOptionsAtWordStarts)
findOptions |= FindOptionsAtWordStarts;
if (wkFindOptions & kWKFindOptionsTreatMedialCapitalAsWordStart)
findOptions |= FindOptionsTreatMedialCapitalAsWordStart;
if (wkFindOptions & kWKFindOptionsBackwards)
findOptions |= FindOptionsBackwards;
if (wkFindOptions & kWKFindOptionsWrapAround)
findOptions |= FindOptionsWrapAround;
if (wkFindOptions & kWKFindOptionsShowOverlay)
findOptions |= FindOptionsShowOverlay;
if (wkFindOptions & kWKFindOptionsShowFindIndicator)
findOptions |= FindOptionsShowFindIndicator;
return static_cast<FindOptions>(findOptions);
}
inline FontSmoothingLevel toFontSmoothingLevel(WKFontSmoothingLevel wkLevel)
{
switch (wkLevel) {
......
......@@ -28,6 +28,7 @@
#include <WebKit2/WKBase.h>
#include <WebKit2/WKEvent.h>
#include <WebKit2/WKFindOptions.h>
#include <WebKit2/WKGeometry.h>
#include <WebKit2/WKNativeEvent.h>
......@@ -272,18 +273,6 @@ WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFa
WK_EXPORT void WKPageScaleWebView(WKPageRef page, double scale, WKPoint origin);
WK_EXPORT double WKPageGetViewScaleFactor(WKPageRef page);
// Find.
enum {
kWKFindOptionsCaseInsensitive = 1 << 0,
kWKFindOptionsAtWordStarts = 1 << 1,
kWKFindOptionsTreatMedialCapitalAsWordStart = 1 << 2,
kWKFindOptionsBackwards = 1 << 3,
kWKFindOptionsWrapAround = 1 << 4,
kWKFindOptionsShowOverlay = 1 << 5,
kWKFindOptionsShowFindIndicator = 1 << 6
};
typedef uint32_t WKFindOptions;
WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
WK_EXPORT void WKPageHideFindUI(WKPageRef page);
WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
......
......@@ -194,6 +194,7 @@
1CA8B945127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CA8B943127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp */; };
1CA8B946127C882A00576C2B /* WebInspectorProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */; };
1CA8B954127C891500576C2B /* WebInspectorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E2DAD1278C5B200BC7BD0 /* WebInspectorMac.mm */; };
37F623B812A57B6200E3FDF6 /* WKFindOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 37F623B712A57B6200E3FDF6 /* WKFindOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
510FBB9A1288C95E00AFFDF4 /* WebContextMenuItemData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510FBB981288C95E00AFFDF4 /* WebContextMenuItemData.cpp */; };
510FBB9B1288C95E00AFFDF4 /* WebContextMenuItemData.h in Headers */ = {isa = PBXBuildFile; fileRef = 510FBB991288C95E00AFFDF4 /* WebContextMenuItemData.h */; };
512935D71288D19400A4B695 /* WebContextMenuItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 512935D51288D19400A4B695 /* WebContextMenuItem.cpp */; };
......@@ -760,6 +761,7 @@
1CA8B943127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorProxyMessageReceiver.cpp; sourceTree = "<group>"; };
1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorProxyMessages.h; sourceTree = "<group>"; };
32DBCF5E0370ADEE00C91783 /* WebKit2Prefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKit2Prefix.h; sourceTree = "<group>"; };
37F623B712A57B6200E3FDF6 /* WKFindOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFindOptions.h; sourceTree = "<group>"; };
510FBB981288C95E00AFFDF4 /* WebContextMenuItemData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextMenuItemData.cpp; sourceTree = "<group>"; };
510FBB991288C95E00AFFDF4 /* WebContextMenuItemData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextMenuItemData.h; sourceTree = "<group>"; };
512935D51288D19400A4B695 /* WebContextMenuItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextMenuItem.cpp; sourceTree = "<group>"; };
......@@ -2067,6 +2069,7 @@
BC4075DF124FF0270068F20A /* WKError.cpp */,
BC4075E0124FF0270068F20A /* WKError.h */,
BC40783C1250FADD0068F20A /* WKEvent.h */,
37F623B712A57B6200E3FDF6 /* WKFindOptions.h */,
BCC8B373125FB69000DE46A4 /* WKGeometry.h */,
BC4075E1124FF0270068F20A /* WKMutableArray.cpp */,
BC4075E2124FF0270068F20A /* WKMutableArray.h */,
......@@ -2427,6 +2430,7 @@
1CA8B946127C882A00576C2B /* WebInspectorProxyMessages.h in Headers */,
5153569D1291B1D2000749DC /* WebPageContextMenuClient.h in Headers */,
1AAB4A8D1296F0A20023952F /* SandboxExtension.h in Headers */,
37F623B812A57B6200E3FDF6 /* WKFindOptions.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -156,3 +156,8 @@ bool WKBundlePageCanHandleRequest(WKURLRequestRef requestRef)
{
return WebPage::canHandleRequest(toImpl(requestRef)->resourceRequest());
}
bool WKBundlePageFindString(WKBundlePageRef pageRef, WKStringRef target, WKFindOptions findOptions)
{
return toImpl(pageRef)->findStringFromInjectedBundle(toImpl(target)->string(), toFindOptions(findOptions));
}
......@@ -28,6 +28,7 @@
#include <WebKit2/WKBase.h>
#include <WebKit2/WKEvent.h>
#include <WebKit2/WKFindOptions.h>
#ifndef __cplusplus
#include <stdbool.h>
......@@ -209,6 +210,8 @@ WK_EXPORT void WKBundlePageUninstallPageOverlay(WKBundlePageRef page, WKBundlePa
WK_EXPORT bool WKBundlePageHasLocalDataForURL(WKBundlePageRef page, WKURLRef url);
WK_EXPORT bool WKBundlePageCanHandleRequest(WKURLRequestRef request);
WK_EXPORT bool WKBundlePageFindString(WKBundlePageRef page, WKStringRef target, WKFindOptions findOptions);
#ifdef __cplusplus
}
#endif
......
......@@ -1001,6 +1001,11 @@ void WebPage::setActivePopupMenu(WebPopupMenu* menu)
m_activePopupMenu = menu;
}
bool WebPage::findStringFromInjectedBundle(const String& target, FindOptions options)
{
return m_page->findString(target, options);
}
void WebPage::findString(const String& string, uint32_t options, uint32_t maxMatchCount)
{
m_findController.findString(string, static_cast<FindOptions>(options), maxMatchCount);
......
......@@ -149,6 +149,8 @@ public:
InjectedBundlePageLoaderClient& injectedBundleLoaderClient() { return m_loaderClient; }
InjectedBundlePageUIClient& injectedBundleUIClient() { return m_uiClient; }
bool findStringFromInjectedBundle(const String&, FindOptions);
WebFrame* mainFrame() const { return m_mainFrame.get(); }
PassRefPtr<Plugin> createPlugin(const Plugin::Parameters&);
......
2010-11-30 Dan Bernstein <mitz@apple.com>
Reviewed by Anders Carlsson.
<rdar://problem/8710645> WebKitTestRunner needs layoutTestController.findString
https://bugs.webkit.org/show_bug.cgi?id=50238
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::findString): Added.
* WebKitTestRunner/InjectedBundle/LayoutTestController.h:
2010-11-30 Steve Falkenburg <sfalken@apple.com>
 
Reviewed by Adam Roben.
......
......@@ -233,6 +233,41 @@ void LayoutTestController::execCommand(JSStringRef name, JSStringRef argument)
WKBundlePageExecuteEditingCommand(InjectedBundle::shared().page()->page(), toWK(name).get(), toWK(argument).get());
}
bool LayoutTestController::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
{
WKFindOptions options = 0;
JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
if (!JSValueIsNumber(context, lengthValue))
return false;
size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0));
for (size_t i = 0; i < length; ++i) {
JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0);
if (!JSValueIsString(context, value))
continue;
JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
options |= kWKFindOptionsCaseInsensitive;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts"))
options |= kWKFindOptionsAtWordStarts;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart"))
options |= kWKFindOptionsTreatMedialCapitalAsWordStart;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards"))
options |= kWKFindOptionsBackwards;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround"))
options |= kWKFindOptionsWrapAround;
else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection")) {
// FIXME: No kWKFindOptionsStartInSelection.
}
}
return WKBundlePageFindString(InjectedBundle::shared().page()->page(), toWK(target).get(), options);
}
bool LayoutTestController::isCommandEnabled(JSStringRef name)
{
return WKBundlePageIsEditingCommandEnabled(InjectedBundle::shared().page()->page(), toWK(name).get());
......
......@@ -101,6 +101,9 @@ public:
void addUserScript(JSStringRef source, bool runAtStart, bool allFrames);
void addUserStyleSheet(JSStringRef source, bool allFrames);
// Text search testing.
bool findString(JSContextRef, JSStringRef, JSObjectRef optionsArray);
enum WhatToDump { RenderTree, MainFrameText, AllFramesText };
WhatToDump whatToDump() const { return m_whatToDump; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment