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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 if (output.length() >= maxChars) | 234 if (output.length() >= maxChars) |
235 return; // Filled up the buffer. | 235 return; // Filled up the buffer. |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 // The separator between frames when the frames are converted to plain text. | 239 // The separator between frames when the frames are converted to plain text. |
240 const LChar frameSeparator[] = { '\n', '\n' }; | 240 const LChar frameSeparator[] = { '\n', '\n' }; |
241 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator); | 241 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator); |
242 | 242 |
243 // Recursively walk the children. | 243 // Recursively walk the children. |
244 FrameTree* frameTree = frame->tree(); | 244 const FrameTree& frameTree = frame->tree(); |
245 for (Frame* curChild = frameTree->firstChild(); curChild; curChild = curChil
d->tree()->nextSibling()) { | 245 for (Frame* curChild = frameTree.firstChild(); curChild; curChild = curChild
->tree().nextSibling()) { |
246 // Ignore the text of non-visible frames. | 246 // Ignore the text of non-visible frames. |
247 RenderView* contentRenderer = curChild->contentRenderer(); | 247 RenderView* contentRenderer = curChild->contentRenderer(); |
248 RenderPart* ownerRenderer = curChild->ownerRenderer(); | 248 RenderPart* ownerRenderer = curChild->ownerRenderer(); |
249 if (!contentRenderer || !contentRenderer->width() || !contentRenderer->h
eight() | 249 if (!contentRenderer || !contentRenderer->width() || !contentRenderer->h
eight() |
250 || (contentRenderer->x() + contentRenderer->width() <= 0) || (conten
tRenderer->y() + contentRenderer->height() <= 0) | 250 || (contentRenderer->x() + contentRenderer->width() <= 0) || (conten
tRenderer->y() + contentRenderer->height() <= 0) |
251 || (ownerRenderer && ownerRenderer->style() && ownerRenderer->style(
)->visibility() != VISIBLE)) { | 251 || (ownerRenderer && ownerRenderer->style() && ownerRenderer->style(
)->visibility() != VISIBLE)) { |
252 continue; | 252 continue; |
253 } | 253 } |
254 | 254 |
255 // Make sure the frame separator won't fill up the buffer, and give up i
f | 255 // Make sure the frame separator won't fill up the buffer, and give up i
f |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 } | 522 } |
523 | 523 |
524 void WebFrameImpl::close() | 524 void WebFrameImpl::close() |
525 { | 525 { |
526 m_client = 0; | 526 m_client = 0; |
527 deref(); // Balances ref() acquired in WebFrame::create | 527 deref(); // Balances ref() acquired in WebFrame::create |
528 } | 528 } |
529 | 529 |
530 WebString WebFrameImpl::uniqueName() const | 530 WebString WebFrameImpl::uniqueName() const |
531 { | 531 { |
532 return frame()->tree()->uniqueName(); | 532 return frame()->tree().uniqueName(); |
533 } | 533 } |
534 | 534 |
535 WebString WebFrameImpl::assignedName() const | 535 WebString WebFrameImpl::assignedName() const |
536 { | 536 { |
537 return frame()->tree()->name(); | 537 return frame()->tree().name(); |
538 } | 538 } |
539 | 539 |
540 void WebFrameImpl::setName(const WebString& name) | 540 void WebFrameImpl::setName(const WebString& name) |
541 { | 541 { |
542 frame()->tree()->setName(name); | 542 frame()->tree().setName(name); |
543 } | 543 } |
544 | 544 |
545 long long WebFrameImpl::embedderIdentifier() const | 545 long long WebFrameImpl::embedderIdentifier() const |
546 { | 546 { |
547 return m_embedderIdentifier; | 547 return m_embedderIdentifier; |
548 } | 548 } |
549 | 549 |
550 WebVector<WebIconURL> WebFrameImpl::iconURLs(int iconTypesMask) const | 550 WebVector<WebIconURL> WebFrameImpl::iconURLs(int iconTypesMask) const |
551 { | 551 { |
552 // The URL to the icon may be in the header. As such, only | 552 // The URL to the icon may be in the header. As such, only |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 | 625 |
626 void WebFrameImpl::setOpener(const WebFrame* webFrame) | 626 void WebFrameImpl::setOpener(const WebFrame* webFrame) |
627 { | 627 { |
628 frame()->loader()->setOpener(webFrame ? toWebFrameImpl(webFrame)->frame() :
0); | 628 frame()->loader()->setOpener(webFrame ? toWebFrameImpl(webFrame)->frame() :
0); |
629 } | 629 } |
630 | 630 |
631 WebFrame* WebFrameImpl::parent() const | 631 WebFrame* WebFrameImpl::parent() const |
632 { | 632 { |
633 if (!frame()) | 633 if (!frame()) |
634 return 0; | 634 return 0; |
635 return fromFrame(frame()->tree()->parent()); | 635 return fromFrame(frame()->tree().parent()); |
636 } | 636 } |
637 | 637 |
638 WebFrame* WebFrameImpl::top() const | 638 WebFrame* WebFrameImpl::top() const |
639 { | 639 { |
640 if (!frame()) | 640 if (!frame()) |
641 return 0; | 641 return 0; |
642 return fromFrame(frame()->tree()->top()); | 642 return fromFrame(frame()->tree().top()); |
643 } | 643 } |
644 | 644 |
645 WebFrame* WebFrameImpl::firstChild() const | 645 WebFrame* WebFrameImpl::firstChild() const |
646 { | 646 { |
647 if (!frame()) | 647 if (!frame()) |
648 return 0; | 648 return 0; |
649 return fromFrame(frame()->tree()->firstChild()); | 649 return fromFrame(frame()->tree().firstChild()); |
650 } | 650 } |
651 | 651 |
652 WebFrame* WebFrameImpl::lastChild() const | 652 WebFrame* WebFrameImpl::lastChild() const |
653 { | 653 { |
654 if (!frame()) | 654 if (!frame()) |
655 return 0; | 655 return 0; |
656 return fromFrame(frame()->tree()->lastChild()); | 656 return fromFrame(frame()->tree().lastChild()); |
657 } | 657 } |
658 | 658 |
659 WebFrame* WebFrameImpl::nextSibling() const | 659 WebFrame* WebFrameImpl::nextSibling() const |
660 { | 660 { |
661 if (!frame()) | 661 if (!frame()) |
662 return 0; | 662 return 0; |
663 return fromFrame(frame()->tree()->nextSibling()); | 663 return fromFrame(frame()->tree().nextSibling()); |
664 } | 664 } |
665 | 665 |
666 WebFrame* WebFrameImpl::previousSibling() const | 666 WebFrame* WebFrameImpl::previousSibling() const |
667 { | 667 { |
668 if (!frame()) | 668 if (!frame()) |
669 return 0; | 669 return 0; |
670 return fromFrame(frame()->tree()->previousSibling()); | 670 return fromFrame(frame()->tree().previousSibling()); |
671 } | 671 } |
672 | 672 |
673 WebFrame* WebFrameImpl::traverseNext(bool wrap) const | 673 WebFrame* WebFrameImpl::traverseNext(bool wrap) const |
674 { | 674 { |
675 if (!frame()) | 675 if (!frame()) |
676 return 0; | 676 return 0; |
677 return fromFrame(frame()->tree()->traverseNextWithWrap(wrap)); | 677 return fromFrame(frame()->tree().traverseNextWithWrap(wrap)); |
678 } | 678 } |
679 | 679 |
680 WebFrame* WebFrameImpl::traversePrevious(bool wrap) const | 680 WebFrame* WebFrameImpl::traversePrevious(bool wrap) const |
681 { | 681 { |
682 if (!frame()) | 682 if (!frame()) |
683 return 0; | 683 return 0; |
684 return fromFrame(frame()->tree()->traversePreviousWithWrap(wrap)); | 684 return fromFrame(frame()->tree().traversePreviousWithWrap(wrap)); |
685 } | 685 } |
686 | 686 |
687 WebFrame* WebFrameImpl::findChildByName(const WebString& name) const | 687 WebFrame* WebFrameImpl::findChildByName(const WebString& name) const |
688 { | 688 { |
689 if (!frame()) | 689 if (!frame()) |
690 return 0; | 690 return 0; |
691 return fromFrame(frame()->tree()->child(name)); | 691 return fromFrame(frame()->tree().child(name)); |
692 } | 692 } |
693 | 693 |
694 WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const | 694 WebFrame* WebFrameImpl::findChildByExpression(const WebString& xpath) const |
695 { | 695 { |
696 if (xpath.isEmpty()) | 696 if (xpath.isEmpty()) |
697 return 0; | 697 return 0; |
698 | 698 |
699 Document* document = frame()->document(); | 699 Document* document = frame()->document(); |
700 | 700 |
701 RefPtr<XPathResult> xpathResult = DocumentXPathEvaluator::evaluate(document,
xpath, document, 0, XPathResult::ORDERED_NODE_ITERATOR_TYPE, 0, IGNORE_EXCEPTIO
N); | 701 RefPtr<XPathResult> xpathResult = DocumentXPathEvaluator::evaluate(document,
xpath, document, 0, XPathResult::ORDERED_NODE_ITERATOR_TYPE, 0, IGNORE_EXCEPTIO
N); |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 viewImpl()->mainFrameImpl()->m_findMatchMarkersVersion++; | 1825 viewImpl()->mainFrameImpl()->m_findMatchMarkersVersion++; |
1826 | 1826 |
1827 m_findMatchesCache.clear(); | 1827 m_findMatchesCache.clear(); |
1828 m_findMatchRectsAreValid = false; | 1828 m_findMatchRectsAreValid = false; |
1829 } | 1829 } |
1830 | 1830 |
1831 bool WebFrameImpl::isActiveMatchFrameValid() const | 1831 bool WebFrameImpl::isActiveMatchFrameValid() const |
1832 { | 1832 { |
1833 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); | 1833 WebFrameImpl* mainFrameImpl = viewImpl()->mainFrameImpl(); |
1834 WebFrameImpl* activeMatchFrame = mainFrameImpl->activeMatchFrame(); | 1834 WebFrameImpl* activeMatchFrame = mainFrameImpl->activeMatchFrame(); |
1835 return activeMatchFrame && activeMatchFrame->m_activeMatch && activeMatchFra
me->frame()->tree()->isDescendantOf(mainFrameImpl->frame()); | 1835 return activeMatchFrame && activeMatchFrame->m_activeMatch && activeMatchFra
me->frame()->tree().isDescendantOf(mainFrameImpl->frame()); |
1836 } | 1836 } |
1837 | 1837 |
1838 void WebFrameImpl::updateFindMatchRects() | 1838 void WebFrameImpl::updateFindMatchRects() |
1839 { | 1839 { |
1840 IntSize currentContentsSize = contentsSize(); | 1840 IntSize currentContentsSize = contentsSize(); |
1841 if (m_contentsSizeForCurrentFindMatchRects != currentContentsSize) { | 1841 if (m_contentsSizeForCurrentFindMatchRects != currentContentsSize) { |
1842 m_contentsSizeForCurrentFindMatchRects = currentContentsSize; | 1842 m_contentsSizeForCurrentFindMatchRects = currentContentsSize; |
1843 m_findMatchRectsAreValid = false; | 1843 m_findMatchRectsAreValid = false; |
1844 } | 1844 } |
1845 | 1845 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2166 } | 2166 } |
2167 | 2167 |
2168 // Add an extra ref on behalf of the page/FrameLoader, which references the | 2168 // Add an extra ref on behalf of the page/FrameLoader, which references the |
2169 // WebFrame via the FrameLoaderClient interface. See the comment at the top | 2169 // WebFrame via the FrameLoaderClient interface. See the comment at the top |
2170 // of this file for more info. | 2170 // of this file for more info. |
2171 webframe->ref(); | 2171 webframe->ref(); |
2172 | 2172 |
2173 RefPtr<Frame> childFrame = Frame::create(frame()->page(), ownerElement, &web
frame->m_frameLoaderClient); | 2173 RefPtr<Frame> childFrame = Frame::create(frame()->page(), ownerElement, &web
frame->m_frameLoaderClient); |
2174 webframe->setWebCoreFrame(childFrame.get()); | 2174 webframe->setWebCoreFrame(childFrame.get()); |
2175 | 2175 |
2176 childFrame->tree()->setName(request.frameName()); | 2176 childFrame->tree().setName(request.frameName()); |
2177 | 2177 |
2178 frame()->tree()->appendChild(childFrame); | 2178 frame()->tree().appendChild(childFrame); |
2179 | 2179 |
2180 // FIXME: Remove once all embedders return non-null from createChildFrame(). | 2180 // FIXME: Remove once all embedders return non-null from createChildFrame(). |
2181 if (mustCallDidCreateFrame) | 2181 if (mustCallDidCreateFrame) |
2182 m_client->didCreateFrame(this, webframe); | 2182 m_client->didCreateFrame(this, webframe); |
2183 | 2183 |
2184 // Frame::init() can trigger onload event in the parent frame, | 2184 // Frame::init() can trigger onload event in the parent frame, |
2185 // which may detach this frame and trigger a null-pointer access | 2185 // which may detach this frame and trigger a null-pointer access |
2186 // in FrameTree::removeChild. Move init() after appendChild call | 2186 // in FrameTree::removeChild. Move init() after appendChild call |
2187 // so that webframe->mFrame is in the tree before triggering | 2187 // so that webframe->mFrame is in the tree before triggering |
2188 // onload event handler. | 2188 // onload event handler. |
2189 // Because the event handler may set webframe->mFrame to null, | 2189 // Because the event handler may set webframe->mFrame to null, |
2190 // it is necessary to check the value after calling init() and | 2190 // it is necessary to check the value after calling init() and |
2191 // return without loading URL. | 2191 // return without loading URL. |
2192 // NOTE: m_client will be null if this frame has been detached. | 2192 // NOTE: m_client will be null if this frame has been detached. |
2193 // (b:791612) | 2193 // (b:791612) |
2194 childFrame->init(); // create an empty document | 2194 childFrame->init(); // create an empty document |
2195 if (!childFrame->tree()->parent()) | 2195 if (!childFrame->tree().parent()) |
2196 return 0; | 2196 return 0; |
2197 | 2197 |
2198 HistoryItem* parentItem = frame()->loader()->history()->currentItem(); | 2198 HistoryItem* parentItem = frame()->loader()->history()->currentItem(); |
2199 HistoryItem* childItem = 0; | 2199 HistoryItem* childItem = 0; |
2200 // If we're moving in the back/forward list, we might want to replace the co
ntent | 2200 // If we're moving in the back/forward list, we might want to replace the co
ntent |
2201 // of this child frame with whatever was there at that point. | 2201 // of this child frame with whatever was there at that point. |
2202 if (parentItem && parentItem->children().size() && isBackForwardLoadType(fra
me()->loader()->loadType()) && !frame()->document()->loadEventFinished()) | 2202 if (parentItem && parentItem->children().size() && isBackForwardLoadType(fra
me()->loader()->loadType()) && !frame()->document()->loadEventFinished()) |
2203 childItem = parentItem->childItemWithTarget(childFrame->tree()->uniqueNa
me()); | 2203 childItem = parentItem->childItemWithTarget(childFrame->tree().uniqueNam
e()); |
2204 | 2204 |
2205 if (childItem) | 2205 if (childItem) |
2206 childFrame->loader()->loadHistoryItem(childItem); | 2206 childFrame->loader()->loadHistoryItem(childItem); |
2207 else | 2207 else |
2208 childFrame->loader()->load(FrameLoadRequest(0, request.resourceRequest()
, "_self")); | 2208 childFrame->loader()->load(FrameLoadRequest(0, request.resourceRequest()
, "_self")); |
2209 | 2209 |
2210 // A synchronous navigation (about:blank) would have already processed | 2210 // A synchronous navigation (about:blank) would have already processed |
2211 // onload, so it is possible for the frame to have already been destroyed by | 2211 // onload, so it is possible for the frame to have already been destroyed by |
2212 // script in the page. | 2212 // script in the page. |
2213 // NOTE: m_client will be null if this frame has been detached. | 2213 // NOTE: m_client will be null if this frame has been detached. |
2214 if (!childFrame->tree()->parent()) | 2214 if (!childFrame->tree().parent()) |
2215 return 0; | 2215 return 0; |
2216 | 2216 |
2217 return childFrame.release(); | 2217 return childFrame.release(); |
2218 } | 2218 } |
2219 | 2219 |
2220 void WebFrameImpl::didChangeContentsSize(const IntSize& size) | 2220 void WebFrameImpl::didChangeContentsSize(const IntSize& size) |
2221 { | 2221 { |
2222 // This is only possible on the main frame. | 2222 // This is only possible on the main frame. |
2223 if (m_totalMatchCount > 0) { | 2223 if (m_totalMatchCount > 0) { |
2224 ASSERT(!parent()); | 2224 ASSERT(!parent()); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2517 | 2517 |
2518 // There is a possibility that the frame being detached was the only | 2518 // There is a possibility that the frame being detached was the only |
2519 // pending one. We need to make sure final replies can be sent. | 2519 // pending one. We need to make sure final replies can be sent. |
2520 flushCurrentScopingEffort(m_findRequestIdentifier); | 2520 flushCurrentScopingEffort(m_findRequestIdentifier); |
2521 | 2521 |
2522 cancelPendingScopingEffort(); | 2522 cancelPendingScopingEffort(); |
2523 } | 2523 } |
2524 } | 2524 } |
2525 | 2525 |
2526 } // namespace WebKit | 2526 } // namespace WebKit |
OLD | NEW |