Changeset 25057 in webkit
- Timestamp:
- Aug 13, 2007, 12:14:49 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r25056 r25057 1 2007-08-13 Justin Garcia <justin.garcia@apple.com> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5333725> -webkit-user-select: none makes selection difficult 6 7 * editing/selection/5333725-expected.checksum: Added. 8 * editing/selection/5333725-expected.png: Added. 9 * editing/selection/5333725-expected.txt: Added. 10 * editing/selection/5333725.html: Added. 11 12 Added a workaround for a bug where -webkit-user-select:none 13 has no effect on the body if placed on the html element: 14 * editing/selection/select-all-user-select-none.html: 15 1 16 2007-08-13 Anders Carlsson <andersca@apple.com> 2 17 -
trunk/LayoutTests/editing/selection/select-all-user-select-none.html
r18338 r25057 2 2 <head> 3 3 <style> 4 html{4 body { 5 5 -webkit-user-select: none; 6 6 } -
trunk/WebCore/ChangeLog
r25056 r25057 1 2007-08-13 Justin Garcia <justin.garcia@apple.com> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5333725> -webkit-user-select: none makes selection difficult 6 7 Let users create selections if they mouse down in a -webkit-user-select:none 8 region, just (continue to) disallow selection endpoints in those regions, and 9 don't paint those regions as selected if they are fully enclosed by a selection. 10 For example, in xxyyyxx where x is -webkit-user-select:none, a user can mouse down 11 between the first two xs and drag across yyy to the second two xs to create a 12 selection xx^yyy^xx. 13 14 * editing/SelectionController.cpp: 15 (WebCore::SelectionController::selectAll): Allow selectAll inside a root 16 that has -webkit-user-select:none, because it may contain content that 17 is selectable (VisiblePosition and Selection creation will keep Selection 18 endpoints out of -webkit-user-select:none regions). 19 * page/EventHandler.cpp: 20 (WebCore::EventHandler::selectClosestWordFromMouseEvent): Use canMouseDownStartSelect 21 instead of the ambiguously named shouldSelect(). 22 (WebCore::EventHandler::handleMousePressEventTripleClick): Ditto. 23 (WebCore::EventHandler::handleMousePressEventSingleClick): Ditto. 24 (WebCore::EventHandler::updateSelectionForMouseDrag): Use canMouseDragExtendSelect. 25 (WebCore::EventHandler::selectCursor): Paint an ibeam in -webkit-user-select:none regions, 26 because you can click in those regions to create a selection. 27 (WebCore::EventHandler::canMouseDownStartSelect): Now fires the selectStart event, and 28 returns true in -webkit-user-select: none regions. 29 (WebCore::EventHandler::canMouseDragExtendSelect): This is identical to 30 canMouseDownStartSelect because of 12823, even though it seems strange that we would fire 31 the selectStart event here. 32 * page/EventHandler.h: 33 * rendering/RenderObject.cpp: 34 (WebCore::RenderObject::draggableNode): Only -webkit-user-select:ignore regions will 35 prevent selection creation. 36 * rendering/RenderObject.h: 37 1 38 2007-08-13 Anders Carlsson <andersca@apple.com> 2 39 -
trunk/WebCore/editing/SelectionController.cpp
r24974 r25057 1172 1172 1173 1173 Node* root = isContentEditable() ? highestEditableRoot(m_sel.start()) : document->documentElement(); 1174 if (!root || !root->renderer() || !root->renderer()->canSelect())1174 if (!root) 1175 1175 return; 1176 1176 Selection newSelection(Selection::selectionFromContentsOfNode(root)); -
trunk/WebCore/page/EventHandler.cpp
r24957 r25057 153 153 Selection newSelection; 154 154 155 if (innerNode && innerNode->renderer() && m_mouseDownMayStartSelect && innerNode->renderer()->shouldSelect()) {155 if (innerNode && innerNode->renderer() && m_mouseDownMayStartSelect) { 156 156 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.localPoint())); 157 157 if (pos.isNotNull()) { … … 194 194 195 195 Node* innerNode = event.targetNode(); 196 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect 197 && innerNode->renderer()->shouldSelect())) 196 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) 198 197 return false; 199 198 … … 221 220 222 221 Node* innerNode = event.targetNode(); 223 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect 224 && innerNode->renderer()->shouldSelect())) 222 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) 225 223 return false; 226 224 … … 409 407 if (!targetRenderer) 410 408 return; 411 412 if (! targetRenderer->shouldSelect())409 410 if (!canMouseDragExtendSelect(targetNode)) 413 411 return; 414 412 … … 728 726 if (m_frame->view() && layer && layer->isPointInResizeControl(m_frame->view()->windowToContents(event.event().pos()))) 729 727 inResizer = true; 730 if ((editable || (renderer && renderer->isText() && renderer-> canSelect())) && !inResizer && !scrollbar)728 if ((editable || (renderer && renderer->isText() && renderer->style()->userSelect() != SELECT_IGNORE)) && !inResizer && !scrollbar) 731 729 return iBeamCursor(); 732 730 return pointerCursor(); … … 1361 1359 } 1362 1360 1361 // Whether or not a mouse down can begin the creation of a selection. Fires the selectStart event. 1363 1362 bool EventHandler::canMouseDownStartSelect(Node* node) 1364 1363 { 1365 1364 if (!node || !node->renderer()) 1366 1365 return true; 1367 1368 // Check to see if -webkit-user-select has been set to none1369 if (!node->renderer()->canSelect())1370 return false;1371 1366 1372 1367 // Some controls and images can't start a select on a mouse down. … … 1374 1369 if (curr->style()->userSelect() == SELECT_IGNORE) 1375 1370 return false; 1371 1372 for (RenderObject* curr = node->renderer(); curr; curr = curr->parent()) 1373 if (Node* node = curr->element()) 1374 return EventTargetNodeCast(node)->dispatchHTMLEvent(selectstartEvent, true, true); 1376 1375 1377 1376 return true; 1377 } 1378 1379 bool EventHandler::canMouseDragExtendSelect(Node* node) 1380 { 1381 return canMouseDownStartSelect(node); 1378 1382 } 1379 1383 -
trunk/WebCore/page/EventHandler.h
r24957 r25057 196 196 197 197 static bool canMouseDownStartSelect(Node*); 198 static bool canMouseDragExtendSelect(Node*); 198 199 199 200 void handleAutoscroll(RenderObject*); -
trunk/WebCore/rendering/RenderObject.cpp
r24970 r25057 2012 2012 #endif // NDEBUG 2013 2013 2014 static Node* selectStartNode(const RenderObject* object)2015 {2016 Node* node = 0;2017 bool forcedOn = false;2018 2019 for (const RenderObject* curr = object; curr; curr = curr->parent()) {2020 if (curr->style()->userSelect() == SELECT_TEXT)2021 forcedOn = true;2022 if (!forcedOn && curr->style()->userSelect() == SELECT_NONE)2023 return 0;2024 2025 if (!node)2026 node = curr->element();2027 }2028 2029 // somewhere up the render tree there must be an element!2030 ASSERT(node);2031 2032 return node;2033 }2034 2035 bool RenderObject::canSelect() const2036 {2037 return selectStartNode(this) != 0;2038 }2039 2040 bool RenderObject::shouldSelect() const2041 {2042 if (Node* node = selectStartNode(this))2043 return EventTargetNodeCast(node)->dispatchHTMLEvent(selectstartEvent, true, true);2044 2045 return false;2046 }2047 2048 2014 Color RenderObject::selectionBackgroundColor() const 2049 2015 { … … 2094 2060 return curr->node(); 2095 2061 } 2096 if (curr->s houldSelect())2062 if (curr->style()->userSelect() != SELECT_IGNORE) 2097 2063 // In this case we have a click in the unselected portion of text. If this text is 2098 2064 // selectable, we want to start the selection process instead of looking for a parent -
trunk/WebCore/rendering/RenderObject.h
r24907 r25057 755 755 virtual bool hasSelectedChildren() const { return false; } 756 756 757 // Whether or not a selection can be attempted on this object.758 bool canSelect() const;759 760 // Whether or not a selection can be attempted on this object. Should only be called right before actually beginning a selection,761 // since it fires the selectstart DOM event.762 bool shouldSelect() const;763 764 757 // Obtains the selection colors that should be used when painting a selection. 765 758 Color selectionBackgroundColor() const;
Note:
See TracChangeset
for help on using the changeset viewer.