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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 stopObservingVisibleSelectionChangeIfNecessary(); | 114 stopObservingVisibleSelectionChangeIfNecessary(); |
115 #endif | 115 #endif |
116 } | 116 } |
117 | 117 |
118 Element* FrameSelection::rootEditableElementOrDocumentElement() const | 118 Element* FrameSelection::rootEditableElementOrDocumentElement() const |
119 { | 119 { |
120 Element* selectionRoot = m_selection.rootEditableElement(); | 120 Element* selectionRoot = m_selection.rootEditableElement(); |
121 return selectionRoot ? selectionRoot : m_frame->document()->documentElement(
); | 121 return selectionRoot ? selectionRoot : m_frame->document()->documentElement(
); |
122 } | 122 } |
123 | 123 |
124 Node* FrameSelection::rootEditableElementOrTreeScopeRootNode() const | 124 ContainerNode* FrameSelection::rootEditableElementOrTreeScopeRootNode() const |
125 { | 125 { |
126 Element* selectionRoot = m_selection.rootEditableElement(); | 126 Element* selectionRoot = m_selection.rootEditableElement(); |
127 if (selectionRoot) | 127 if (selectionRoot) |
128 return selectionRoot; | 128 return selectionRoot; |
129 | 129 |
130 Node* node = m_selection.base().containerNode(); | 130 Node* node = m_selection.base().containerNode(); |
131 return node ? &node->treeScope().rootNode() : 0; | 131 return node ? &node->treeScope().rootNode() : 0; |
132 } | 132 } |
133 | 133 |
134 void FrameSelection::moveTo(const VisiblePosition &pos, EUserTriggered userTrigg
ered, CursorAlignOnScroll align) | 134 void FrameSelection::moveTo(const VisiblePosition &pos, EUserTriggered userTrigg
ered, CursorAlignOnScroll align) |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 return; | 1339 return; |
1340 if (!isEndOfDocument(selection().visibleEnd())) | 1340 if (!isEndOfDocument(selection().visibleEnd())) |
1341 return; | 1341 return; |
1342 | 1342 |
1343 // FIXME: This is not yet implemented for cross-process frame relationships. | 1343 // FIXME: This is not yet implemented for cross-process frame relationships. |
1344 if (!parent->isLocalFrame()) | 1344 if (!parent->isLocalFrame()) |
1345 return; | 1345 return; |
1346 | 1346 |
1347 // Get to the <iframe> or <frame> (or even <object>) element in the parent f
rame. | 1347 // Get to the <iframe> or <frame> (or even <object>) element in the parent f
rame. |
1348 // FIXME: Doesn't work for OOPI. | 1348 // FIXME: Doesn't work for OOPI. |
1349 Element* ownerElement = m_frame->deprecatedLocalOwner(); | 1349 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); |
1350 if (!ownerElement) | 1350 if (!ownerElement) |
1351 return; | 1351 return; |
1352 ContainerNode* ownerElementParent = ownerElement->parentNode(); | 1352 ContainerNode* ownerElementParent = ownerElement->parentNode(); |
1353 if (!ownerElementParent) | 1353 if (!ownerElementParent) |
1354 return; | 1354 return; |
1355 | 1355 |
1356 // 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. | 1356 // 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. |
1357 if (!ownerElementParent->hasEditableStyle()) | 1357 if (!ownerElementParent->hasEditableStyle()) |
1358 return; | 1358 return; |
1359 | 1359 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 } | 1617 } |
1618 | 1618 |
1619 bool FrameSelection::shouldBlinkCaret() const | 1619 bool FrameSelection::shouldBlinkCaret() const |
1620 { | 1620 { |
1621 if (!caretIsVisible() || !isCaret()) | 1621 if (!caretIsVisible() || !isCaret()) |
1622 return false; | 1622 return false; |
1623 | 1623 |
1624 if (m_frame->settings() && m_frame->settings()->caretBrowsingEnabled()) | 1624 if (m_frame->settings() && m_frame->settings()->caretBrowsingEnabled()) |
1625 return false; | 1625 return false; |
1626 | 1626 |
1627 Node* root = rootEditableElement(); | 1627 Element* root = rootEditableElement(); |
1628 if (!root) | 1628 if (!root) |
1629 return false; | 1629 return false; |
1630 | 1630 |
1631 Element* focusedElement = root->document().focusedElement(); | 1631 Element* focusedElement = root->document().focusedElement(); |
1632 if (!focusedElement) | 1632 if (!focusedElement) |
1633 return false; | 1633 return false; |
1634 | 1634 |
1635 return focusedElement->containsIncludingShadowDOM(m_selection.start().anchor
Node()); | 1635 return focusedElement->containsIncludingShadowDOM(m_selection.start().anchor
Node()); |
1636 } | 1636 } |
1637 | 1637 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 void FrameSelection::setSelectionFromNone() | 1806 void FrameSelection::setSelectionFromNone() |
1807 { | 1807 { |
1808 // Put a caret inside the body if the entire frame is editable (either the | 1808 // Put a caret inside the body if the entire frame is editable (either the |
1809 // entire WebView is editable or designMode is on for this document). | 1809 // entire WebView is editable or designMode is on for this document). |
1810 | 1810 |
1811 Document* document = m_frame->document(); | 1811 Document* document = m_frame->document(); |
1812 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi
ngEnabled(); | 1812 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi
ngEnabled(); |
1813 if (!isNone() || !(document->hasEditableStyle() || caretBrowsing)) | 1813 if (!isNone() || !(document->hasEditableStyle() || caretBrowsing)) |
1814 return; | 1814 return; |
1815 | 1815 |
1816 Node* node = document->documentElement(); | 1816 Element* documentElement = document->documentElement(); |
1817 if (!node) | 1817 if (!documentElement) |
1818 return; | 1818 return; |
1819 Node* body = isHTMLBodyElement(*node) ? node : Traversal<HTMLBodyElement>::n
ext(*node); | 1819 HTMLBodyElement* body = isHTMLBodyElement(*documentElement) ? toHTMLBodyElem
ent(documentElement) : Traversal<HTMLBodyElement>::next(*documentElement); |
1820 if (body) | 1820 if (body) |
1821 setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), DOWNSTR
EAM)); | 1821 setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), DOWNSTR
EAM)); |
1822 } | 1822 } |
1823 | 1823 |
1824 bool FrameSelection::dispatchSelectStart() | 1824 bool FrameSelection::dispatchSelectStart() |
1825 { | 1825 { |
1826 Node* selectStartTarget = m_selection.extent().containerNode(); | 1826 Node* selectStartTarget = m_selection.extent().containerNode(); |
1827 if (!selectStartTarget) | 1827 if (!selectStartTarget) |
1828 return true; | 1828 return true; |
1829 | 1829 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 sel.showTreeForThis(); | 1918 sel.showTreeForThis(); |
1919 } | 1919 } |
1920 | 1920 |
1921 void showTree(const blink::FrameSelection* sel) | 1921 void showTree(const blink::FrameSelection* sel) |
1922 { | 1922 { |
1923 if (sel) | 1923 if (sel) |
1924 sel->showTreeForThis(); | 1924 sel->showTreeForThis(); |
1925 } | 1925 } |
1926 | 1926 |
1927 #endif | 1927 #endif |
OLD | NEW |