| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 Google Inc. All Rights Reserved. | 2 * Copyright 2007 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * ***** BEGIN LICENSE BLOCK ***** | 6 * ***** BEGIN LICENSE BLOCK ***** |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return instance; | 133 return instance; |
| 134 } | 134 } |
| 135 | 135 |
| 136 WebViewImpl::WebViewImpl() | 136 WebViewImpl::WebViewImpl() |
| 137 : delegate_(NULL), | 137 : delegate_(NULL), |
| 138 pending_history_item_(NULL), | 138 pending_history_item_(NULL), |
| 139 observed_new_navigation_(false), | 139 observed_new_navigation_(false), |
| 140 #ifndef NDEBUG | 140 #ifndef NDEBUG |
| 141 new_navigation_loader_(NULL), | 141 new_navigation_loader_(NULL), |
| 142 #endif | 142 #endif |
| 143 text_zoom_level_(0), | 143 zoom_level_(0), |
| 144 context_menu_allowed_(false), | 144 context_menu_allowed_(false), |
| 145 doing_drag_and_drop_(false), | 145 doing_drag_and_drop_(false), |
| 146 suppress_next_keypress_event_(false), | 146 suppress_next_keypress_event_(false), |
| 147 window_open_disposition_(IGNORE_ACTION), | 147 window_open_disposition_(IGNORE_ACTION), |
| 148 ime_accept_events_(true) { | 148 ime_accept_events_(true) { |
| 149 // WebKit/win/WebView.cpp does the same thing, except they call the | 149 // WebKit/win/WebView.cpp does the same thing, except they call the |
| 150 // KJS specific wrapper around this method. We need to have threading | 150 // KJS specific wrapper around this method. We need to have threading |
| 151 // initialized because CollatorICU requires it. | 151 // initialized because CollatorICU requires it. |
| 152 WTF::initializeThreading(); | 152 WTF::initializeThreading(); |
| 153 | 153 |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 | 1151 |
| 1152 // Return the canonical encoding name of current main webframe in webview. | 1152 // Return the canonical encoding name of current main webframe in webview. |
| 1153 std::wstring WebViewImpl::GetMainFrameEncodingName() { | 1153 std::wstring WebViewImpl::GetMainFrameEncodingName() { |
| 1154 if (!main_frame_) | 1154 if (!main_frame_) |
| 1155 return std::wstring(L""); | 1155 return std::wstring(L""); |
| 1156 | 1156 |
| 1157 String encoding_name = main_frame_->frame()->loader()->encoding(); | 1157 String encoding_name = main_frame_->frame()->loader()->encoding(); |
| 1158 return webkit_glue::StringToStdWString(encoding_name); | 1158 return webkit_glue::StringToStdWString(encoding_name); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 void WebViewImpl::MakeTextLarger() { | 1161 void WebViewImpl::ZoomIn(bool text_only) { |
| 1162 Frame* frame = main_frame()->frame(); | 1162 Frame* frame = main_frame()->frame(); |
| 1163 double multiplier = std::min(std::pow(kTextSizeMultiplierRatio, | 1163 double multiplier = std::min(std::pow(kTextSizeMultiplierRatio, |
| 1164 text_zoom_level_ + 1), | 1164 zoom_level_ + 1), |
| 1165 kMaxTextSizeMultiplier); | 1165 kMaxTextSizeMultiplier); |
| 1166 float zoom_factor = static_cast<float>(multiplier); | 1166 float zoom_factor = static_cast<float>(multiplier); |
| 1167 if (zoom_factor != frame->zoomFactor()) { | 1167 if (zoom_factor != frame->zoomFactor()) { |
| 1168 ++text_zoom_level_; | 1168 ++zoom_level_; |
| 1169 frame->setZoomFactor(zoom_factor, false); | 1169 frame->setZoomFactor(zoom_factor, text_only); |
| 1170 } | 1170 } |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 void WebViewImpl::MakeTextSmaller() { | 1173 void WebViewImpl::ZoomOut(bool text_only) { |
| 1174 Frame* frame = main_frame()->frame(); | 1174 Frame* frame = main_frame()->frame(); |
| 1175 double multiplier = std::max(std::pow(kTextSizeMultiplierRatio, | 1175 double multiplier = std::max(std::pow(kTextSizeMultiplierRatio, |
| 1176 text_zoom_level_ - 1), | 1176 zoom_level_ - 1), |
| 1177 kMinTextSizeMultiplier); | 1177 kMinTextSizeMultiplier); |
| 1178 float zoom_factor = static_cast<float>(multiplier); | 1178 float zoom_factor = static_cast<float>(multiplier); |
| 1179 if (zoom_factor != frame->zoomFactor()) { | 1179 if (zoom_factor != frame->zoomFactor()) { |
| 1180 --text_zoom_level_; | 1180 --zoom_level_; |
| 1181 frame->setZoomFactor(zoom_factor, false); | 1181 frame->setZoomFactor(zoom_factor, text_only); |
| 1182 } | 1182 } |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 void WebViewImpl::MakeTextStandardSize() { | 1185 void WebViewImpl::ResetZoom() { |
| 1186 text_zoom_level_ = 0; | 1186 // We don't change the zoom mode (text only vs. full page) here. We just want |
| 1187 main_frame()->frame()->setZoomFactor(1.0f, false); | 1187 // to reset whatever is already set. |
| 1188 zoom_level_ = 0; |
| 1189 main_frame()->frame()->setZoomFactor( |
| 1190 1.0f, |
| 1191 main_frame()->frame()->isZoomFactorTextOnly()); |
| 1188 } | 1192 } |
| 1189 | 1193 |
| 1190 void WebViewImpl::CopyImageAt(int x, int y) { | 1194 void WebViewImpl::CopyImageAt(int x, int y) { |
| 1191 IntPoint point = IntPoint(x, y); | 1195 IntPoint point = IntPoint(x, y); |
| 1192 | 1196 |
| 1193 Frame* frame = main_frame_->frame(); | 1197 Frame* frame = main_frame_->frame(); |
| 1194 if (!frame) | 1198 if (!frame) |
| 1195 return; | 1199 return; |
| 1196 | 1200 |
| 1197 HitTestResult result = | 1201 HitTestResult result = |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 } | 1541 } |
| 1538 | 1542 |
| 1539 void WebViewImpl::DeleteImageResourceFetcher(ImageResourceFetcher* fetcher) { | 1543 void WebViewImpl::DeleteImageResourceFetcher(ImageResourceFetcher* fetcher) { |
| 1540 DCHECK(image_fetchers_.find(fetcher) != image_fetchers_.end()); | 1544 DCHECK(image_fetchers_.find(fetcher) != image_fetchers_.end()); |
| 1541 image_fetchers_.erase(fetcher); | 1545 image_fetchers_.erase(fetcher); |
| 1542 | 1546 |
| 1543 // We're in the callback from the ImageResourceFetcher, best to delay | 1547 // We're in the callback from the ImageResourceFetcher, best to delay |
| 1544 // deletion. | 1548 // deletion. |
| 1545 MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher); | 1549 MessageLoop::current()->DeleteSoon(FROM_HERE, fetcher); |
| 1546 } | 1550 } |
| OLD | NEW |