| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "webkit/glue/webkit_glue.h" | 6 #include "webkit/glue/webkit_glue.h" |
| 7 | 7 |
| 8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
| 9 #include <objidl.h> | 9 #include <objidl.h> |
| 10 #include <mlang.h> | 10 #include <mlang.h> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "base/sys_string_conversions.h" | 37 #include "base/sys_string_conversions.h" |
| 38 #include "net/base/escape.h" | 38 #include "net/base/escape.h" |
| 39 #include "skia/ext/platform_canvas.h" | 39 #include "skia/ext/platform_canvas.h" |
| 40 #include "third_party/skia/include/core/SkBitmap.h" | 40 #include "third_party/skia/include/core/SkBitmap.h" |
| 41 #include "webkit/api/public/WebHistoryItem.h" | 41 #include "webkit/api/public/WebHistoryItem.h" |
| 42 #include "webkit/api/public/WebString.h" | 42 #include "webkit/api/public/WebString.h" |
| 43 #include "webkit/api/public/WebVector.h" | 43 #include "webkit/api/public/WebVector.h" |
| 44 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 45 #include "webkit/api/public/win/WebInputEventFactory.h" | 45 #include "webkit/api/public/win/WebInputEventFactory.h" |
| 46 #endif | 46 #endif |
| 47 #include "webkit/api/src/WebFrameImpl.h" |
| 48 #include "webkit/api/src/WebViewImpl.h" |
| 47 #include "webkit/glue/glue_serialize.h" | 49 #include "webkit/glue/glue_serialize.h" |
| 48 #include "webkit/glue/glue_util.h" | 50 #include "webkit/glue/glue_util.h" |
| 49 #include "webkit/glue/webframe_impl.h" | |
| 50 #include "webkit/glue/webview_impl.h" | |
| 51 | 51 |
| 52 #include "webkit_version.h" // Generated | 52 #include "webkit_version.h" // Generated |
| 53 | 53 |
| 54 using WebKit::WebCanvas; | 54 using WebKit::WebCanvas; |
| 55 using WebKit::WebFrame; | 55 using WebKit::WebFrame; |
| 56 using WebKit::WebFrameImpl; |
| 56 using WebKit::WebHistoryItem; | 57 using WebKit::WebHistoryItem; |
| 57 using WebKit::WebString; | 58 using WebKit::WebString; |
| 58 using WebKit::WebVector; | 59 using WebKit::WebVector; |
| 59 using WebKit::WebView; | 60 using WebKit::WebView; |
| 61 using WebKit::WebViewImpl; |
| 60 | 62 |
| 61 namespace { | 63 namespace { |
| 62 | 64 |
| 63 static const char kLayoutTestsPattern[] = "/LayoutTests/"; | 65 static const char kLayoutTestsPattern[] = "/LayoutTests/"; |
| 64 static const std::string::size_type kLayoutTestsPatternSize = | 66 static const std::string::size_type kLayoutTestsPatternSize = |
| 65 arraysize(kLayoutTestsPattern) - 1; | 67 arraysize(kLayoutTestsPattern) - 1; |
| 66 static const char kFileUrlPattern[] = "file:/"; | 68 static const char kFileUrlPattern[] = "file:/"; |
| 67 static const char kDataUrlPattern[] = "data:"; | 69 static const char kDataUrlPattern[] = "data:"; |
| 68 static const std::string::size_type kDataUrlPatternSize = | 70 static const std::string::size_type kDataUrlPatternSize = |
| 69 arraysize(kDataUrlPattern) - 1; | 71 arraysize(kDataUrlPattern) - 1; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 result.append(L"'\n--------\n"); | 118 result.append(L"'\n--------\n"); |
| 117 } | 119 } |
| 118 | 120 |
| 119 result.append(DumpDocumentText(web_frame)); | 121 result.append(DumpDocumentText(web_frame)); |
| 120 result.append(L"\n"); | 122 result.append(L"\n"); |
| 121 | 123 |
| 122 if (recursive) { | 124 if (recursive) { |
| 123 WebCore::Frame* child = webFrameImpl->frame()->tree()->firstChild(); | 125 WebCore::Frame* child = webFrameImpl->frame()->tree()->firstChild(); |
| 124 for (; child; child = child->tree()->nextSibling()) { | 126 for (; child; child = child->tree()->nextSibling()) { |
| 125 result.append( | 127 result.append( |
| 126 DumpFramesAsText(WebFrameImpl::FromFrame(child), recursive)); | 128 DumpFramesAsText(WebFrameImpl::fromFrame(child), recursive)); |
| 127 } | 129 } |
| 128 } | 130 } |
| 129 | 131 |
| 130 return result; | 132 return result; |
| 131 } | 133 } |
| 132 | 134 |
| 133 std::wstring DumpRenderer(WebFrame* web_frame) { | 135 std::wstring DumpRenderer(WebFrame* web_frame) { |
| 134 WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(web_frame); | 136 WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(web_frame); |
| 135 WebCore::Frame* frame = webFrameImpl->frame(); | 137 WebCore::Frame* frame = webFrameImpl->frame(); |
| 136 | 138 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 148 frame->document()->getElementById(WebCore::AtomicString(id.c_str())); | 150 frame->document()->getElementById(WebCore::AtomicString(id.c_str())); |
| 149 if (!element) | 151 if (!element) |
| 150 return false; | 152 return false; |
| 151 WebCore::String counterValue = WebCore::counterValueForElement(element); | 153 WebCore::String counterValue = WebCore::counterValueForElement(element); |
| 152 *counter_value = StringToStdWString(counterValue); | 154 *counter_value = StringToStdWString(counterValue); |
| 153 return true; | 155 return true; |
| 154 } | 156 } |
| 155 | 157 |
| 156 std::wstring DumpFrameScrollPosition(WebFrame* web_frame, bool recursive) { | 158 std::wstring DumpFrameScrollPosition(WebFrame* web_frame, bool recursive) { |
| 157 WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(web_frame); | 159 WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(web_frame); |
| 158 WebCore::IntSize offset = webFrameImpl->frameview()->scrollOffset(); | 160 WebCore::IntSize offset = webFrameImpl->frameView()->scrollOffset(); |
| 159 std::wstring result; | 161 std::wstring result; |
| 160 | 162 |
| 161 if (offset.width() > 0 || offset.height() > 0) { | 163 if (offset.width() > 0 || offset.height() > 0) { |
| 162 if (webFrameImpl->parent()) { | 164 if (webFrameImpl->parent()) { |
| 163 StringAppendF(&result, L"frame '%ls' ", StringToStdWString( | 165 StringAppendF(&result, L"frame '%ls' ", StringToStdWString( |
| 164 webFrameImpl->frame()->tree()->name()).c_str()); | 166 webFrameImpl->frame()->tree()->name()).c_str()); |
| 165 } | 167 } |
| 166 StringAppendF(&result, L"scrolled to %d,%d\n", | 168 StringAppendF(&result, L"scrolled to %d,%d\n", |
| 167 offset.width(), offset.height()); | 169 offset.width(), offset.height()); |
| 168 } | 170 } |
| 169 | 171 |
| 170 if (recursive) { | 172 if (recursive) { |
| 171 WebCore::Frame* child = webFrameImpl->frame()->tree()->firstChild(); | 173 WebCore::Frame* child = webFrameImpl->frame()->tree()->firstChild(); |
| 172 for (; child; child = child->tree()->nextSibling()) { | 174 for (; child; child = child->tree()->nextSibling()) { |
| 173 result.append(DumpFrameScrollPosition(WebFrameImpl::FromFrame(child), | 175 result.append(DumpFrameScrollPosition(WebFrameImpl::fromFrame(child), |
| 174 recursive)); | 176 recursive)); |
| 175 } | 177 } |
| 176 } | 178 } |
| 177 | 179 |
| 178 return result; | 180 return result; |
| 179 } | 181 } |
| 180 | 182 |
| 181 // Returns True if item1 < item2. | 183 // Returns True if item1 < item2. |
| 182 static bool HistoryItemCompareLess(const WebHistoryItem& item1, | 184 static bool HistoryItemCompareLess(const WebHistoryItem& item1, |
| 183 const WebHistoryItem& item2) { | 185 const WebHistoryItem& item2) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 // The log macro was having problems due to collisions with WTF, so we just | 269 // The log macro was having problems due to collisions with WTF, so we just |
| 268 // code here what that would have inlined. | 270 // code here what that would have inlined. |
| 269 void DumpLeakedObject(const char* file, int line, const char* object, int count)
{ | 271 void DumpLeakedObject(const char* file, int line, const char* object, int count)
{ |
| 270 std::string msg = StringPrintf("%s LEAKED %d TIMES", object, count); | 272 std::string msg = StringPrintf("%s LEAKED %d TIMES", object, count); |
| 271 AppendToLog(file, line, msg.c_str()); | 273 AppendToLog(file, line, msg.c_str()); |
| 272 } | 274 } |
| 273 #endif | 275 #endif |
| 274 | 276 |
| 275 void CheckForLeaks() { | 277 void CheckForLeaks() { |
| 276 #ifndef NDEBUG | 278 #ifndef NDEBUG |
| 277 int count = WebFrameImpl::live_object_count(); | 279 int count = WebFrameImpl::liveObjectCount(); |
| 278 if (count) | 280 if (count) |
| 279 DumpLeakedObject(__FILE__, __LINE__, "WebFrame", count); | 281 DumpLeakedObject(__FILE__, __LINE__, "WebFrame", count); |
| 280 #endif | 282 #endif |
| 281 } | 283 } |
| 282 | 284 |
| 283 bool DecodeImage(const std::string& image_data, SkBitmap* image) { | 285 bool DecodeImage(const std::string& image_data, SkBitmap* image) { |
| 284 RefPtr<WebCore::SharedBuffer> buffer( | 286 RefPtr<WebCore::SharedBuffer> buffer( |
| 285 WebCore::SharedBuffer::create(image_data.data(), | 287 WebCore::SharedBuffer::create(image_data.data(), |
| 286 static_cast<int>(image_data.length()))); | 288 static_cast<int>(image_data.length()))); |
| 287 WebCore::ImageSource image_source; | 289 WebCore::ImageSource image_source; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 518 |
| 517 bool IsMediaCacheEnabled() { | 519 bool IsMediaCacheEnabled() { |
| 518 return g_enable_media_cache; | 520 return g_enable_media_cache; |
| 519 } | 521 } |
| 520 | 522 |
| 521 void SetMediaCacheEnabled(bool enabled) { | 523 void SetMediaCacheEnabled(bool enabled) { |
| 522 g_enable_media_cache = enabled; | 524 g_enable_media_cache = enabled; |
| 523 } | 525 } |
| 524 | 526 |
| 525 } // namespace webkit_glue | 527 } // namespace webkit_glue |
| OLD | NEW |