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 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 // Scans logically forward from "start", including any child frames. | 1956 // Scans logically forward from "start", including any child frames. |
1957 static HTMLFormElement* scanForForm(Node* start) | 1957 static HTMLFormElement* scanForForm(Node* start) |
1958 { | 1958 { |
1959 if (!start) | 1959 if (!start) |
1960 return 0; | 1960 return 0; |
1961 Element* element = start->isElementNode() ? toElement(start) : ElementTraver
sal::next(start); | 1961 Element* element = start->isElementNode() ? toElement(start) : ElementTraver
sal::next(start); |
1962 for (; element; element = ElementTraversal::next(element)) { | 1962 for (; element; element = ElementTraversal::next(element)) { |
1963 if (element->hasTagName(formTag)) | 1963 if (element->hasTagName(formTag)) |
1964 return static_cast<HTMLFormElement*>(element); | 1964 return static_cast<HTMLFormElement*>(element); |
1965 if (element->isHTMLElement() && toHTMLElement(element)->isFormControlEle
ment()) | 1965 if (element->isHTMLElement() && toHTMLElement(element)->isFormControlEle
ment()) |
1966 return static_cast<HTMLFormControlElement*>(element)->form(); | 1966 return toHTMLFormControlElement(element)->form(); |
1967 if (element->hasTagName(frameTag) || element->hasTagName(iframeTag)) { | 1967 if (element->hasTagName(frameTag) || element->hasTagName(iframeTag)) { |
1968 Node* childDocument = static_cast<HTMLFrameElementBase*>(element)->c
ontentDocument(); | 1968 Node* childDocument = static_cast<HTMLFrameElementBase*>(element)->c
ontentDocument(); |
1969 if (HTMLFormElement* frameResult = scanForForm(childDocument)) | 1969 if (HTMLFormElement* frameResult = scanForForm(childDocument)) |
1970 return frameResult; | 1970 return frameResult; |
1971 } | 1971 } |
1972 } | 1972 } |
1973 return 0; | 1973 return 0; |
1974 } | 1974 } |
1975 | 1975 |
1976 // We look for either the form containing the current focus, or for one immediat
ely after it | 1976 // We look for either the form containing the current focus, or for one immediat
ely after it |
1977 HTMLFormElement* FrameSelection::currentForm() const | 1977 HTMLFormElement* FrameSelection::currentForm() const |
1978 { | 1978 { |
1979 // Start looking either at the active (first responder) node, or where the s
election is. | 1979 // Start looking either at the active (first responder) node, or where the s
election is. |
1980 Node* start = m_frame->document()->focusedNode(); | 1980 Node* start = m_frame->document()->focusedNode(); |
1981 if (!start) | 1981 if (!start) |
1982 start = this->start().deprecatedNode(); | 1982 start = this->start().deprecatedNode(); |
1983 | 1983 |
1984 // Try walking up the node tree to find a form element. | 1984 // Try walking up the node tree to find a form element. |
1985 Node* node; | 1985 Node* node; |
1986 for (node = start; node; node = node->parentNode()) { | 1986 for (node = start; node; node = node->parentNode()) { |
1987 if (node->hasTagName(formTag)) | 1987 if (node->hasTagName(formTag)) |
1988 return static_cast<HTMLFormElement*>(node); | 1988 return static_cast<HTMLFormElement*>(node); |
1989 if (node->isHTMLElement() && toHTMLElement(node)->isFormControlElement()
) | 1989 if (node->isHTMLElement() && toHTMLElement(node)->isFormControlElement()
) |
1990 return static_cast<HTMLFormControlElement*>(node)->form(); | 1990 return toHTMLFormControlElement(node)->form(); |
1991 } | 1991 } |
1992 | 1992 |
1993 // Try walking forward in the node tree to find a form element. | 1993 // Try walking forward in the node tree to find a form element. |
1994 return scanForForm(start); | 1994 return scanForForm(start); |
1995 } | 1995 } |
1996 | 1996 |
1997 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt
entOption revealExtentOption) | 1997 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt
entOption revealExtentOption) |
1998 { | 1998 { |
1999 LayoutRect rect; | 1999 LayoutRect rect; |
2000 | 2000 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 sel.showTreeForThis(); | 2089 sel.showTreeForThis(); |
2090 } | 2090 } |
2091 | 2091 |
2092 void showTree(const WebCore::FrameSelection* sel) | 2092 void showTree(const WebCore::FrameSelection* sel) |
2093 { | 2093 { |
2094 if (sel) | 2094 if (sel) |
2095 sel->showTreeForThis(); | 2095 sel->showTreeForThis(); |
2096 } | 2096 } |
2097 | 2097 |
2098 #endif | 2098 #endif |
OLD | NEW |