Changeset 107719 in webkit
- Timestamp:
- Feb 14, 2012 11:39:58 AM (12 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r107716 r107719 1 2012-02-14 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 applying padding to 8 a direction that would cause the selection to shrink when performing 9 the handle direction detection. 10 11 Reviewed by Rob Buis. 12 13 * blackberry/WebKitSupport/SelectionHandler.cpp: 14 (BlackBerry::WebKit::directionOfPointRelativeToRect): 15 (BlackBerry::WebKit::SelectionHandler::extendSelectionToFieldBoundary): 16 (BlackBerry::WebKit::SelectionHandler::clipPointToFocusNode): 17 (BlackBerry::WebKit::SelectionHandler::setSelection): 18 * blackberry/WebKitSupport/SelectionHandler.h: 19 1 20 2012-02-14 Rob Buis <rbuis@rim.com> 2 21 -
trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp
r107674 r107719 171 171 } 172 172 173 static unsigned short directionOfPointRelativeToRect(const IntPoint& point, const IntRect& rect )173 static unsigned short directionOfPointRelativeToRect(const IntPoint& point, const IntRect& rect, const bool useTopPadding = true, const bool useBottomPadding = true) 174 174 { 175 175 ASSERT(!rect.contains(point)); … … 180 180 // Do height movement check first but add padding. We may be off on both x & y axis and only 181 181 // want to move in one direction at a time. 182 if (point.y() + verticalPadding< rect.y())182 if (point.y() + (useTopPadding ? verticalPadding : 0) < rect.y()) 183 183 return KEYCODE_UP; 184 if (point.y() > rect.maxY() + verticalPadding)184 if (point.y() > rect.maxY() + (useBottomPadding ? verticalPadding : 0)) 185 185 return KEYCODE_DOWN; 186 186 if (point.x() < rect.location().x()) … … 343 343 344 344 IntRect nodeBoundingBox = focusedFrame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect(); 345 nodeBoundingBox.inflate(-1); 345 346 346 347 // Start handle is outside of the field. Treat it as the changed handle and move 347 348 // relative to the start caret rect. 348 unsigned short character = directionOfPointRelativeToRect(selectionPoint, caretRect );349 unsigned short character = directionOfPointRelativeToRect(selectionPoint, caretRect, isStartHandle /*useTopPadding*/, !isStartHandle /*useBottomPadding*/); 349 350 350 351 // Prevent incorrect movement, handles can only extend the selection this way … … 354 355 character = 0; 355 356 356 VisiblePosition newVisiblePosition = controller->selection().start();357 VisiblePosition newVisiblePosition = isStartHandle ? controller->selection().extent() : controller->selection().base(); 357 358 // Extend the selection to the bounds of the box before doing incremental scroll if the point is outside the node. 358 359 // Don't extend selection and handle the character at the same time. … … 361 362 362 363 if (isStartHandle) 363 newSelection = VisibleSelection(newVisiblePosition, newSelection. visibleEnd(), true /*isDirectional*/);364 newSelection = VisibleSelection(newVisiblePosition, newSelection.extent(), true /*isDirectional*/); 364 365 else 365 newSelection = VisibleSelection(newSelection. visibleStart(), newVisiblePosition, true /*isDirectional*/);366 newSelection = VisibleSelection(newSelection.base(), newVisiblePosition, true /*isDirectional*/); 366 367 367 368 // If no selection will be changed, return the character to extend using navigation. … … 433 434 } 434 435 436 IntPoint SelectionHandler::clipPointToFocusNode(const IntPoint& point) 437 { 438 Frame* focusedFrame = m_webPage->focusedOrMainFrame(); 439 FrameSelection* controller = focusedFrame->selection(); 440 441 if (!focusedFrame->document()->focusedNode() || !focusedFrame->document()->focusedNode()->renderer()) 442 return point; 443 444 IntRect focusedNodeBoundingBox = focusedFrame->document()->focusedNode()->renderer()->absoluteBoundingBoxRect(); 445 focusedNodeBoundingBox.inflate(-1); 446 447 IntPoint clippedPoint = point; 448 if (!focusedNodeBoundingBox.contains(clippedPoint)) 449 clippedPoint = IntPoint( 450 point.x() < focusedNodeBoundingBox.x() ? focusedNodeBoundingBox.x() : std::min(focusedNodeBoundingBox.maxX(), point.x()), 451 point.y() < focusedNodeBoundingBox.y() ? focusedNodeBoundingBox.y() : std::min(focusedNodeBoundingBox.maxY(), point.y())); 452 453 return clippedPoint; 454 } 455 435 456 void SelectionHandler::setSelection(const IntPoint& start, const IntPoint& end) 436 457 { … … 467 488 468 489 // Set the selection with validation. 469 newSelection.setBase(visiblePositionForPointIgnoringClipping(*focusedFrame, relativeStart));490 newSelection.setBase(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToFocusNode(relativeStart))); 470 491 471 492 // Reset the selection using the existing extent without validation. … … 477 498 478 499 // Set the selection with validation. 479 newSelection.setExtent(visiblePositionForPointIgnoringClipping(*focusedFrame, relativeEnd));500 newSelection.setExtent(visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToFocusNode(relativeEnd))); 480 501 481 502 // Reset the selection using the existing base without validation. -
trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.h
r107674 r107719 78 78 bool shouldUpdateSelectionOrCaretForPoint(const WebCore::IntPoint&, const WebCore::IntRect&, bool startCaret = true) const; 79 79 unsigned short extendSelectionToFieldBoundary(bool isStartHandle, const WebCore::IntPoint& selectionPoint, WebCore::VisibleSelection& newSelection); 80 WebCore::IntPoint clipPointToFocusNode(const WebCore::IntPoint&); 80 81 81 82 WebPagePrivate* m_webPage;
Note: See TracChangeset
for help on using the changeset viewer.