Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: Source/core/editing/FrameSelection.cpp

Issue 106423005: Only 'form associated' elements have a potential form owner. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/html/HTMLElement.h » ('j') | Source/core/html/HTMLElement.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 1732
1733 // Scans logically forward from "start", including any child frames. 1733 // Scans logically forward from "start", including any child frames.
1734 static HTMLFormElement* scanForForm(Node* start) 1734 static HTMLFormElement* scanForForm(Node* start)
1735 { 1735 {
1736 if (!start) 1736 if (!start)
1737 return 0; 1737 return 0;
1738 Element* element = start->isElementNode() ? toElement(start) : ElementTraver sal::next(*start); 1738 Element* element = start->isElementNode() ? toElement(start) : ElementTraver sal::next(*start);
1739 for (; element; element = ElementTraversal::next(*element)) { 1739 for (; element; element = ElementTraversal::next(*element)) {
1740 if (element->hasTagName(formTag)) 1740 if (element->hasTagName(formTag))
1741 return toHTMLFormElement(element); 1741 return toHTMLFormElement(element);
1742 if (element->isHTMLElement() && toHTMLElement(element)->isFormControlEle ment()) 1742 if (element->isHTMLElement()) {
1743 return toHTMLFormControlElement(element)->form(); 1743 HTMLFormElement* owner = toHTMLElement(element)->formOwner();
arv (Not doing code reviews) 2013/12/10 20:37:20 You could do: if (HTMLFormElement* owner = toHTML
1744 if (owner)
1745 return owner;
1746 }
1744 if (element->hasTagName(frameTag) || element->hasTagName(iframeTag)) { 1747 if (element->hasTagName(frameTag) || element->hasTagName(iframeTag)) {
1745 Node* childDocument = toHTMLFrameElementBase(element)->contentDocume nt(); 1748 Node* childDocument = toHTMLFrameElementBase(element)->contentDocume nt();
1746 if (HTMLFormElement* frameResult = scanForForm(childDocument)) 1749 if (HTMLFormElement* frameResult = scanForForm(childDocument))
1747 return frameResult; 1750 return frameResult;
1748 } 1751 }
1749 } 1752 }
1750 return 0; 1753 return 0;
1751 } 1754 }
1752 1755
1753 // We look for either the form containing the current focus, or for one immediat ely after it 1756 // We look for either the form containing the current focus, or for one immediat ely after it
1754 HTMLFormElement* FrameSelection::currentForm() const 1757 HTMLFormElement* FrameSelection::currentForm() const
1755 { 1758 {
1756 // Start looking either at the active (first responder) node, or where the s election is. 1759 // Start looking either at the active (first responder) node, or where the s election is.
1757 Node* start = m_frame->document()->focusedElement(); 1760 Node* start = m_frame->document()->focusedElement();
1758 if (!start) 1761 if (!start)
1759 start = this->start().deprecatedNode(); 1762 start = this->start().deprecatedNode();
1760 1763
1761 // Try walking up the node tree to find a form element. 1764 // Try walking up the node tree to find a form element.
1762 Node* node; 1765 Node* node;
1763 for (node = start; node; node = node->parentNode()) { 1766 for (node = start; node; node = node->parentNode()) {
1764 if (node->hasTagName(formTag)) 1767 if (node->hasTagName(formTag))
1765 return toHTMLFormElement(node); 1768 return toHTMLFormElement(node);
1766 if (node->isHTMLElement() && toHTMLElement(node)->isFormControlElement() ) 1769 if (node->isHTMLElement()) {
1767 return toHTMLFormControlElement(node)->form(); 1770 HTMLFormElement* owner = toHTMLElement(node)->formOwner();
1771 if (owner)
1772 return owner;
1773 }
1768 } 1774 }
1769 1775
1770 // Try walking forward in the node tree to find a form element. 1776 // Try walking forward in the node tree to find a form element.
1771 return scanForForm(start); 1777 return scanForForm(start);
1772 } 1778 }
1773 1779
1774 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt entOption revealExtentOption) 1780 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt entOption revealExtentOption)
1775 { 1781 {
1776 LayoutRect rect; 1782 LayoutRect rect;
1777 1783
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 sel.showTreeForThis(); 1861 sel.showTreeForThis();
1856 } 1862 }
1857 1863
1858 void showTree(const WebCore::FrameSelection* sel) 1864 void showTree(const WebCore::FrameSelection* sel)
1859 { 1865 {
1860 if (sel) 1866 if (sel)
1861 sel->showTreeForThis(); 1867 sel->showTreeForThis();
1862 } 1868 }
1863 1869
1864 #endif 1870 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/HTMLElement.h » ('j') | Source/core/html/HTMLElement.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698