| 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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 options); | 687 options); |
| 688 m_selectionEditor->setLogicalRange(logicalRange); | 688 m_selectionEditor->setLogicalRange(logicalRange); |
| 689 return true; | 689 return true; |
| 690 } | 690 } |
| 691 | 691 |
| 692 Range* FrameSelection::firstRange() const { | 692 Range* FrameSelection::firstRange() const { |
| 693 return m_selectionEditor->firstRange(); | 693 return m_selectionEditor->firstRange(); |
| 694 } | 694 } |
| 695 | 695 |
| 696 bool FrameSelection::isInPasswordField() const { | 696 bool FrameSelection::isInPasswordField() const { |
| 697 TextControlElement* textControl = enclosingTextControl(start()); | 697 TextControlElement* textControl = enclosingTextControl( |
| 698 computeVisibleSelectionInDOMTreeDeprecated().start()); |
| 698 return isHTMLInputElement(textControl) && | 699 return isHTMLInputElement(textControl) && |
| 699 toHTMLInputElement(textControl)->type() == InputTypeNames::password; | 700 toHTMLInputElement(textControl)->type() == InputTypeNames::password; |
| 700 } | 701 } |
| 701 | 702 |
| 702 void FrameSelection::notifyAccessibilityForSelectionChange() { | 703 void FrameSelection::notifyAccessibilityForSelectionChange() { |
| 703 if (selectionInDOMTree().isNone()) | 704 if (selectionInDOMTree().isNone()) |
| 704 return; | 705 return; |
| 705 AXObjectCache* cache = document().existingAXObjectCache(); | 706 AXObjectCache* cache = document().existingAXObjectCache(); |
| 706 if (!cache) | 707 if (!cache) |
| 707 return; | 708 return; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 return 0; | 939 return 0; |
| 939 } | 940 } |
| 940 | 941 |
| 941 // We look for either the form containing the current focus, or for one | 942 // We look for either the form containing the current focus, or for one |
| 942 // immediately after it | 943 // immediately after it |
| 943 HTMLFormElement* FrameSelection::currentForm() const { | 944 HTMLFormElement* FrameSelection::currentForm() const { |
| 944 // Start looking either at the active (first responder) node, or where the | 945 // Start looking either at the active (first responder) node, or where the |
| 945 // selection is. | 946 // selection is. |
| 946 Node* start = document().focusedElement(); | 947 Node* start = document().focusedElement(); |
| 947 if (!start) | 948 if (!start) |
| 948 start = this->start().anchorNode(); | 949 start = computeVisibleSelectionInDOMTreeDeprecated().start().anchorNode(); |
| 949 if (!start) | 950 if (!start) |
| 950 return 0; | 951 return 0; |
| 951 | 952 |
| 952 // Try walking up the node tree to find a form element. | 953 // Try walking up the node tree to find a form element. |
| 953 for (HTMLElement* element = | 954 for (HTMLElement* element = |
| 954 Traversal<HTMLElement>::firstAncestorOrSelf(*start); | 955 Traversal<HTMLElement>::firstAncestorOrSelf(*start); |
| 955 element; element = Traversal<HTMLElement>::firstAncestor(*element)) { | 956 element; element = Traversal<HTMLElement>::firstAncestor(*element)) { |
| 956 if (HTMLFormElement* form = associatedFormElement(*element)) | 957 if (HTMLFormElement* form = associatedFormElement(*element)) |
| 957 return form; | 958 return form; |
| 958 } | 959 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 979 rect = LayoutRect(absoluteCaretBounds()); | 980 rect = LayoutRect(absoluteCaretBounds()); |
| 980 break; | 981 break; |
| 981 case RangeSelection: | 982 case RangeSelection: |
| 982 rect = LayoutRect( | 983 rect = LayoutRect( |
| 983 revealExtentOption == RevealExtent | 984 revealExtentOption == RevealExtent |
| 984 ? absoluteCaretBoundsOf(createVisiblePosition(extent())) | 985 ? absoluteCaretBoundsOf(createVisiblePosition(extent())) |
| 985 : enclosingIntRect(unclippedBounds())); | 986 : enclosingIntRect(unclippedBounds())); |
| 986 break; | 987 break; |
| 987 } | 988 } |
| 988 | 989 |
| 989 Position start = this->start(); | 990 Position start = computeVisibleSelectionInDOMTreeDeprecated().start(); |
| 990 DCHECK(start.anchorNode()); | 991 DCHECK(start.anchorNode()); |
| 991 if (start.anchorNode() && start.anchorNode()->layoutObject()) { | 992 if (start.anchorNode() && start.anchorNode()->layoutObject()) { |
| 992 // FIXME: This code only handles scrolling the startContainer's layer, but | 993 // FIXME: This code only handles scrolling the startContainer's layer, but |
| 993 // the selection rect could intersect more than just that. | 994 // the selection rect could intersect more than just that. |
| 994 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) | 995 if (DocumentLoader* documentLoader = m_frame->loader().documentLoader()) |
| 995 documentLoader->initialScrollState().wasScrolledByUser = true; | 996 documentLoader->initialScrollState().wasScrolledByUser = true; |
| 996 if (start.anchorNode()->layoutObject()->scrollRectToVisible(rect, alignment, | 997 if (start.anchorNode()->layoutObject()->scrollRectToVisible(rect, alignment, |
| 997 alignment)) | 998 alignment)) |
| 998 updateAppearance(); | 999 updateAppearance(); |
| 999 } | 1000 } |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 } | 1178 } |
| 1178 | 1179 |
| 1179 void showTree(const blink::FrameSelection* sel) { | 1180 void showTree(const blink::FrameSelection* sel) { |
| 1180 if (sel) | 1181 if (sel) |
| 1181 sel->showTreeForThis(); | 1182 sel->showTreeForThis(); |
| 1182 else | 1183 else |
| 1183 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1184 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
| 1184 } | 1185 } |
| 1185 | 1186 |
| 1186 #endif | 1187 #endif |
| OLD | NEW |