| 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 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 } | 1316 } |
| 1317 | 1317 |
| 1318 // Workaround for the fact that it's hard to delete a frame. | 1318 // Workaround for the fact that it's hard to delete a frame. |
| 1319 // Call this after doing user-triggered selections to make it easy to delete the
frame you entirely selected. | 1319 // Call this after doing user-triggered selections to make it easy to delete the
frame you entirely selected. |
| 1320 // Can't do this implicitly as part of every setSelection call because in some c
ontexts it might not be good | 1320 // Can't do this implicitly as part of every setSelection call because in some c
ontexts it might not be good |
| 1321 // for the focus to move to another frame. So instead we call it from places whe
re we are selecting with the | 1321 // for the focus to move to another frame. So instead we call it from places whe
re we are selecting with the |
| 1322 // mouse or the keyboard after setting the selection. | 1322 // mouse or the keyboard after setting the selection. |
| 1323 void FrameSelection::selectFrameElementInParentIfFullySelected() | 1323 void FrameSelection::selectFrameElementInParentIfFullySelected() |
| 1324 { | 1324 { |
| 1325 // Find the parent frame; if there is none, then we have nothing to do. | 1325 // Find the parent frame; if there is none, then we have nothing to do. |
| 1326 LocalFrame* parent = m_frame->tree().parent(); | 1326 Frame* parent = m_frame->tree().parent(); |
| 1327 if (!parent) | 1327 if (!parent) |
| 1328 return; | 1328 return; |
| 1329 Page* page = m_frame->page(); | 1329 Page* page = m_frame->page(); |
| 1330 if (!page) | 1330 if (!page) |
| 1331 return; | 1331 return; |
| 1332 | 1332 |
| 1333 // Check if the selection contains the entire frame contents; if not, then t
here is nothing to do. | 1333 // Check if the selection contains the entire frame contents; if not, then t
here is nothing to do. |
| 1334 if (!isRange()) | 1334 if (!isRange()) |
| 1335 return; | 1335 return; |
| 1336 if (!isStartOfDocument(selection().visibleStart())) | 1336 if (!isStartOfDocument(selection().visibleStart())) |
| 1337 return; | 1337 return; |
| 1338 if (!isEndOfDocument(selection().visibleEnd())) | 1338 if (!isEndOfDocument(selection().visibleEnd())) |
| 1339 return; | 1339 return; |
| 1340 | 1340 |
| 1341 // FIXME: This is not yet implemented for cross-process frame relationships. |
| 1342 if (!parent->isLocalFrame()) |
| 1343 return; |
| 1344 |
| 1341 // Get to the <iframe> or <frame> (or even <object>) element in the parent f
rame. | 1345 // Get to the <iframe> or <frame> (or even <object>) element in the parent f
rame. |
| 1342 // FIXME: Doesn't work for OOPI. | 1346 // FIXME: Doesn't work for OOPI. |
| 1343 Element* ownerElement = m_frame->deprecatedLocalOwner(); | 1347 Element* ownerElement = m_frame->deprecatedLocalOwner(); |
| 1344 if (!ownerElement) | 1348 if (!ownerElement) |
| 1345 return; | 1349 return; |
| 1346 ContainerNode* ownerElementParent = ownerElement->parentNode(); | 1350 ContainerNode* ownerElementParent = ownerElement->parentNode(); |
| 1347 if (!ownerElementParent) | 1351 if (!ownerElementParent) |
| 1348 return; | 1352 return; |
| 1349 | 1353 |
| 1350 // This method's purpose is it to make it easier to select iframes (in order
to delete them). Don't do anything if the iframe isn't deletable. | 1354 // This method's purpose is it to make it easier to select iframes (in order
to delete them). Don't do anything if the iframe isn't deletable. |
| 1351 if (!ownerElementParent->rendererIsEditable()) | 1355 if (!ownerElementParent->rendererIsEditable()) |
| 1352 return; | 1356 return; |
| 1353 | 1357 |
| 1354 // Create compute positions before and after the element. | 1358 // Create compute positions before and after the element. |
| 1355 unsigned ownerElementNodeIndex = ownerElement->nodeIndex(); | 1359 unsigned ownerElementNodeIndex = ownerElement->nodeIndex(); |
| 1356 VisiblePosition beforeOwnerElement(VisiblePosition(Position(ownerElementPare
nt, ownerElementNodeIndex, Position::PositionIsOffsetInAnchor))); | 1360 VisiblePosition beforeOwnerElement(VisiblePosition(Position(ownerElementPare
nt, ownerElementNodeIndex, Position::PositionIsOffsetInAnchor))); |
| 1357 VisiblePosition afterOwnerElement(VisiblePosition(Position(ownerElementParen
t, ownerElementNodeIndex + 1, Position::PositionIsOffsetInAnchor), VP_UPSTREAM_I
F_POSSIBLE)); | 1361 VisiblePosition afterOwnerElement(VisiblePosition(Position(ownerElementParen
t, ownerElementNodeIndex + 1, Position::PositionIsOffsetInAnchor), VP_UPSTREAM_I
F_POSSIBLE)); |
| 1358 | 1362 |
| 1359 // Focus on the parent frame, and then select from before this element to af
ter. | 1363 // Focus on the parent frame, and then select from before this element to af
ter. |
| 1360 VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement); | 1364 VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement); |
| 1361 page->focusController().setFocusedFrame(parent); | 1365 page->focusController().setFocusedFrame(parent); |
| 1362 parent->selection().setSelection(newSelection); | 1366 toLocalFrame(parent)->selection().setSelection(newSelection); |
| 1363 } | 1367 } |
| 1364 | 1368 |
| 1365 void FrameSelection::selectAll() | 1369 void FrameSelection::selectAll() |
| 1366 { | 1370 { |
| 1367 Document* document = m_frame->document(); | 1371 Document* document = m_frame->document(); |
| 1368 | 1372 |
| 1369 if (isHTMLSelectElement(document->focusedElement())) { | 1373 if (isHTMLSelectElement(document->focusedElement())) { |
| 1370 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused
Element()); | 1374 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused
Element()); |
| 1371 if (selectElement->canSelectAll()) { | 1375 if (selectElement->canSelectAll()) { |
| 1372 selectElement->selectAll(); | 1376 selectElement->selectAll(); |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 sel.showTreeForThis(); | 1886 sel.showTreeForThis(); |
| 1883 } | 1887 } |
| 1884 | 1888 |
| 1885 void showTree(const WebCore::FrameSelection* sel) | 1889 void showTree(const WebCore::FrameSelection* sel) |
| 1886 { | 1890 { |
| 1887 if (sel) | 1891 if (sel) |
| 1888 sel->showTreeForThis(); | 1892 sel->showTreeForThis(); |
| 1889 } | 1893 } |
| 1890 | 1894 |
| 1891 #endif | 1895 #endif |
| OLD | NEW |