OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 3 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 #include "FrameTree.h" | 99 #include "FrameTree.h" |
100 #include "FrameView.h" | 100 #include "FrameView.h" |
101 #include "FrameWin.h" | 101 #include "FrameWin.h" |
102 #include "GraphicsContext.h" | 102 #include "GraphicsContext.h" |
103 #include "HTMLHeadElement.h" | 103 #include "HTMLHeadElement.h" |
104 #include "HTMLLinkElement.h" | 104 #include "HTMLLinkElement.h" |
105 #include "HTMLNames.h" | 105 #include "HTMLNames.h" |
106 #include "HistoryItem.h" | 106 #include "HistoryItem.h" |
107 #include "markup.h" | 107 #include "markup.h" |
108 #include "Page.h" | 108 #include "Page.h" |
| 109 #if defined(OS_WIN) |
109 #include "PlatformScrollBar.h" | 110 #include "PlatformScrollBar.h" |
| 111 #endif |
110 #include "RenderFrame.h" | 112 #include "RenderFrame.h" |
111 #include "RenderWidget.h" | 113 #include "RenderWidget.h" |
112 #include "ReplaceSelectionCommand.h" | 114 #include "ReplaceSelectionCommand.h" |
113 #include "ResourceHandle.h" | 115 #include "ResourceHandle.h" |
114 #if defined(OS_WIN) | 116 #if defined(OS_WIN) |
115 #include "ResourceHandleWin.h" | 117 #include "ResourceHandleWin.h" |
116 #endif | 118 #endif |
117 #include "ResourceRequest.h" | 119 #include "ResourceRequest.h" |
118 #include "ScriptController.h" | 120 #include "ScriptController.h" |
119 #include "SelectionController.h" | 121 #include "SelectionController.h" |
120 #include "Settings.h" | 122 #include "Settings.h" |
121 #include "SkiaUtils.h" | 123 #include "SkiaUtils.h" |
122 #include "SubstituteData.h" | 124 #include "SubstituteData.h" |
123 #include "TextIterator.h" | 125 #include "TextIterator.h" |
124 #include "TextAffinity.h" | 126 #include "TextAffinity.h" |
125 #include "XPathResult.h" | 127 #include "XPathResult.h" |
126 | 128 |
| 129 #if defined(OS_LINUX) |
| 130 #include <gdk/gdk.h> |
| 131 #endif |
| 132 |
127 MSVC_POP_WARNING(); | 133 MSVC_POP_WARNING(); |
128 | 134 |
129 #undef LOG | 135 #undef LOG |
130 #include "base/gfx/bitmap_platform_device.h" | 136 #include "base/gfx/bitmap_platform_device.h" |
131 #include "base/gfx/platform_canvas.h" | 137 #include "base/gfx/platform_canvas.h" |
132 #include "base/gfx/rect.h" | 138 #include "base/gfx/rect.h" |
133 #include "base/logging.h" | 139 #include "base/logging.h" |
134 #include "base/message_loop.h" | 140 #include "base/message_loop.h" |
135 #include "base/stats_counters.h" | 141 #include "base/stats_counters.h" |
136 #include "base/string_util.h" | 142 #include "base/string_util.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 int to_append = std::min(it.length(), | 244 int to_append = std::min(it.length(), |
239 max_chars - static_cast<int>(output->size())); | 245 max_chars - static_cast<int>(output->size())); |
240 output->append(chars, to_append); | 246 output->append(chars, to_append); |
241 if (output->size() >= static_cast<size_t>(max_chars)) | 247 if (output->size() >= static_cast<size_t>(max_chars)) |
242 return; // Filled up the buffer. | 248 return; // Filled up the buffer. |
243 } | 249 } |
244 } | 250 } |
245 | 251 |
246 // Recursively walk the children. | 252 // Recursively walk the children. |
247 FrameTree* frame_tree = frame->tree(); | 253 FrameTree* frame_tree = frame->tree(); |
248 Frame* cur_child = frame_tree->firstChild(); | |
249 for (Frame* cur_child = frame_tree->firstChild(); cur_child; | 254 for (Frame* cur_child = frame_tree->firstChild(); cur_child; |
250 cur_child = cur_child->tree()->nextSibling()) { | 255 cur_child = cur_child->tree()->nextSibling()) { |
251 // Make sure the frame separator won't fill up the buffer, and give up if | 256 // Make sure the frame separator won't fill up the buffer, and give up if |
252 // it will. The danger is if the separator will make the buffer longer than | 257 // it will. The danger is if the separator will make the buffer longer than |
253 // max_chars. This will cause the computation above: | 258 // max_chars. This will cause the computation above: |
254 // max_chars - output->size() | 259 // max_chars - output->size() |
255 // to be a negative number which will crash when the subframe is added. | 260 // to be a negative number which will crash when the subframe is added. |
256 if (static_cast<int>(output->size()) >= max_chars - kFrameSeparatorLen) | 261 if (static_cast<int>(output->size()) >= max_chars - kFrameSeparatorLen) |
257 return; | 262 return; |
258 | 263 |
259 output->append(kFrameSeparator, kFrameSeparatorLen); | 264 output->append(kFrameSeparator, kFrameSeparatorLen); |
260 FrameContentAsPlainText(max_chars, cur_child, output); | 265 FrameContentAsPlainText(max_chars, cur_child, output); |
261 if (output->size() >= static_cast<size_t>(max_chars)) | 266 if (output->size() >= static_cast<size_t>(max_chars)) |
262 return; // Filled up the buffer. | 267 return; // Filled up the buffer. |
263 } | 268 } |
264 } | 269 } |
265 | 270 |
266 // WebFrameImpl ---------------------------------------------------------------- | 271 // WebFrameImpl ---------------------------------------------------------------- |
267 | 272 |
268 int WebFrameImpl::live_object_count_ = 0; | 273 int WebFrameImpl::live_object_count_ = 0; |
269 | 274 |
270 WebFrameImpl::WebFrameImpl() | 275 WebFrameImpl::WebFrameImpl() |
271 // Don't complain about using "this" in initializer list. | 276 // Don't complain about using "this" in initializer list. |
272 MSVC_PUSH_DISABLE_WARNING(4355) | 277 MSVC_PUSH_DISABLE_WARNING(4355) |
273 : frame_loader_client_(this), | 278 : frame_loader_client_(this), |
274 scope_matches_factory_(this), | |
275 MSVC_POP_WARNING() | |
276 currently_loading_request_(NULL), | 279 currently_loading_request_(NULL), |
277 plugin_delegate_(NULL), | 280 plugin_delegate_(NULL), |
278 allows_scrolling_(true), | 281 allows_scrolling_(true), |
279 margin_width_(-1), | 282 margin_width_(-1), |
280 margin_height_(-1), | 283 margin_height_(-1), |
281 last_match_count_(-1), | |
282 total_matchcount_(-1), | |
283 inspected_node_(NULL), | 284 inspected_node_(NULL), |
284 active_tickmark_frame_(NULL), | |
285 active_tickmark_(WidgetClientWin::kNoTickmark), | 285 active_tickmark_(WidgetClientWin::kNoTickmark), |
286 locating_active_rect_(false), | 286 locating_active_rect_(false), |
287 last_active_range_(NULL), | 287 last_active_range_(NULL), |
| 288 last_match_count_(-1), |
| 289 total_matchcount_(-1), |
| 290 active_tickmark_frame_(NULL), |
288 frames_scoping_count_(-1), | 291 frames_scoping_count_(-1), |
289 scoping_complete_(false), | 292 scoping_complete_(false), |
290 next_invalidate_after_(0), | 293 next_invalidate_after_(0), |
| 294 scope_matches_factory_(this), |
| 295 MSVC_POP_WARNING() |
291 printing_(false) { | 296 printing_(false) { |
292 StatsCounter(kWebFrameActiveCount).Increment(); | 297 StatsCounter(kWebFrameActiveCount).Increment(); |
293 live_object_count_++; | 298 live_object_count_++; |
294 } | 299 } |
295 | 300 |
296 WebFrameImpl::~WebFrameImpl() { | 301 WebFrameImpl::~WebFrameImpl() { |
297 StatsCounter(kWebFrameActiveCount).Decrement(); | 302 StatsCounter(kWebFrameActiveCount).Decrement(); |
298 live_object_count_--; | 303 live_object_count_--; |
299 | 304 |
300 CancelPendingScopingEffort(); | 305 CancelPendingScopingEffort(); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 std::wstring* text) const { | 722 std::wstring* text) const { |
718 text->clear(); | 723 text->clear(); |
719 if (!frame_) | 724 if (!frame_) |
720 return; | 725 return; |
721 | 726 |
722 FrameContentAsPlainText(max_chars, frame_.get(), text); | 727 FrameContentAsPlainText(max_chars, frame_.get(), text); |
723 } | 728 } |
724 | 729 |
725 void WebFrameImpl::InvalidateArea(AreaToInvalidate area) { | 730 void WebFrameImpl::InvalidateArea(AreaToInvalidate area) { |
726 ASSERT(frame() && frame()->view()); | 731 ASSERT(frame() && frame()->view()); |
727 FrameView* view = frame()->view(); | |
728 | 732 |
729 #if defined(OS_WIN) | 733 #if defined(OS_WIN) |
| 734 FrameView* view = frame()->view(); |
730 // TODO(pinkerton): Fix Mac invalidation to be more like Win ScrollView | 735 // TODO(pinkerton): Fix Mac invalidation to be more like Win ScrollView |
731 if ((area & INVALIDATE_ALL) == INVALIDATE_ALL) { | 736 if ((area & INVALIDATE_ALL) == INVALIDATE_ALL) { |
732 view->addToDirtyRegion(view->frameGeometry()); | 737 view->addToDirtyRegion(view->frameGeometry()); |
733 } else { | 738 } else { |
734 if ((area & INVALIDATE_CONTENT_AREA) == INVALIDATE_CONTENT_AREA) { | 739 if ((area & INVALIDATE_CONTENT_AREA) == INVALIDATE_CONTENT_AREA) { |
735 IntRect content_area(view->x(), | 740 IntRect content_area(view->x(), |
736 view->y(), | 741 view->y(), |
737 view->visibleWidth(), | 742 view->visibleWidth(), |
738 view->visibleHeight()); | 743 view->visibleHeight()); |
739 view->addToDirtyRegion(content_area); | 744 view->addToDirtyRegion(content_area); |
740 } | 745 } |
741 | 746 |
742 if ((area & INVALIDATE_SCROLLBAR) == INVALIDATE_SCROLLBAR) { | 747 if ((area & INVALIDATE_SCROLLBAR) == INVALIDATE_SCROLLBAR) { |
743 // Invalidate the vertical scroll bar region for the view. | 748 // Invalidate the vertical scroll bar region for the view. |
744 IntRect scroll_bar_vert(view->x() + view->visibleWidth(), | 749 IntRect scroll_bar_vert(view->x() + view->visibleWidth(), |
745 view->y(), | 750 view->y(), |
746 PlatformScrollbar::verticalScrollbarWidth(), | 751 PlatformScrollbar::verticalScrollbarWidth(), |
747 view->visibleHeight()); | 752 view->visibleHeight()); |
748 view->addToDirtyRegion(scroll_bar_vert); | 753 view->addToDirtyRegion(scroll_bar_vert); |
749 } | 754 } |
750 } | 755 } |
751 #endif | 756 #endif |
752 } | 757 } |
753 | 758 |
754 void WebFrameImpl::InvalidateTickmark(RefPtr<WebCore::Range> tickmark) { | 759 void WebFrameImpl::InvalidateTickmark(RefPtr<WebCore::Range> tickmark) { |
755 ASSERT(frame() && frame()->view()); | 760 ASSERT(frame() && frame()->view()); |
756 FrameView* view = frame()->view(); | |
757 | 761 |
758 #if defined(OS_WIN) | 762 #if defined(OS_WIN) |
| 763 FrameView* view = frame()->view(); |
759 // TODO(pinkerton): Fix Mac invalidation to be more like Win ScrollView | 764 // TODO(pinkerton): Fix Mac invalidation to be more like Win ScrollView |
760 IntRect pos = tickmark->boundingBox(); | 765 IntRect pos = tickmark->boundingBox(); |
761 pos.move(-view->contentsX(), -view->contentsY()); | 766 pos.move(-view->contentsX(), -view->contentsY()); |
762 view->addToDirtyRegion(pos); | 767 view->addToDirtyRegion(pos); |
763 #endif | 768 #endif |
764 } | 769 } |
765 | 770 |
766 void WebFrameImpl::IncreaseMatchCount(int count, int request_id) { | 771 void WebFrameImpl::IncreaseMatchCount(int count, int request_id) { |
767 total_matchcount_ += count; | 772 total_matchcount_ += count; |
768 | 773 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context)); | 1490 GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context)); |
1486 #endif | 1491 #endif |
1487 if (frame_->document() && frameview()) { | 1492 if (frame_->document() && frameview()) { |
1488 frameview()->paint(&gc, dirty_rect); | 1493 frameview()->paint(&gc, dirty_rect); |
1489 } else { | 1494 } else { |
1490 gc.fillRect(dirty_rect, Color::white); | 1495 gc.fillRect(dirty_rect, Color::white); |
1491 } | 1496 } |
1492 } | 1497 } |
1493 } | 1498 } |
1494 | 1499 |
1495 #if defined(OS_WIN) | |
1496 gfx::BitmapPlatformDevice WebFrameImpl::CaptureImage(bool scroll_to_zero) { | 1500 gfx::BitmapPlatformDevice WebFrameImpl::CaptureImage(bool scroll_to_zero) { |
1497 // Must layout before painting. | 1501 // Must layout before painting. |
1498 Layout(); | 1502 Layout(); |
1499 | 1503 gfx::PlatformCanvas canvas(frameview()->width(), |
1500 gfx::PlatformCanvasWin canvas(frameview()->width(), frameview()->height(), tru
e); | 1504 frameview()->height(), true); |
| 1505 #if defined(OS_WIN) || defined(OS_LINUX) |
1501 PlatformContextSkia context(&canvas); | 1506 PlatformContextSkia context(&canvas); |
1502 | 1507 |
1503 GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context)); | 1508 GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context)); |
1504 frameview()->paint(&gc, IntRect(0, 0, frameview()->width(), | 1509 frameview()->paint(&gc, IntRect(0, 0, frameview()->width(), |
1505 frameview()->height())); | 1510 frameview()->height())); |
1506 | |
1507 gfx::BitmapPlatformDeviceWin& device = | |
1508 static_cast<gfx::BitmapPlatformDeviceWin&>(canvas.getTopPlatformDevice()); | |
1509 device.fixupAlphaBeforeCompositing(); | |
1510 return device; | |
1511 } | |
1512 #elif defined(OS_MACOSX) | 1511 #elif defined(OS_MACOSX) |
1513 gfx::BitmapPlatformDevice WebFrameImpl::CaptureImage(bool scroll_to_zero) { | |
1514 // Must layout before painting. | |
1515 Layout(); | |
1516 | |
1517 gfx::PlatformCanvasMac canvas(frameview()->width(), | |
1518 frameview()->height(), true); | |
1519 CGContextRef context = canvas.beginPlatformPaint(); | 1512 CGContextRef context = canvas.beginPlatformPaint(); |
1520 GraphicsContext gc(context); | 1513 GraphicsContext gc(context); |
1521 frameview()->paint(&gc, IntRect(0, 0, frameview()->width(), | 1514 frameview()->paint(&gc, IntRect(0, 0, frameview()->width(), |
1522 frameview()->height())); | 1515 frameview()->height())); |
1523 canvas.endPlatformPaint(); | 1516 canvas.endPlatformPaint(); |
| 1517 #endif |
1524 | 1518 |
1525 gfx::BitmapPlatformDevice& device = | 1519 gfx::BitmapPlatformDevice& device = |
1526 static_cast<gfx::BitmapPlatformDevice&>(canvas.getTopPlatformDevice()); | 1520 static_cast<gfx::BitmapPlatformDevice&>(canvas.getTopPlatformDevice()); |
| 1521 #if defined(OS_WIN) |
| 1522 device.fixupAlphaBeforeCompositing(); |
| 1523 #endif |
1527 return device; | 1524 return device; |
1528 } | 1525 } |
1529 #else | |
1530 gfx::BitmapPlatformDevice WebFrameImpl::CaptureImage(bool scroll_to_zero) { | |
1531 NOTIMPLEMENTED(); | |
1532 } | |
1533 #endif | |
1534 | 1526 |
1535 bool WebFrameImpl::IsLoading() { | 1527 bool WebFrameImpl::IsLoading() { |
1536 // I'm assuming this does what we want. | 1528 // I'm assuming this does what we want. |
1537 return frame_->loader()->isLoading(); | 1529 return frame_->loader()->isLoading(); |
1538 } | 1530 } |
1539 | 1531 |
1540 void WebFrameImpl::Closing() { | 1532 void WebFrameImpl::Closing() { |
1541 // let go of our references, this breaks reference cycles and will | 1533 // let go of our references, this breaks reference cycles and will |
1542 // usually eventually lead to us being destroyed. | 1534 // usually eventually lead to us being destroyed. |
1543 if (frameview()) | 1535 if (frameview()) |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 } | 1828 } |
1837 | 1829 |
1838 void WebFrameImpl::GetPageRect(int page, gfx::Rect* page_size) const { | 1830 void WebFrameImpl::GetPageRect(int page, gfx::Rect* page_size) const { |
1839 if (page < 0 || page >= static_cast<int>(pages_.size())) { | 1831 if (page < 0 || page >= static_cast<int>(pages_.size())) { |
1840 NOTREACHED(); | 1832 NOTREACHED(); |
1841 return; | 1833 return; |
1842 } | 1834 } |
1843 *page_size = pages_[page]; | 1835 *page_size = pages_[page]; |
1844 } | 1836 } |
1845 | 1837 |
1846 bool WebFrameImpl::SpoolPage(int page, | 1838 bool WebFrameImpl::SpoolPage(int page, PlatformContextSkia* context) { |
1847 PlatformContextSkia* context) { | |
1848 // Ensure correct state. | 1839 // Ensure correct state. |
1849 if (!context || | 1840 if (!context || |
1850 !printing_ || | 1841 !printing_ || |
1851 page < 0 || | 1842 page < 0 || |
1852 page >= static_cast<int>(pages_.size())) { | 1843 page >= static_cast<int>(pages_.size())) { |
1853 NOTREACHED(); | 1844 NOTREACHED(); |
1854 return false; | 1845 return false; |
1855 } | 1846 } |
1856 | 1847 |
1857 if (!frame() || !frame()->document()) { | 1848 if (!frame() || !frame()->document()) { |
(...skipping 22 matching lines...) Expand all Loading... |
1880 if (loader) { | 1871 if (loader) { |
1881 return WebCore::FrameLoadTypeReloadAllowingStaleData == | 1872 return WebCore::FrameLoadTypeReloadAllowingStaleData == |
1882 loader->policyLoadType(); | 1873 loader->policyLoadType(); |
1883 } | 1874 } |
1884 return false; | 1875 return false; |
1885 } | 1876 } |
1886 | 1877 |
1887 int WebFrameImpl::PendingFrameUnloadEventCount() const { | 1878 int WebFrameImpl::PendingFrameUnloadEventCount() const { |
1888 return frame()->eventHandler()->pendingFrameUnloadEventCount(); | 1879 return frame()->eventHandler()->pendingFrameUnloadEventCount(); |
1889 } | 1880 } |
OLD | NEW |