| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 if (!s.isNone() && !(options & DoNotSetFocus)) | 257 if (!s.isNone() && !(options & DoNotSetFocus)) |
| 258 setFocusedNodeIfNeeded(); | 258 setFocusedNodeIfNeeded(); |
| 259 | 259 |
| 260 if (!(options & DoNotUpdateAppearance)) { | 260 if (!(options & DoNotUpdateAppearance)) { |
| 261 updateAppearance(ResetCaretBlink); | 261 updateAppearance(ResetCaretBlink); |
| 262 } | 262 } |
| 263 | 263 |
| 264 // Always clear the x position used for vertical arrow navigation. | 264 // Always clear the x position used for vertical arrow navigation. |
| 265 // It will be restored by the vertical arrow navigation code if necessary. | 265 // It will be restored by the vertical arrow navigation code if necessary. |
| 266 m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); | 266 m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); |
| 267 selectFrameElementInParentIfFullySelected(); | |
| 268 notifyRendererOfSelectionChange(userTriggered); | 267 notifyRendererOfSelectionChange(userTriggered); |
| 269 m_frame->editor().respondToChangedSelection(oldSelection, options); | 268 m_frame->editor().respondToChangedSelection(oldSelection, options); |
| 270 if (userTriggered == UserTriggered) { | 269 if (userTriggered == UserTriggered) { |
| 271 ScrollAlignment alignment = (align == AlignCursorOnScrollAlways) ? Scrol
lAlignment::alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded; | 270 ScrollAlignment alignment = (align == AlignCursorOnScrollAlways) ? Scrol
lAlignment::alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded; |
| 272 revealSelection(alignment, RevealExtent); | 271 revealSelection(alignment, RevealExtent); |
| 273 } | 272 } |
| 274 | 273 |
| 275 notifyAccessibilityForSelectionChange(); | 274 notifyAccessibilityForSelectionChange(); |
| 276 | 275 |
| 277 m_frame->domWindow()->enqueueDocumentEvent(Event::create(EventTypeNames::sel
ectionchange)); | 276 m_frame->domWindow()->enqueueDocumentEvent(Event::create(EventTypeNames::sel
ectionchange)); |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 if (m_selection.visibleStart().isNull() || m_selection.visibleEnd().isNull()
) | 1231 if (m_selection.visibleStart().isNull() || m_selection.visibleEnd().isNull()
) |
| 1233 return false; | 1232 return false; |
| 1234 | 1233 |
| 1235 Position start(m_selection.visibleStart().deepEquivalent()); | 1234 Position start(m_selection.visibleStart().deepEquivalent()); |
| 1236 Position end(m_selection.visibleEnd().deepEquivalent()); | 1235 Position end(m_selection.visibleEnd().deepEquivalent()); |
| 1237 Position p(visiblePos.deepEquivalent()); | 1236 Position p(visiblePos.deepEquivalent()); |
| 1238 | 1237 |
| 1239 return comparePositions(start, p) <= 0 && comparePositions(p, end) <= 0; | 1238 return comparePositions(start, p) <= 0 && comparePositions(p, end) <= 0; |
| 1240 } | 1239 } |
| 1241 | 1240 |
| 1242 // Workaround for the fact that it's hard to delete a frame. | |
| 1243 // Call this after doing user-triggered selections to make it easy to delete the
frame you entirely selected. | |
| 1244 // Can't do this implicitly as part of every setSelection call because in some c
ontexts it might not be good | |
| 1245 // for the focus to move to another frame. So instead we call it from places whe
re we are selecting with the | |
| 1246 // mouse or the keyboard after setting the selection. | |
| 1247 void FrameSelection::selectFrameElementInParentIfFullySelected() | |
| 1248 { | |
| 1249 | |
| 1250 } | |
| 1251 | |
| 1252 void FrameSelection::selectAll() | 1241 void FrameSelection::selectAll() |
| 1253 { | 1242 { |
| 1254 Document* document = m_frame->document(); | 1243 Document* document = m_frame->document(); |
| 1255 | 1244 |
| 1256 RefPtr<Node> root = nullptr; | 1245 RefPtr<Node> root = nullptr; |
| 1257 Node* selectStartTarget = 0; | 1246 Node* selectStartTarget = 0; |
| 1258 if (isContentEditable()) { | 1247 if (isContentEditable()) { |
| 1259 root = highestEditableRoot(m_selection.start()); | 1248 root = highestEditableRoot(m_selection.start()); |
| 1260 if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode()) | 1249 if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode()) |
| 1261 selectStartTarget = shadowRoot->shadowHost(); | 1250 selectStartTarget = shadowRoot->shadowHost(); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 { | 1478 { |
| 1490 if (isNone() || !isFocused()) | 1479 if (isNone() || !isFocused()) |
| 1491 return; | 1480 return; |
| 1492 | 1481 |
| 1493 if (Element* target = rootEditableElement()) { | 1482 if (Element* target = rootEditableElement()) { |
| 1494 // Walk up the DOM tree to search for a node to focus. | 1483 // Walk up the DOM tree to search for a node to focus. |
| 1495 while (target) { | 1484 while (target) { |
| 1496 // We don't want to set focus on a subframe when selecting in a pare
nt frame, | 1485 // We don't want to set focus on a subframe when selecting in a pare
nt frame, |
| 1497 // so add the !isFrameElement check here. There's probably a better
way to make this | 1486 // so add the !isFrameElement check here. There's probably a better
way to make this |
| 1498 // work in the long term, but this is the safest fix at this time. | 1487 // work in the long term, but this is the safest fix at this time. |
| 1499 if (target->isMouseFocusable() && !isFrameElement(target)) { | 1488 if (target->isFocusable() && !isFrameElement(target)) { |
| 1500 m_frame->page()->focusController().setFocusedElement(target, m_f
rame); | 1489 m_frame->page()->focusController().setFocusedElement(target, m_f
rame); |
| 1501 return; | 1490 return; |
| 1502 } | 1491 } |
| 1503 target = target->parentOrShadowHostElement(); | 1492 target = target->parentOrShadowHostElement(); |
| 1504 } | 1493 } |
| 1505 m_frame->document()->setFocusedElement(nullptr); | 1494 m_frame->document()->setFocusedElement(nullptr); |
| 1506 } | 1495 } |
| 1507 } | 1496 } |
| 1508 | 1497 |
| 1509 String FrameSelection::selectedText() const | 1498 String FrameSelection::selectedText() const |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 sel.showTreeForThis(); | 1629 sel.showTreeForThis(); |
| 1641 } | 1630 } |
| 1642 | 1631 |
| 1643 void showTree(const blink::FrameSelection* sel) | 1632 void showTree(const blink::FrameSelection* sel) |
| 1644 { | 1633 { |
| 1645 if (sel) | 1634 if (sel) |
| 1646 sel->showTreeForThis(); | 1635 sel->showTreeForThis(); |
| 1647 } | 1636 } |
| 1648 | 1637 |
| 1649 #endif | 1638 #endif |
| OLD | NEW |