Changeset 109013 in webkit
- Timestamp:
- Feb 27, 2012 12:03:09 PM (12 years ago)
- Location:
- trunk/Source/WebKit/blackberry
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/blackberry/ChangeLog
r108963 r109013 1 2012-02-27 Ed Baker <edbaker@rim.com> 2 3 [BlackBerry] Dragging a selection handle outside of the content bounding box does not update the selection range correctly 4 https://bugs.webkit.org/show_bug.cgi?id=78608 5 6 Ensure that when selection handles leave the content bounding box that 7 the handle not being dragged remains fixed. Do not apply padding to a 8 direction that would cause the selection to shrink when performing the 9 handle direction detection. 10 11 Reviewed by Antonio Gomes. 12 13 * WebKitSupport/DOMSupport.cpp: 14 (BlackBerry::WebKit::DOMSupport::convertPointToFrame): 15 * WebKitSupport/DOMSupport.h: 16 * WebKitSupport/SelectionHandler.cpp: 17 (BlackBerry::WebKit::clamp): 18 (BlackBerry::WebKit::directionalVisiblePositionAtExtentOfBox): 19 (BlackBerry::WebKit::SelectionHandler::extendSelectionToFieldBoundary): 20 (BlackBerry::WebKit::SelectionHandler::setSelection): 21 (BlackBerry::WebKit::SelectionHandler::clipPointToVisibleContainer): 22 * WebKitSupport/SelectionHandler.h: 23 1 24 2012-02-27 Leo Yang <leo.yang@torchmobile.com.cn> 2 25 -
trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.cpp
r107743 r109013 337 337 } 338 338 339 IntPoint convertPointToFrame(const Frame* sourceFrame, const Frame* targetFrame, const IntPoint& point )339 IntPoint convertPointToFrame(const Frame* sourceFrame, const Frame* targetFrame, const IntPoint& point, const bool clampToTargetFrame) 340 340 { 341 341 ASSERT(sourceFrame && targetFrame); … … 348 348 Frame* targetFrameParent = targetFrame->tree()->parent(); 349 349 IntRect targetFrameRect = targetFrame->view()->frameRect(); 350 IntPoint targetPoint = point; 350 351 351 352 // Convert the target frame rect to source window content coordinates. This is only required … … 356 357 357 358 // Requested point is outside of target frame, return InvalidPoint. 358 if (!targetFrameRect.contains(point)) 359 if (clampToTargetFrame && !targetFrameRect.contains(targetPoint)) 360 targetPoint = IntPoint(targetPoint.x() < targetFrameRect.x() ? targetFrameRect.x() : std::min(targetPoint.x(), targetFrameRect.maxX()), 361 targetPoint.y() < targetFrameRect.y() ? targetFrameRect.y() : std::min(targetPoint.y(), targetFrameRect.maxY())); 362 else if (!targetFrameRect.contains(targetPoint)) 359 363 return InvalidPoint; 360 364 361 365 // Adjust the points to be relative to the target. 362 return targetFrame->view()->windowToContents(sourceFrame->view()->contentsToWindow( point));366 return targetFrame->view()->windowToContents(sourceFrame->view()->contentsToWindow(targetPoint)); 363 367 } 364 368 -
trunk/Source/WebKit/blackberry/WebKitSupport/DOMSupport.h
r107743 r109013 73 73 bool elementIdOrNameIndicatesNoAutocomplete(const WebCore::Element*); 74 74 75 WebCore::IntPoint convertPointToFrame(const WebCore::Frame* sourceFrame, const WebCore::Frame* targetFrame, const WebCore::IntPoint& sourcePoint );75 WebCore::IntPoint convertPointToFrame(const WebCore::Frame* sourceFrame, const WebCore::Frame* targetFrame, const WebCore::IntPoint& sourcePoint, const bool clampToTargetFrame = false); 76 76 77 77 static const WebCore::IntPoint InvalidPoint = WebCore::IntPoint(-1, -1); -
trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
r108796 r109013 272 272 } 273 273 274 static int clamp(const int min, const int value, const int max) 275 { 276 return value < min ? min : std::min(value, max); 277 } 278 274 279 static VisiblePosition directionalVisiblePositionAtExtentOfBox(Frame* frame, const WebCore::IntRect& boundingBox, unsigned short direction, const WebCore::IntPoint& basePoint) 275 280 { … … 281 286 switch (direction) { 282 287 case KEYCODE_LEFT: 283 // Extend x to start without modifying y.284 return frame->visiblePositionForPoint(WebCore::IntPoint(boundingBox.x(), basePoint.y()));288 // Extend x to start and clamp y to the edge of bounding box. 289 return frame->visiblePositionForPoint(WebCore::IntPoint(boundingBox.x(), clamp(boundingBox.y(), basePoint.y(), boundingBox.maxY()))); 285 290 case KEYCODE_RIGHT: 286 // Extend x to end without modifying y.287 return frame->visiblePositionForPoint(WebCore::IntPoint(boundingBox.maxX(), basePoint.y()));291 // Extend x to end and clamp y to the edge of bounding box. 292 return frame->visiblePositionForPoint(WebCore::IntPoint(boundingBox.maxX(), clamp(boundingBox.y(), basePoint.y(), boundingBox.maxY()))); 288 293 case KEYCODE_UP: 289 // Extend y to top without modifyingx.290 return frame->visiblePositionForPoint(WebCore::IntPoint( basePoint.x(), boundingBox.y()));294 // Extend y to top and clamp x to the edge of bounding box. 295 return frame->visiblePositionForPoint(WebCore::IntPoint(clamp(boundingBox.x(), basePoint.x(), boundingBox.maxX()), boundingBox.y())); 291 296 case KEYCODE_DOWN: 292 // Extend y to bottom without modifyingx.293 return frame->visiblePositionForPoint(WebCore::IntPoint( basePoint.x(), boundingBox.maxY()));297 // Extend y to bottom and clamp x to the edge of bounding box. 298 return frame->visiblePositionForPoint(WebCore::IntPoint(clamp(boundingBox.x(), basePoint.x(), boundingBox.maxX()), boundingBox.maxY())); 294 299 default: 295 300 break; … … 326 331 // Start handle is outside of the field. Treat it as the changed handle and move 327 332 // relative to the start caret rect. 328 unsigned short character = directionOfPointRelativeToRect(selectionPoint, caretRect, isStartHandle /* useTopPadding*/, !isStartHandle /*useBottomPadding*/);333 unsigned short character = directionOfPointRelativeToRect(selectionPoint, caretRect, isStartHandle /* useTopPadding */, !isStartHandle /* useBottomPadding */); 329 334 330 335 // Prevent incorrect movement, handles can only extend the selection this way … … 341 346 342 347 if (isStartHandle) 343 newSelection = VisibleSelection(newVisiblePosition, newSelection.extent(), true /* isDirectional*/);348 newSelection = VisibleSelection(newVisiblePosition, newSelection.extent(), true /* isDirectional */); 344 349 else 345 newSelection = VisibleSelection(newSelection.base(), newVisiblePosition, true /* isDirectional*/);350 newSelection = VisibleSelection(newSelection.base(), newVisiblePosition, true /* isDirectional */); 346 351 347 352 // If no selection will be changed, return the character to extend using navigation. … … 413 418 } 414 419 415 WebCore::IntPoint SelectionHandler::clipPointToFocusNode(const WebCore::IntPoint& point)416 {417 // Clipping should only happen if we are in an input field.418 if (!m_webPage->m_inputHandler->isInputMode())419 return point;420 421 Frame* focusedFrame = m_webPage->focusedOrMainFrame();422 if (!focusedFrame->document()->focusedNode() || !focusedFrame->document()->focusedNode()->renderer())423 return point;424 425 WebCore::IntRect focusedNodeBoundingBox = focusedFrame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect();426 focusedNodeBoundingBox.inflate(-1);427 428 WebCore::IntPoint clippedPoint = point;429 if (!focusedNodeBoundingBox.contains(clippedPoint))430 clippedPoint = WebCore::IntPoint(431 point.x() < focusedNodeBoundingBox.x() ? focusedNodeBoundingBox.x() : std::min(focusedNodeBoundingBox.maxX(), point.x()),432 point.y() < focusedNodeBoundingBox.y() ? focusedNodeBoundingBox.y() : std::min(focusedNodeBoundingBox.maxY(), point.y()));433 434 return clippedPoint;435 }436 437 420 void SelectionHandler::setSelection(const WebCore::IntPoint& start, const WebCore::IntPoint& end) 438 421 { … … 469 452 470 453 // Set the selection with validation. 471 newSelection.setBase(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointTo FocusNode(relativeStart)));454 newSelection.setBase(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(start))); 472 455 473 456 // Reset the selection using the existing extent without validation. … … 479 462 480 463 // Set the selection with validation. 481 newSelection.setExtent(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointTo FocusNode(relativeEnd)));464 newSelection.setExtent(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(end))); 482 465 483 466 // Reset the selection using the existing base without validation. … … 777 760 } 778 761 762 WebCore::IntPoint SelectionHandler::clipPointToVisibleContainer(const WebCore::IntPoint& point) const 763 { 764 ASSERT(m_webPage->m_mainFrame && m_webPage->m_mainFrame->view()); 765 766 Frame* frame = m_webPage->focusedOrMainFrame(); 767 WebCore::IntPoint clippedPoint = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), frame, point, true /* clampToTargetFrame */); 768 769 if (m_webPage->m_inputHandler->isInputMode() 770 && frame->document()->focusedNode() 771 && frame->document()->focusedNode()->renderer()) { 772 WebCore::IntRect boundingBox(frame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect()); 773 boundingBox.inflate(-1); 774 clippedPoint = WebCore::IntPoint(clamp(boundingBox.x(), clippedPoint.x(), boundingBox.maxX()), clamp(boundingBox.y(), clippedPoint.y(), boundingBox.maxY())); 775 } 776 777 return clippedPoint; 778 } 779 779 780 static WebCore::IntPoint referencePoint(const VisiblePosition& position, const WebCore::IntRect& boundingRect, const WebCore::IntPoint& framePosition, bool isStartCaret, bool isRTL) 780 781 { -
trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h
r107736 r109013 77 77 bool shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPoint&, const WebCore::IntRect&, bool startCaret = true) const; 78 78 unsigned short extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection); 79 WebCore::IntPoint clipPointTo FocusNode(const WebCore::IntPoint&);79 WebCore::IntPoint clipPointToVisibleContainer(const WebCore::IntPoint&) const; 80 80 81 81 WebPagePrivate* m_webPage;
Note: See TracChangeset
for help on using the changeset viewer.