Title: [91108] trunk/Source/WebKit2
- Revision
- 91108
- Author
- adac...@apple.com
- Date
- 2011-07-15 14:00:51 -0700 (Fri, 15 Jul 2011)
Log Message
Implement "Jump to Selection" in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=64569
Reviewed by Anders Carlsson.
* UIProcess/API/mac/WKView.mm:
(-[WKView centerSelectionInVisibleArea:]): Call WebPageProxy::centerSelectionInVisibleArea().
(-[WKView validateUserInterfaceItem:]): Enable the centerSelectionInVisibleArea: selector if there's a selection
range or if there's an insertion point in an editable area.
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::showFindIndicatorInSelection): Call updateFindIndicator() to show the find indicator.
* WebProcess/WebPage/FindController.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::centerSelectionInVisibleArea): Use the selection in the focused or main frame.
After scrolling the selection into view, flash the find indicator.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (91107 => 91108)
--- trunk/Source/WebKit2/ChangeLog 2011-07-15 20:54:48 UTC (rev 91107)
+++ trunk/Source/WebKit2/ChangeLog 2011-07-15 21:00:51 UTC (rev 91108)
@@ -1,3 +1,21 @@
+2011-07-15 Ada Chan <adac...@apple.com>
+
+ Implement "Jump to Selection" in WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=64569
+
+ Reviewed by Anders Carlsson.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView centerSelectionInVisibleArea:]): Call WebPageProxy::centerSelectionInVisibleArea().
+ (-[WKView validateUserInterfaceItem:]): Enable the centerSelectionInVisibleArea: selector if there's a selection
+ range or if there's an insertion point in an editable area.
+ * WebProcess/WebPage/FindController.cpp:
+ (WebKit::FindController::showFindIndicatorInSelection): Call updateFindIndicator() to show the find indicator.
+ * WebProcess/WebPage/FindController.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::centerSelectionInVisibleArea): Use the selection in the focused or main frame.
+ After scrolling the selection into view, flash the find indicator.
+
2011-07-15 Dan Bernstein <m...@apple.com>
Windows build fix.
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (91107 => 91108)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2011-07-15 20:54:48 UTC (rev 91107)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2011-07-15 21:00:51 UTC (rev 91108)
@@ -536,6 +536,11 @@
return _data->_page->writeSelectionToPasteboard([pasteboard name], pasteboardTypes);
}
+- (void)centerSelectionInVisibleArea:(id)sender
+{
+ _data->_page->centerSelectionInVisibleArea();
+}
+
// This method is needed to support Mac OS X services.
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
@@ -569,7 +574,6 @@
Editing-related methods still unimplemented that are implemented in WebKit1:
- (void)capitalizeWord:(id)sender;
-- (void)centerSelectionInVisibleArea:(id)sender;
- (void)changeFont:(id)sender;
- (void)complete:(id)sender;
- (void)copyFont:(id)sender;
@@ -697,6 +701,10 @@
if (action == @selector(stopSpeaking:))
return [NSApp isSpeaking];
+
+ // The centerSelectionInVisibleArea: selector is enabled if there's a selection range or if there's an insertion point in an editable area.
+ if (action == @selector(centerSelectionInVisibleArea:))
+ return _data->_page->editorState().selectionIsRange || (_data->_page->editorState().isContentEditable && !_data->_page->editorState().selectionIsNone);
// Next, handle editor commands. Start by returning YES for anything that is not an editor command.
// Returning YES is the default thing to do in an AppKit validate method for any selector that is not recognized.
Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp (91107 => 91108)
--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp 2011-07-15 20:54:48 UTC (rev 91107)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp 2011-07-15 21:00:51 UTC (rev 91108)
@@ -33,6 +33,7 @@
#include "WebPageProxyMessages.h"
#include "WebProcess.h"
#include <WebCore/DocumentMarkerController.h>
+#include <WebCore/FocusController.h>
#include <WebCore/Frame.h>
#include <WebCore/FrameView.h>
#include <WebCore/GraphicsContext.h>
@@ -227,6 +228,15 @@
m_isShowingFindIndicator = false;
}
+void FindController::showFindIndicatorInSelection()
+{
+ Frame* selectedFrame = m_webPage->corePage()->focusController()->focusedOrMainFrame();
+ if (!selectedFrame)
+ return;
+
+ updateFindIndicator(selectedFrame, false);
+}
+
Vector<IntRect> FindController::rectsForTextMatches()
{
Vector<IntRect> rects;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/FindController.h (91107 => 91108)
--- trunk/Source/WebKit2/WebProcess/WebPage/FindController.h 2011-07-15 20:54:48 UTC (rev 91107)
+++ trunk/Source/WebKit2/WebProcess/WebPage/FindController.h 2011-07-15 21:00:51 UTC (rev 91108)
@@ -53,6 +53,7 @@
void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
void hideFindIndicator();
+ void showFindIndicatorInSelection();
private:
// PageOverlay::Client.
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (91107 => 91108)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2011-07-15 20:54:48 UTC (rev 91107)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2011-07-15 21:00:51 UTC (rev 91108)
@@ -1235,11 +1235,12 @@
void WebPage::centerSelectionInVisibleArea()
{
- Frame* coreFrame = m_mainFrame->coreFrame();
- if (!coreFrame)
+ Frame* frame = m_page->focusController()->focusedOrMainFrame();
+ if (!frame)
return;
-
- coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
+
+ frame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
+ m_findController.showFindIndicatorInSelection();
}
void WebPage::setActive(bool isActive)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes