| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #include "config.h" | 78 #include "config.h" |
| 79 | 79 |
| 80 #include "build/build_config.h" | 80 #include "build/build_config.h" |
| 81 | 81 |
| 82 #include <algorithm> | 82 #include <algorithm> |
| 83 #include <string> | 83 #include <string> |
| 84 | 84 |
| 85 #pragma warning(push, 0) | 85 #pragma warning(push, 0) |
| 86 #include "HTMLFormElement.h" // need this before Document.h | 86 #include "HTMLFormElement.h" // need this before Document.h |
| 87 #include "Chrome.h" | 87 #include "Chrome.h" |
| 88 #include "ChromeClientChromium.h" |
| 88 #include "Console.h" | 89 #include "Console.h" |
| 89 #include "Document.h" | 90 #include "Document.h" |
| 90 #include "DocumentFragment.h" // Only needed for ReplaceSelectionCommand.h :( | 91 #include "DocumentFragment.h" // Only needed for ReplaceSelectionCommand.h :( |
| 91 #include "DocumentLoader.h" | 92 #include "DocumentLoader.h" |
| 92 #include "DOMWindow.h" | 93 #include "DOMWindow.h" |
| 93 #include "Editor.h" | 94 #include "Editor.h" |
| 94 #include "EventHandler.h" | 95 #include "EventHandler.h" |
| 95 #include "Frame.h" | 96 #include "Frame.h" |
| 97 #include "FrameChromium.h" |
| 96 #include "FrameLoader.h" | 98 #include "FrameLoader.h" |
| 97 #include "FrameLoadRequest.h" | 99 #include "FrameLoadRequest.h" |
| 98 #include "FrameTree.h" | 100 #include "FrameTree.h" |
| 99 #include "FrameView.h" | 101 #include "FrameView.h" |
| 100 #include "FrameWin.h" | 102 #include "FrameWin.h" |
| 101 #include "GraphicsContext.h" | 103 #include "GraphicsContext.h" |
| 102 #include "HTMLHeadElement.h" | 104 #include "HTMLHeadElement.h" |
| 103 #include "HTMLLinkElement.h" | 105 #include "HTMLLinkElement.h" |
| 104 #include "HTMLNames.h" | 106 #include "HTMLNames.h" |
| 105 #include "HistoryItem.h" | 107 #include "HistoryItem.h" |
| 106 #include "markup.h" | 108 #include "markup.h" |
| 107 #include "Page.h" | 109 #include "Page.h" |
| 108 #include "PlatformScrollBar.h" | 110 #include "PlatformScrollBar.h" |
| 109 #include "RenderFrame.h" | 111 #include "RenderFrame.h" |
| 110 #include "RenderWidget.h" | 112 #include "RenderWidget.h" |
| 111 #include "ReplaceSelectionCommand.h" | 113 #include "ReplaceSelectionCommand.h" |
| 112 #include "ResourceHandle.h" | 114 #include "ResourceHandle.h" |
| 113 #if defined(OS_WIN) | |
| 114 #include "ResourceHandleWin.h" | |
| 115 #endif | |
| 116 #include "ResourceRequest.h" | 115 #include "ResourceRequest.h" |
| 117 #include "ScriptController.h" | 116 #include "ScriptController.h" |
| 118 #include "SelectionController.h" | 117 #include "SelectionController.h" |
| 119 #include "Settings.h" | 118 #include "Settings.h" |
| 120 #include "SkiaUtils.h" | 119 #include "SkiaUtils.h" |
| 121 #include "SubstituteData.h" | 120 #include "SubstituteData.h" |
| 122 #include "TextIterator.h" | 121 #include "TextIterator.h" |
| 123 #include "TextAffinity.h" | 122 #include "TextAffinity.h" |
| 123 #include "WidgetClientChromium.h" |
| 124 #include "XPathResult.h" | 124 #include "XPathResult.h" |
| 125 | 125 |
| 126 #pragma warning(pop) | 126 #pragma warning(pop) |
| 127 | 127 |
| 128 #undef LOG | 128 #undef LOG |
| 129 #include "base/gfx/bitmap_platform_device.h" | 129 #include "base/gfx/bitmap_platform_device.h" |
| 130 #include "base/gfx/platform_canvas.h" | 130 #include "base/gfx/platform_canvas.h" |
| 131 #include "base/gfx/rect.h" | 131 #include "base/gfx/rect.h" |
| 132 #include "base/logging.h" | 132 #include "base/logging.h" |
| 133 #include "base/message_loop.h" | 133 #include "base/message_loop.h" |
| 134 #include "base/stats_counters.h" | 134 #include "base/stats_counters.h" |
| 135 #include "base/string_util.h" | 135 #include "base/string_util.h" |
| 136 #include "base/time.h" | 136 #include "base/time.h" |
| 137 #include "net/base/net_errors.h" | 137 #include "net/base/net_errors.h" |
| 138 #include "webkit/glue/dom_operations.h" | 138 #include "webkit/glue/dom_operations.h" |
| 139 #include "webkit/glue/glue_serialize.h" | 139 #include "webkit/glue/glue_serialize.h" |
| 140 #include "webkit/glue/alt_error_page_resource_fetcher.h" | 140 #include "webkit/glue/alt_error_page_resource_fetcher.h" |
| 141 #include "webkit/glue/webdocumentloader_impl.h" | 141 #include "webkit/glue/webdocumentloader_impl.h" |
| 142 #include "webkit/glue/weberror_impl.h" | 142 #include "webkit/glue/weberror_impl.h" |
| 143 #include "webkit/glue/webframe_impl.h" | 143 #include "webkit/glue/webframe_impl.h" |
| 144 #include "webkit/glue/webhistoryitem_impl.h" | 144 #include "webkit/glue/webhistoryitem_impl.h" |
| 145 #include "webkit/glue/webtextinput_impl.h" | 145 #include "webkit/glue/webtextinput_impl.h" |
| 146 #include "webkit/glue/webview_impl.h" | 146 #include "webkit/glue/webview_impl.h" |
| 147 #include "webkit/port/page/ChromeClientWin.h" | |
| 148 #include "webkit/port/platform/WidgetClientWin.h" | |
| 149 | 147 |
| 150 #if defined(OS_LINUX) | 148 #if defined(OS_LINUX) |
| 151 #include <gdk/gdk.h> | 149 #include <gdk/gdk.h> |
| 152 #endif | 150 #endif |
| 153 | 151 |
| 154 using WebCore::ChromeClientWin; | 152 using WebCore::ChromeClientChromium; |
| 155 using WebCore::Color; | 153 using WebCore::Color; |
| 156 using WebCore::Document; | 154 using WebCore::Document; |
| 157 using WebCore::DocumentFragment; | 155 using WebCore::DocumentFragment; |
| 158 using WebCore::DocumentLoader; | 156 using WebCore::DocumentLoader; |
| 159 using WebCore::ExceptionCode; | 157 using WebCore::ExceptionCode; |
| 160 using WebCore::GraphicsContext; | 158 using WebCore::GraphicsContext; |
| 161 using WebCore::HTMLFrameOwnerElement; | 159 using WebCore::HTMLFrameOwnerElement; |
| 162 using WebCore::Frame; | 160 using WebCore::Frame; |
| 163 using WebCore::FrameLoader; | 161 using WebCore::FrameLoader; |
| 164 using WebCore::FrameLoadRequest; | 162 using WebCore::FrameLoadRequest; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 176 using WebCore::RenderObject; | 174 using WebCore::RenderObject; |
| 177 using WebCore::ResourceError; | 175 using WebCore::ResourceError; |
| 178 using WebCore::ResourceHandle; | 176 using WebCore::ResourceHandle; |
| 179 using WebCore::ResourceRequest; | 177 using WebCore::ResourceRequest; |
| 180 using WebCore::Selection; | 178 using WebCore::Selection; |
| 181 using WebCore::SharedBuffer; | 179 using WebCore::SharedBuffer; |
| 182 using WebCore::String; | 180 using WebCore::String; |
| 183 using WebCore::SubstituteData; | 181 using WebCore::SubstituteData; |
| 184 using WebCore::TextIterator; | 182 using WebCore::TextIterator; |
| 185 using WebCore::VisiblePosition; | 183 using WebCore::VisiblePosition; |
| 186 using WebCore::WidgetClientWin; | 184 using WebCore::WidgetClientChromium; |
| 187 using WebCore::XPathResult; | 185 using WebCore::XPathResult; |
| 188 | 186 |
| 189 static const wchar_t* const kWebFrameActiveCount = L"WebFrameActiveCount"; | 187 static const wchar_t* const kWebFrameActiveCount = L"WebFrameActiveCount"; |
| 190 | 188 |
| 191 static const char* const kOSDType = "application/opensearchdescription+xml"; | 189 static const char* const kOSDType = "application/opensearchdescription+xml"; |
| 192 static const char* const kOSDRel = "search"; | 190 static const char* const kOSDRel = "search"; |
| 193 | 191 |
| 194 // The separator between frames when the frames are converted to plain text. | 192 // The separator between frames when the frames are converted to plain text. |
| 195 static const wchar_t kFrameSeparator[] = L"\n\n"; | 193 static const wchar_t kFrameSeparator[] = L"\n\n"; |
| 196 static const int kFrameSeparatorLen = arraysize(kFrameSeparator) - 1; | 194 static const int kFrameSeparatorLen = arraysize(kFrameSeparator) - 1; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 : frame_loader_client_(this), | 273 : frame_loader_client_(this), |
| 276 scope_matches_factory_(this), | 274 scope_matches_factory_(this), |
| 277 MSVC_POP_WARNING() | 275 MSVC_POP_WARNING() |
| 278 currently_loading_request_(NULL), | 276 currently_loading_request_(NULL), |
| 279 plugin_delegate_(NULL), | 277 plugin_delegate_(NULL), |
| 280 allows_scrolling_(true), | 278 allows_scrolling_(true), |
| 281 margin_width_(-1), | 279 margin_width_(-1), |
| 282 margin_height_(-1), | 280 margin_height_(-1), |
| 283 inspected_node_(NULL), | 281 inspected_node_(NULL), |
| 284 active_tickmark_frame_(NULL), | 282 active_tickmark_frame_(NULL), |
| 285 active_tickmark_(WidgetClientWin::kNoTickmark), | 283 active_tickmark_(WidgetClientChromium::kNoTickmark), |
| 286 locating_active_rect_(false), | 284 locating_active_rect_(false), |
| 287 last_active_range_(NULL), | 285 last_active_range_(NULL), |
| 288 last_match_count_(-1), | 286 last_match_count_(-1), |
| 289 total_matchcount_(-1), | 287 total_matchcount_(-1), |
| 290 frames_scoping_count_(-1), | 288 frames_scoping_count_(-1), |
| 291 scoping_complete_(false), | 289 scoping_complete_(false), |
| 292 next_invalidate_after_(0), | 290 next_invalidate_after_(0), |
| 293 printing_(false) { | 291 printing_(false) { |
| 294 StatsCounter(kWebFrameActiveCount).Increment(); | 292 StatsCounter(kWebFrameActiveCount).Increment(); |
| 295 live_object_count_++; | 293 live_object_count_++; |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 if (tickmarks_.isEmpty()) | 881 if (tickmarks_.isEmpty()) |
| 884 return false; | 882 return false; |
| 885 | 883 |
| 886 // Save the old tickmark (if any). We will use this to invalidate the area | 884 // Save the old tickmark (if any). We will use this to invalidate the area |
| 887 // of the tickmark that becomes unselected. | 885 // of the tickmark that becomes unselected. |
| 888 WebFrameImpl* const main_frame_impl = | 886 WebFrameImpl* const main_frame_impl = |
| 889 static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); | 887 static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); |
| 890 WebFrameImpl* const active_frame = main_frame_impl->active_tickmark_frame_; | 888 WebFrameImpl* const active_frame = main_frame_impl->active_tickmark_frame_; |
| 891 RefPtr<WebCore::Range> old_tickmark = NULL; | 889 RefPtr<WebCore::Range> old_tickmark = NULL; |
| 892 if (active_frame && | 890 if (active_frame && |
| 893 (active_frame->active_tickmark_ != WidgetClientWin::kNoTickmark)) { | 891 (active_frame->active_tickmark_ != WidgetClientChromium::kNoTickmark)) { |
| 894 // When we get a reference to |old_tickmark| we can be in a state where | 892 // When we get a reference to |old_tickmark| we can be in a state where |
| 895 // the |active_tickmark_| points outside the tickmark vector, possibly | 893 // the |active_tickmark_| points outside the tickmark vector, possibly |
| 896 // during teardown of the frame. This doesn't reproduce normally, so if you | 894 // during teardown of the frame. This doesn't reproduce normally, so if you |
| 897 // hit this during debugging, update issue http://b/1277569 with | 895 // hit this during debugging, update issue http://b/1277569 with |
| 898 // reproduction steps - or contact the assignee. In release, we can ignore | 896 // reproduction steps - or contact the assignee. In release, we can ignore |
| 899 // this and continue on (and let |old_tickmark| be null). | 897 // this and continue on (and let |old_tickmark| be null). |
| 900 if (active_frame->active_tickmark_ >= active_frame->tickmarks_.size()) | 898 if (active_frame->active_tickmark_ >= active_frame->tickmarks_.size()) |
| 901 NOTREACHED() << L"Active tickmark points outside the tickmark vector!"; | 899 NOTREACHED() << L"Active tickmark points outside the tickmark vector!"; |
| 902 else | 900 else |
| 903 old_tickmark = active_frame->tickmarks_[active_frame->active_tickmark_]; | 901 old_tickmark = active_frame->tickmarks_[active_frame->active_tickmark_]; |
| 904 } | 902 } |
| 905 | 903 |
| 906 // See if we have another match to select, and select it. | 904 // See if we have another match to select, and select it. |
| 907 if (request.forward) { | 905 if (request.forward) { |
| 908 const bool at_end = (active_tickmark_ == (tickmarks_.size() - 1)); | 906 const bool at_end = (active_tickmark_ == (tickmarks_.size() - 1)); |
| 909 if ((active_tickmark_ == WidgetClientWin::kNoTickmark) || | 907 if ((active_tickmark_ == WidgetClientChromium::kNoTickmark) || |
| 910 (at_end && wrap_within_frame)) { | 908 (at_end && wrap_within_frame)) { |
| 911 // Wrapping within a frame is only done for single frame pages. So when we | 909 // Wrapping within a frame is only done for single frame pages. So when we |
| 912 // reach the end we go back to the beginning (or back to the end if | 910 // reach the end we go back to the beginning (or back to the end if |
| 913 // searching backwards). | 911 // searching backwards). |
| 914 active_tickmark_ = 0; | 912 active_tickmark_ = 0; |
| 915 } else if (at_end) { | 913 } else if (at_end) { |
| 916 return false; | 914 return false; |
| 917 } else { | 915 } else { |
| 918 ++active_tickmark_; | 916 ++active_tickmark_; |
| 919 DCHECK(active_tickmark_ < tickmarks_.size()); | 917 DCHECK(active_tickmark_ < tickmarks_.size()); |
| 920 } | 918 } |
| 921 } else { | 919 } else { |
| 922 const bool at_end = (active_tickmark_ == 0); | 920 const bool at_end = (active_tickmark_ == 0); |
| 923 if ((active_tickmark_ == WidgetClientWin::kNoTickmark) || | 921 if ((active_tickmark_ == WidgetClientChromium::kNoTickmark) || |
| 924 (at_end && wrap_within_frame)) { | 922 (at_end && wrap_within_frame)) { |
| 925 // Wrapping within a frame is not done for multi-frame pages, but if no | 923 // Wrapping within a frame is not done for multi-frame pages, but if no |
| 926 // tickmark is active we still need to set the index to the end so that | 924 // tickmark is active we still need to set the index to the end so that |
| 927 // we don't skip the frame during FindNext when searching backwards. | 925 // we don't skip the frame during FindNext when searching backwards. |
| 928 active_tickmark_ = tickmarks_.size() - 1; | 926 active_tickmark_ = tickmarks_.size() - 1; |
| 929 } else if (at_end) { | 927 } else if (at_end) { |
| 930 return false; | 928 return false; |
| 931 } else { | 929 } else { |
| 932 --active_tickmark_; | 930 --active_tickmark_; |
| 933 DCHECK(active_tickmark_ < tickmarks_.size()); | 931 DCHECK(active_tickmark_ < tickmarks_.size()); |
| 934 } | 932 } |
| 935 } | 933 } |
| 936 | 934 |
| 937 if (active_frame != this) { | 935 if (active_frame != this) { |
| 938 // If we are jumping between frames, reset the active tickmark in the old | 936 // If we are jumping between frames, reset the active tickmark in the old |
| 939 // frame and invalidate the area. | 937 // frame and invalidate the area. |
| 940 active_frame->active_tickmark_ = WidgetClientWin::kNoTickmark; | 938 active_frame->active_tickmark_ = WidgetClientChromium::kNoTickmark; |
| 941 active_frame->InvalidateArea(INVALIDATE_CONTENT_AREA); | 939 active_frame->InvalidateArea(INVALIDATE_CONTENT_AREA); |
| 942 main_frame_impl->active_tickmark_frame_ = this; | 940 main_frame_impl->active_tickmark_frame_ = this; |
| 943 } else { | 941 } else { |
| 944 // Invalidate the old tickmark. | 942 // Invalidate the old tickmark. |
| 945 if (old_tickmark) | 943 if (old_tickmark) |
| 946 active_frame->InvalidateTickmark(old_tickmark); | 944 active_frame->InvalidateTickmark(old_tickmark); |
| 947 } | 945 } |
| 948 | 946 |
| 949 Selection selection(tickmarks_[active_tickmark_].get()); | 947 Selection selection(tickmarks_[active_tickmark_].get()); |
| 950 frame()->selection()->setSelection(selection); | 948 frame()->selection()->setSelection(selection); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 main_frame_impl->IncreaseMatchCount(0, request.request_id); | 1218 main_frame_impl->IncreaseMatchCount(0, request.request_id); |
| 1221 | 1219 |
| 1222 // This frame is done, so show any tickmark/highlight we haven't drawn yet. | 1220 // This frame is done, so show any tickmark/highlight we haven't drawn yet. |
| 1223 InvalidateArea(INVALIDATE_ALL); | 1221 InvalidateArea(INVALIDATE_ALL); |
| 1224 | 1222 |
| 1225 return; | 1223 return; |
| 1226 } | 1224 } |
| 1227 | 1225 |
| 1228 void WebFrameImpl::CancelPendingScopingEffort() { | 1226 void WebFrameImpl::CancelPendingScopingEffort() { |
| 1229 scope_matches_factory_.RevokeAll(); | 1227 scope_matches_factory_.RevokeAll(); |
| 1230 active_tickmark_ = WidgetClientWin::kNoTickmark; | 1228 active_tickmark_ = WidgetClientChromium::kNoTickmark; |
| 1231 } | 1229 } |
| 1232 | 1230 |
| 1233 void WebFrameImpl::SetFindEndstateFocusAndSelection() { | 1231 void WebFrameImpl::SetFindEndstateFocusAndSelection() { |
| 1234 WebFrameImpl* main_frame_impl = | 1232 WebFrameImpl* main_frame_impl = |
| 1235 static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); | 1233 static_cast<WebFrameImpl*>(GetView()->GetMainFrame()); |
| 1236 | 1234 |
| 1237 if (this == main_frame_impl->active_tickmark_frame() && | 1235 if (this == main_frame_impl->active_tickmark_frame() && |
| 1238 active_tickmark_ != WidgetClientWin::kNoTickmark) { | 1236 active_tickmark_ != WidgetClientChromium::kNoTickmark) { |
| 1239 RefPtr<Range> range = tickmarks_[active_tickmark_]; | 1237 RefPtr<Range> range = tickmarks_[active_tickmark_]; |
| 1240 | 1238 |
| 1241 // Set the selection to what the active match is. | 1239 // Set the selection to what the active match is. |
| 1242 frame()->selection()->setSelectedRange( | 1240 frame()->selection()->setSelectedRange( |
| 1243 range.get(), WebCore::DOWNSTREAM, false); | 1241 range.get(), WebCore::DOWNSTREAM, false); |
| 1244 | 1242 |
| 1245 // We will be setting focus ourselves, so we want the view to forget its | 1243 // We will be setting focus ourselves, so we want the view to forget its |
| 1246 // stored focus node so that it won't change it after we are done. | 1244 // stored focus node so that it won't change it after we are done. |
| 1247 static_cast<WebViewImpl*>(GetView())->ReleaseFocusReferences(); | 1245 static_cast<WebViewImpl*>(GetView())->ReleaseFocusReferences(); |
| 1248 | 1246 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1869 if (loader) { | 1867 if (loader) { |
| 1870 return WebCore::FrameLoadTypeReloadAllowingStaleData == | 1868 return WebCore::FrameLoadTypeReloadAllowingStaleData == |
| 1871 loader->policyLoadType(); | 1869 loader->policyLoadType(); |
| 1872 } | 1870 } |
| 1873 return false; | 1871 return false; |
| 1874 } | 1872 } |
| 1875 | 1873 |
| 1876 int WebFrameImpl::PendingFrameUnloadEventCount() const { | 1874 int WebFrameImpl::PendingFrameUnloadEventCount() const { |
| 1877 return frame()->eventHandler()->pendingFrameUnloadEventCount(); | 1875 return frame()->eventHandler()->pendingFrameUnloadEventCount(); |
| 1878 } | 1876 } |
| OLD | NEW |