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 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 page->focusController()->setFocusedFrame(parent); | 1591 page->focusController()->setFocusedFrame(parent); |
1592 parent->selection()->setSelection(newSelection); | 1592 parent->selection()->setSelection(newSelection); |
1593 } | 1593 } |
1594 } | 1594 } |
1595 | 1595 |
1596 void FrameSelection::selectAll() | 1596 void FrameSelection::selectAll() |
1597 { | 1597 { |
1598 Document* document = m_frame->document(); | 1598 Document* document = m_frame->document(); |
1599 | 1599 |
1600 if (document->focusedNode() && document->focusedNode()->hasTagName(selectTag
)) { | 1600 if (document->focusedNode() && document->focusedNode()->hasTagName(selectTag
)) { |
1601 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focused
Node()); | 1601 Handle<HTMLSelectElement> selectElement = toHTMLSelectElement(document->
focusedNode()); |
1602 if (selectElement->canSelectAll()) { | 1602 if (selectElement->canSelectAll()) { |
1603 selectElement->selectAll(); | 1603 selectElement->selectAll(); |
1604 return; | 1604 return; |
1605 } | 1605 } |
1606 } | 1606 } |
1607 | 1607 |
1608 RefPtr<Node> root = 0; | 1608 RefPtr<Node> root = 0; |
1609 Node* selectStartTarget = 0; | 1609 Node* selectStartTarget = 0; |
1610 if (isContentEditable()) { | 1610 if (isContentEditable()) { |
1611 root = highestEditableRoot(m_selection.start()); | 1611 root = highestEditableRoot(m_selection.start()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 | 1654 |
1655 // FIXME: Can we provide extentAffinity? | 1655 // FIXME: Can we provide extentAffinity? |
1656 VisiblePosition visibleStart(range->startPosition(), collapsed ? affinity :
DOWNSTREAM); | 1656 VisiblePosition visibleStart(range->startPosition(), collapsed ? affinity :
DOWNSTREAM); |
1657 VisiblePosition visibleEnd(range->endPosition(), SEL_DEFAULT_AFFINITY); | 1657 VisiblePosition visibleEnd(range->endPosition(), SEL_DEFAULT_AFFINITY); |
1658 setSelection(VisibleSelection(visibleStart, visibleEnd), ClearTypingStyle |
(closeTyping ? CloseTyping : 0)); | 1658 setSelection(VisibleSelection(visibleStart, visibleEnd), ClearTypingStyle |
(closeTyping ? CloseTyping : 0)); |
1659 return true; | 1659 return true; |
1660 } | 1660 } |
1661 | 1661 |
1662 bool FrameSelection::isInPasswordField() const | 1662 bool FrameSelection::isInPasswordField() const |
1663 { | 1663 { |
1664 HTMLTextFormControlElement* textControl = enclosingTextFormControl(start()); | 1664 Handle<HTMLTextFormControlElement> textControl = enclosingTextFormControl(st
art()); |
1665 return textControl && textControl->hasTagName(inputTag) && static_cast<HTMLI
nputElement*>(textControl)->isPasswordField(); | 1665 return textControl && textControl->hasTagName(inputTag) && Handle<HTMLInputE
lement>::cast(textControl)->isPasswordField(); |
1666 } | 1666 } |
1667 | 1667 |
1668 void FrameSelection::focusedOrActiveStateChanged() | 1668 void FrameSelection::focusedOrActiveStateChanged() |
1669 { | 1669 { |
1670 bool activeAndFocused = isFocusedAndActive(); | 1670 bool activeAndFocused = isFocusedAndActive(); |
1671 | 1671 |
1672 // Because RenderObject::selectionBackgroundColor() and | 1672 // Because RenderObject::selectionBackgroundColor() and |
1673 // RenderObject::selectionForegroundColor() check if the frame is active, | 1673 // RenderObject::selectionForegroundColor() check if the frame is active, |
1674 // we have to update places those colors were painted. | 1674 // we have to update places those colors were painted. |
1675 if (RenderView* view = m_frame->document()->renderView()) | 1675 if (RenderView* view = m_frame->document()->renderView()) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 if (isCaretBlinkingSuspended() && caretPaint) | 1818 if (isCaretBlinkingSuspended() && caretPaint) |
1819 return; | 1819 return; |
1820 m_caretPaint = !caretPaint; | 1820 m_caretPaint = !caretPaint; |
1821 invalidateCaretRect(); | 1821 invalidateCaretRect(); |
1822 } | 1822 } |
1823 | 1823 |
1824 void FrameSelection::notifyRendererOfSelectionChange(EUserTriggered userTriggere
d) | 1824 void FrameSelection::notifyRendererOfSelectionChange(EUserTriggered userTriggere
d) |
1825 { | 1825 { |
1826 m_frame->document()->updateStyleIfNeeded(); | 1826 m_frame->document()->updateStyleIfNeeded(); |
1827 | 1827 |
1828 if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(start
())) | 1828 if (Handle<HTMLTextFormControlElement> textControl = enclosingTextFormContro
l(start())) |
1829 textControl->selectionChanged(userTriggered == UserTriggered); | 1829 textControl->selectionChanged(userTriggered == UserTriggered); |
1830 } | 1830 } |
1831 | 1831 |
1832 // Helper function that tells whether a particular node is an element that has a
n entire | 1832 // Helper function that tells whether a particular node is an element that has a
n entire |
1833 // Frame and FrameView, a <frame>, <iframe>, or <object>. | 1833 // Frame and FrameView, a <frame>, <iframe>, or <object>. |
1834 static bool isFrameElement(const Node* n) | 1834 static bool isFrameElement(const Node* n) |
1835 { | 1835 { |
1836 if (!n) | 1836 if (!n) |
1837 return false; | 1837 return false; |
1838 RenderObject* renderer = n->renderer(); | 1838 RenderObject* renderer = n->renderer(); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 sel.showTreeForThis(); | 2049 sel.showTreeForThis(); |
2050 } | 2050 } |
2051 | 2051 |
2052 void showTree(const WebCore::FrameSelection* sel) | 2052 void showTree(const WebCore::FrameSelection* sel) |
2053 { | 2053 { |
2054 if (sel) | 2054 if (sel) |
2055 sel->showTreeForThis(); | 2055 sel->showTreeForThis(); |
2056 } | 2056 } |
2057 | 2057 |
2058 #endif | 2058 #endif |
OLD | NEW |