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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 return; // Filled up the buffer. | 231 return; // Filled up the buffer. |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 // The separator between frames when the frames are converted to plain text. | 235 // The separator between frames when the frames are converted to plain text. |
236 const LChar frameSeparator[] = { '\n', '\n' }; | 236 const LChar frameSeparator[] = { '\n', '\n' }; |
237 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator); | 237 const size_t frameSeparatorLength = WTF_ARRAY_LENGTH(frameSeparator); |
238 | 238 |
239 // Recursively walk the children. | 239 // Recursively walk the children. |
240 const FrameTree& frameTree = frame->tree(); | 240 const FrameTree& frameTree = frame->tree(); |
241 for (LocalFrame* curChild = frameTree.firstChild(); curChild; curChild = cur
Child->tree().nextSibling()) { | 241 for (Frame* curChild = frameTree.firstChild(); curChild; curChild = curChild
->tree().nextSibling()) { |
| 242 if (!curChild->isLocalFrame()) |
| 243 continue; |
| 244 LocalFrame* curLocalChild = toLocalFrame(curChild); |
242 // Ignore the text of non-visible frames. | 245 // Ignore the text of non-visible frames. |
243 RenderView* contentRenderer = curChild->contentRenderer(); | 246 RenderView* contentRenderer = curLocalChild->contentRenderer(); |
244 RenderPart* ownerRenderer = curChild->ownerRenderer(); | 247 RenderPart* ownerRenderer = curLocalChild->ownerRenderer(); |
245 if (!contentRenderer || !contentRenderer->width() || !contentRenderer->h
eight() | 248 if (!contentRenderer || !contentRenderer->width() || !contentRenderer->h
eight() |
246 || (contentRenderer->x() + contentRenderer->width() <= 0) || (conten
tRenderer->y() + contentRenderer->height() <= 0) | 249 || (contentRenderer->x() + contentRenderer->width() <= 0) || (conten
tRenderer->y() + contentRenderer->height() <= 0) |
247 || (ownerRenderer && ownerRenderer->style() && ownerRenderer->style(
)->visibility() != VISIBLE)) { | 250 || (ownerRenderer && ownerRenderer->style() && ownerRenderer->style(
)->visibility() != VISIBLE)) { |
248 continue; | 251 continue; |
249 } | 252 } |
250 | 253 |
251 // Make sure the frame separator won't fill up the buffer, and give up i
f | 254 // Make sure the frame separator won't fill up the buffer, and give up i
f |
252 // it will. The danger is if the separator will make the buffer longer t
han | 255 // it will. The danger is if the separator will make the buffer longer t
han |
253 // maxChars. This will cause the computation above: | 256 // maxChars. This will cause the computation above: |
254 // maxChars - output->size() | 257 // maxChars - output->size() |
255 // to be a negative number which will crash when the subframe is added. | 258 // to be a negative number which will crash when the subframe is added. |
256 if (output.length() >= maxChars - frameSeparatorLength) | 259 if (output.length() >= maxChars - frameSeparatorLength) |
257 return; | 260 return; |
258 | 261 |
259 output.append(frameSeparator, frameSeparatorLength); | 262 output.append(frameSeparator, frameSeparatorLength); |
260 frameContentAsPlainText(maxChars, curChild, output); | 263 frameContentAsPlainText(maxChars, curLocalChild, output); |
261 if (output.length() >= maxChars) | 264 if (output.length() >= maxChars) |
262 return; // Filled up the buffer. | 265 return; // Filled up the buffer. |
263 } | 266 } |
264 } | 267 } |
265 | 268 |
266 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame*
frame) | 269 WebPluginContainerImpl* WebLocalFrameImpl::pluginContainerFromFrame(LocalFrame*
frame) |
267 { | 270 { |
268 if (!frame) | 271 if (!frame) |
269 return 0; | 272 return 0; |
270 if (!frame->document() || !frame->document()->isPluginDocument()) | 273 if (!frame->document() || !frame->document()->isPluginDocument()) |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 void WebLocalFrameImpl::removeChild(WebFrame* child) | 654 void WebLocalFrameImpl::removeChild(WebFrame* child) |
652 { | 655 { |
653 WebFrame::removeChild(child); | 656 WebFrame::removeChild(child); |
654 frame()->tree().invalidateScopedChildCount(); | 657 frame()->tree().invalidateScopedChildCount(); |
655 } | 658 } |
656 | 659 |
657 WebFrame* WebLocalFrameImpl::traversePrevious(bool wrap) const | 660 WebFrame* WebLocalFrameImpl::traversePrevious(bool wrap) const |
658 { | 661 { |
659 if (!frame()) | 662 if (!frame()) |
660 return 0; | 663 return 0; |
661 return fromFrame(frame()->tree().traversePreviousWithWrap(wrap)); | 664 // FIXME: This should move to WebFrame and become local/remote agnostic. |
| 665 Frame* prevFrame = frame()->tree().traversePreviousWithWrap(wrap); |
| 666 if (!prevFrame || !prevFrame->isLocalFrame()) |
| 667 return 0; |
| 668 return fromFrame(toLocalFrame(prevFrame)); |
662 } | 669 } |
663 | 670 |
664 WebFrame* WebLocalFrameImpl::traverseNext(bool wrap) const | 671 WebFrame* WebLocalFrameImpl::traverseNext(bool wrap) const |
665 { | 672 { |
| 673 // FIXME: This should move to WebFrame and become local/remote agnostic. |
666 if (!frame()) | 674 if (!frame()) |
667 return 0; | 675 return 0; |
668 return fromFrame(frame()->tree().traverseNextWithWrap(wrap)); | 676 // FIXME: This should move to WebFrame and become local/remote agnostic. |
| 677 Frame* nextFrame = frame()->tree().traverseNextWithWrap(wrap); |
| 678 if (!nextFrame || !nextFrame->isLocalFrame()) |
| 679 return 0; |
| 680 return fromFrame(toLocalFrame(nextFrame)); |
669 } | 681 } |
670 | 682 |
671 WebFrame* WebLocalFrameImpl::findChildByName(const WebString& name) const | 683 WebFrame* WebLocalFrameImpl::findChildByName(const WebString& name) const |
672 { | 684 { |
| 685 // FIXME: This should move to WebFrame and become local/remote agnostic. |
673 if (!frame()) | 686 if (!frame()) |
674 return 0; | 687 return 0; |
675 return fromFrame(frame()->tree().child(name)); | 688 // FIXME: This should move to WebFrame and become local/remote agnostic. |
| 689 Frame* child = frame()->tree().child(name); |
| 690 if (!child || !child->isLocalFrame()) |
| 691 return 0; |
| 692 return fromFrame(toLocalFrame(child)); |
676 } | 693 } |
677 | 694 |
678 WebDocument WebLocalFrameImpl::document() const | 695 WebDocument WebLocalFrameImpl::document() const |
679 { | 696 { |
680 if (!frame() || !frame()->document()) | 697 if (!frame() || !frame()->document()) |
681 return WebDocument(); | 698 return WebDocument(); |
682 return WebDocument(frame()->document()); | 699 return WebDocument(frame()->document()); |
683 } | 700 } |
684 | 701 |
685 WebPerformance WebLocalFrameImpl::performance() const | 702 WebPerformance WebLocalFrameImpl::performance() const |
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 | 1939 |
1923 void WebLocalFrameImpl::invalidateAll() const | 1940 void WebLocalFrameImpl::invalidateAll() const |
1924 { | 1941 { |
1925 ASSERT(frame() && frame()->view()); | 1942 ASSERT(frame() && frame()->view()); |
1926 FrameView* view = frame()->view(); | 1943 FrameView* view = frame()->view(); |
1927 view->invalidateRect(view->frameRect()); | 1944 view->invalidateRect(view->frameRect()); |
1928 invalidateScrollbar(); | 1945 invalidateScrollbar(); |
1929 } | 1946 } |
1930 | 1947 |
1931 } // namespace blink | 1948 } // namespace blink |
OLD | NEW |