OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 return WebDocument(); | 698 return WebDocument(); |
699 return WebDocument(m_frame->document()); | 699 return WebDocument(m_frame->document()); |
700 } | 700 } |
701 | 701 |
702 void WebFrameImpl::forms(WebVector<WebFormElement>& results) const | 702 void WebFrameImpl::forms(WebVector<WebFormElement>& results) const |
703 { | 703 { |
704 if (!m_frame) | 704 if (!m_frame) |
705 return; | 705 return; |
706 | 706 |
707 RefPtr<HTMLCollection> forms = m_frame->document()->forms(); | 707 RefPtr<HTMLCollection> forms = m_frame->document()->forms(); |
708 size_t formCount = 0; | 708 size_t sourceLength = forms->length(); |
709 for (size_t i = 0; i < forms->length(); ++i) { | 709 Vector<WebFormElement> temp; |
| 710 temp.reserveCapacity(sourceLength); |
| 711 for (size_t i = 0; i < sourceLength; ++i) { |
710 Node* node = forms->item(i); | 712 Node* node = forms->item(i); |
| 713 // Strange but true, sometimes node can be 0. |
711 if (node && node->isHTMLElement()) | 714 if (node && node->isHTMLElement()) |
712 ++formCount; | 715 temp.append(WebFormElement(static_cast<HTMLFormElement*>(node))); |
713 } | 716 } |
714 | 717 results.assign(temp); |
715 WebVector<WebFormElement> temp(formCount); | |
716 size_t j = 0; | |
717 for (size_t sourceIndex = 0; j < forms->length(); ++sourceIndex) { | |
718 Node* node = forms->item(sourceIndex); | |
719 // Strange but true, sometimes item can be 0. | |
720 if (node && node->isHTMLElement()) | |
721 temp[j++] = static_cast<HTMLFormElement*>(node); | |
722 } | |
723 ASSERT(j == formCount); | |
724 results.swap(temp); | |
725 } | 718 } |
726 | 719 |
727 WebAnimationController* WebFrameImpl::animationController() | 720 WebAnimationController* WebFrameImpl::animationController() |
728 { | 721 { |
729 return &m_animationController; | 722 return &m_animationController; |
730 } | 723 } |
731 | 724 |
732 WebPerformance WebFrameImpl::performance() const | 725 WebPerformance WebFrameImpl::performance() const |
733 { | 726 { |
734 if (!m_frame || !m_frame->domWindow()) | 727 if (!m_frame || !m_frame->domWindow()) |
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2366 | 2359 |
2367 String scriptResult; | 2360 String scriptResult; |
2368 if (!result.getString(scriptResult)) | 2361 if (!result.getString(scriptResult)) |
2369 return; | 2362 return; |
2370 | 2363 |
2371 if (!m_frame->navigationScheduler()->locationChangePending()) | 2364 if (!m_frame->navigationScheduler()->locationChangePending()) |
2372 m_frame->document()->loader()->writer()->replaceDocument(scriptResult); | 2365 m_frame->document()->loader()->writer()->replaceDocument(scriptResult); |
2373 } | 2366 } |
2374 | 2367 |
2375 } // namespace WebKit | 2368 } // namespace WebKit |
OLD | NEW |