Changeset 83320 in webkit
- Timestamp:
- Apr 8, 2011 11:53:21 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r83301 r83320 1 2011-04-08 Varun Jain <varunjain@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 Need to extend WebKit chromium API to access text selection 6 https://bugs.webkit.org/show_bug.cgi?id=57888 7 8 * Source/WebKit/chromium/public/WebFrame.h: 9 * Source/WebKit/chromium/public/WebWidget.h: 10 * Source/WebKit/chromium/src/WebFrameImpl.cpp: 11 * Source/WebKit/chromium/src/WebFrameImpl.h: 12 * Source/WebKit/chromium/src/WebPopupMenuImpl.h: 13 * Source/WebKit/chromium/src/WebViewImpl.cpp: 14 * Source/WebKit/chromium/src/WebViewImpl.h: 15 * Source/WebKit/chromium/tests/PopupMenuTest.cpp: 16 1 17 2011-04-08 Jon Lee <jonlee@apple.com> 2 18 -
trunk/Source/WebKit/chromium/public/WebFrame.h
r83021 r83320 68 68 struct WebConsoleMessage; 69 69 struct WebFindOptions; 70 struct WebPoint; 70 71 struct WebRect; 71 72 struct WebScriptSource; … … 408 409 // there is ranged selection. 409 410 virtual bool selectWordAroundCaret() = 0; 411 412 virtual void selectRange(const WebPoint& start, const WebPoint& end) = 0; 410 413 411 414 -
trunk/Source/WebKit/chromium/public/WebWidget.h
r76278 r83320 42 42 class WebInputEvent; 43 43 class WebString; 44 struct WebPoint; 44 45 struct WebRect; 45 46 struct WebSize; … … 127 128 virtual WebRect caretOrSelectionBounds() = 0; 128 129 130 // Returns the start and end point for the current selection, aligned to the 131 // bottom of the selected line. 132 // FIXME: make this pure virtual after all downstream classes have 133 // implemented it. 134 virtual bool selectionRange(WebPoint& start, WebPoint& end) const 135 { 136 return false; 137 } 138 129 139 // Changes the text direction of the selected input node. 130 140 virtual void setTextDirection(WebTextDirection) = 0; -
trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp
r83021 r83320 91 91 #include "FrameTree.h" 92 92 #include "FrameView.h" 93 #include "HitTestResult.h" 93 94 #include "HTMLCollection.h" 94 95 #include "HTMLFormElement.h" … … 107 108 #include "PrintContext.h" 108 109 #include "RenderFrame.h" 110 #include "RenderLayer.h" 109 111 #include "RenderObject.h" 110 112 #include "RenderTreeAsText.h" … … 141 143 #include "WebPlugin.h" 142 144 #include "WebPluginContainerImpl.h" 145 #include "WebPoint.h" 143 146 #include "WebRange.h" 144 147 #include "WebRect.h" … … 1304 1307 selectWordAroundPosition(frame(), controller->selection().visibleStart()); 1305 1308 return true; 1309 } 1310 1311 void WebFrameImpl::selectRange(const WebPoint& start, const WebPoint& end) 1312 { 1313 VisibleSelection selection(visiblePositionForWindowPoint(start), 1314 visiblePositionForWindowPoint(end)); 1315 1316 if (frame()->selection()->shouldChangeSelection(selection)) 1317 frame()->selection()->setSelection(selection, CharacterGranularity, 1318 MakeNonDirectionalSelection); 1319 } 1320 1321 VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& point) 1322 { 1323 HitTestRequest::HitTestRequestType hitType = HitTestRequest::MouseMove; 1324 hitType |= HitTestRequest::ReadOnly; 1325 hitType |= HitTestRequest::Active; 1326 HitTestRequest request(hitType); 1327 FrameView* view = frame()->view(); 1328 HitTestResult result(view->windowToContents( 1329 view->convertFromContainingWindow(IntPoint(point.x, point.y)))); 1330 1331 frame()->document()->renderView()->layer()->hitTest(request, result); 1332 1333 // Matching the logic in MouseEventWithHitTestResults::targetNode() 1334 Node* node = result.innerNode(); 1335 if (!node) 1336 return VisiblePosition(); 1337 Element* element = node->parentElement(); 1338 if (!node->inDocument() && element && element->inDocument()) 1339 node = element; 1340 1341 return node->renderer()->positionForPoint(result.localPoint()); 1306 1342 } 1307 1343 -
trunk/Source/WebKit/chromium/src/WebFrameImpl.h
r81913 r83320 158 158 virtual WebString selectionAsMarkup() const; 159 159 virtual bool selectWordAroundCaret(); 160 virtual void selectRange(const WebPoint& start, const WebPoint& end); 160 161 virtual int printBegin(const WebSize& pageSize, 161 162 const WebNode& constrainToNode, … … 327 328 void loadJavaScriptURL(const WebCore::KURL&); 328 329 330 // Returns a hit-tested VisiblePosition for the given point 331 WebCore::VisiblePosition visiblePositionForWindowPoint(const WebPoint&); 332 329 333 FrameLoaderClientImpl m_frameLoaderClient; 330 334 -
trunk/Source/WebKit/chromium/src/WebPopupMenuImpl.h
r76278 r83320 79 79 virtual WebTextInputType textInputType(); 80 80 virtual WebRect caretOrSelectionBounds(); 81 virtual bool selectionRange(WebPoint& start, WebPoint& end) const { return false; } 81 82 virtual void setTextDirection(WebTextDirection direction); 82 83 virtual bool isAcceleratedCompositingActive() const { return false; } -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r82886 r83320 1455 1455 } 1456 1456 1457 bool WebViewImpl::selectionRange(WebPoint& start, WebPoint& end) const 1458 { 1459 const Frame* frame = focusedWebCoreFrame(); 1460 if (!frame) 1461 return false; 1462 RefPtr<Range> selectedRange = frame->selection()->toNormalizedRange(); 1463 RefPtr<Range> range(Range::create(selectedRange->startContainer()->document(), 1464 selectedRange->startContainer(), 1465 selectedRange->startOffset(), 1466 selectedRange->startContainer(), 1467 selectedRange->startOffset())); 1468 1469 IntRect rect = frame->editor()->firstRectForRange(range.get()); 1470 start.x = rect.x(); 1471 start.y = rect.y() + rect.height() - 1; 1472 1473 range = Range::create(selectedRange->endContainer()->document(), 1474 selectedRange->endContainer(), 1475 selectedRange->endOffset(), 1476 selectedRange->endContainer(), 1477 selectedRange->endOffset()); 1478 1479 rect = frame->editor()->firstRectForRange(range.get()); 1480 end.x = rect.x() + rect.width() - 1; 1481 end.y = rect.y() + rect.height() - 1; 1482 1483 start = frame->view()->contentsToWindow(start); 1484 end = frame->view()->contentsToWindow(end); 1485 return true; 1486 } 1487 1457 1488 void WebViewImpl::setTextDirection(WebTextDirection direction) 1458 1489 { -
trunk/Source/WebKit/chromium/src/WebViewImpl.h
r82481 r83320 110 110 virtual WebTextInputType textInputType(); 111 111 virtual WebRect caretOrSelectionBounds(); 112 virtual bool selectionRange(WebPoint& start, WebPoint& end) const; 112 113 virtual void setTextDirection(WebTextDirection direction); 113 114 virtual bool isAcceleratedCompositingActive() const; -
trunk/Source/WebKit/chromium/tests/PopupMenuTest.cpp
r82481 r83320 143 143 virtual WebTextInputType textInputType() { return WebKit::WebTextInputTypeNone; } 144 144 virtual WebRect caretOrSelectionBounds() { return WebRect(); } 145 virtual bool selectionRange(WebPoint& start, WebPoint& end) const { return false; } 145 146 virtual void setTextDirection(WebTextDirection) { } 146 147 };
Note: See TracChangeset
for help on using the changeset viewer.