| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 FrameSelection::~FrameSelection() | 95 FrameSelection::~FrameSelection() |
| 96 { | 96 { |
| 97 #if !ENABLE(OILPAN) | 97 #if !ENABLE(OILPAN) |
| 98 // Oilpan: No need to clear out VisibleSelection observer; | 98 // Oilpan: No need to clear out VisibleSelection observer; |
| 99 // it is finalized as a part object of FrameSelection. | 99 // it is finalized as a part object of FrameSelection. |
| 100 stopObservingVisibleSelectionChangeIfNecessary(); | 100 stopObservingVisibleSelectionChangeIfNecessary(); |
| 101 #endif | 101 #endif |
| 102 } | 102 } |
| 103 | 103 |
| 104 Element* FrameSelection::rootEditableElementOrDocumentElement() const | |
| 105 { | |
| 106 Element* selectionRoot = m_selection.rootEditableElement(); | |
| 107 return selectionRoot ? selectionRoot : m_frame->document()->documentElement(
); | |
| 108 } | |
| 109 | |
| 110 ContainerNode* FrameSelection::rootEditableElementOrTreeScopeRootNode() const | 104 ContainerNode* FrameSelection::rootEditableElementOrTreeScopeRootNode() const |
| 111 { | 105 { |
| 112 Element* selectionRoot = m_selection.rootEditableElement(); | 106 Element* selectionRoot = m_selection.rootEditableElement(); |
| 113 if (selectionRoot) | 107 if (selectionRoot) |
| 114 return selectionRoot; | 108 return selectionRoot; |
| 115 | 109 |
| 116 Node* node = m_selection.base().containerNode(); | 110 Node* node = m_selection.base().containerNode(); |
| 117 return node ? &node->treeScope().rootNode() : 0; | 111 return node ? &node->treeScope().rootNode() : 0; |
| 118 } | 112 } |
| 119 | 113 |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 RefPtr<Node> root = nullptr; | 1239 RefPtr<Node> root = nullptr; |
| 1246 Node* selectStartTarget = 0; | 1240 Node* selectStartTarget = 0; |
| 1247 if (isContentEditable()) { | 1241 if (isContentEditable()) { |
| 1248 root = highestEditableRoot(m_selection.start()); | 1242 root = highestEditableRoot(m_selection.start()); |
| 1249 if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode()) | 1243 if (Node* shadowRoot = m_selection.nonBoundaryShadowTreeRootNode()) |
| 1250 selectStartTarget = shadowRoot->shadowHost(); | 1244 selectStartTarget = shadowRoot->shadowHost(); |
| 1251 else | 1245 else |
| 1252 selectStartTarget = root.get(); | 1246 selectStartTarget = root.get(); |
| 1253 } else { | 1247 } else { |
| 1254 root = m_selection.nonBoundaryShadowTreeRootNode(); | 1248 root = m_selection.nonBoundaryShadowTreeRootNode(); |
| 1255 if (root) | 1249 if (root) { |
| 1256 selectStartTarget = root->shadowHost(); | 1250 selectStartTarget = root->shadowHost(); |
| 1257 else { | 1251 } else { |
| 1258 root = document->documentElement(); | 1252 root = document; |
| 1259 selectStartTarget = document->documentElement(); | 1253 selectStartTarget = document; |
| 1260 } | 1254 } |
| 1261 } | 1255 } |
| 1262 if (!root) | 1256 if (!root) |
| 1263 return; | 1257 return; |
| 1264 | 1258 |
| 1265 if (selectStartTarget && !selectStartTarget->dispatchEvent(Event::createCanc
elableBubble(EventTypeNames::selectstart))) | 1259 if (selectStartTarget && !selectStartTarget->dispatchEvent(Event::createCanc
elableBubble(EventTypeNames::selectstart))) |
| 1266 return; | 1260 return; |
| 1267 | 1261 |
| 1268 VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode(
root.get())); | 1262 VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode(
root.get())); |
| 1269 setSelection(newSelection); | 1263 setSelection(newSelection); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 sel.showTreeForThis(); | 1623 sel.showTreeForThis(); |
| 1630 } | 1624 } |
| 1631 | 1625 |
| 1632 void showTree(const blink::FrameSelection* sel) | 1626 void showTree(const blink::FrameSelection* sel) |
| 1633 { | 1627 { |
| 1634 if (sel) | 1628 if (sel) |
| 1635 sel->showTreeForThis(); | 1629 sel->showTreeForThis(); |
| 1636 } | 1630 } |
| 1637 | 1631 |
| 1638 #endif | 1632 #endif |
| OLD | NEW |