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 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1744 | 1744 |
1745 // We look for either the form containing the current focus, or for one immediat ely after it | 1745 // We look for either the form containing the current focus, or for one immediat ely after it |
1746 HTMLFormElement* FrameSelection::currentForm() const | 1746 HTMLFormElement* FrameSelection::currentForm() const |
1747 { | 1747 { |
1748 // Start looking either at the active (first responder) node, or where the s election is. | 1748 // Start looking either at the active (first responder) node, or where the s election is. |
1749 Node* start = m_frame->document()->focusedElement(); | 1749 Node* start = m_frame->document()->focusedElement(); |
1750 if (!start) | 1750 if (!start) |
1751 start = this->start().deprecatedNode(); | 1751 start = this->start().deprecatedNode(); |
1752 | 1752 |
1753 // Try walking up the node tree to find a form element. | 1753 // Try walking up the node tree to find a form element. |
1754 Node* node; | 1754 HTMLElement* element = !start || start->isHTMLElement() ? toHTMLElement(star t) : Traversal<HTMLElement>::firstAncestor(*start); |
esprehn
2014/03/21 07:58:33
This seems like it makes the code less readable.
Inactive
2014/03/21 14:37:24
Fair enough, I gave it another shot.
| |
1755 for (node = start; node; node = node->parentNode()) { | 1755 for (; element; element = Traversal<HTMLElement>::firstAncestor(*element)) { |
1756 if (isHTMLFormElement(*node)) | 1756 if (isHTMLFormElement(*element)) |
1757 return toHTMLFormElement(node); | 1757 return toHTMLFormElement(element); |
1758 if (node->isHTMLElement()) { | 1758 if (HTMLFormElement* owner = element->formOwner()) |
1759 HTMLFormElement* owner = toHTMLElement(node)->formOwner(); | 1759 return owner; |
1760 if (owner) | |
1761 return owner; | |
1762 } | |
1763 } | 1760 } |
1764 | 1761 |
1765 // Try walking forward in the node tree to find a form element. | 1762 // Try walking forward in the node tree to find a form element. |
1766 return scanForForm(start); | 1763 return scanForForm(start); |
1767 } | 1764 } |
1768 | 1765 |
1769 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt entOption revealExtentOption) | 1766 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt entOption revealExtentOption) |
1770 { | 1767 { |
1771 LayoutRect rect; | 1768 LayoutRect rect; |
1772 | 1769 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1875 sel.showTreeForThis(); | 1872 sel.showTreeForThis(); |
1876 } | 1873 } |
1877 | 1874 |
1878 void showTree(const WebCore::FrameSelection* sel) | 1875 void showTree(const WebCore::FrameSelection* sel) |
1879 { | 1876 { |
1880 if (sel) | 1877 if (sel) |
1881 sel->showTreeForThis(); | 1878 sel->showTreeForThis(); |
1882 } | 1879 } |
1883 | 1880 |
1884 #endif | 1881 #endif |
OLD | NEW |