| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1934 | 1934 |
| 1935 // TODO(esprehn): Blink only ever passes Elements, this should take WebElement. | 1935 // TODO(esprehn): Blink only ever passes Elements, this should take WebElement. |
| 1936 void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode, | 1936 void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode, |
| 1937 const WebNode& toNode) { | 1937 const WebNode& toNode) { |
| 1938 has_scrolled_focused_editable_node_into_rect_ = false; | 1938 has_scrolled_focused_editable_node_into_rect_ = false; |
| 1939 | 1939 |
| 1940 gfx::Rect node_bounds; | 1940 gfx::Rect node_bounds; |
| 1941 bool is_editable = false; | 1941 bool is_editable = false; |
| 1942 if (!toNode.isNull() && toNode.isElementNode()) { | 1942 if (!toNode.isNull() && toNode.isElementNode()) { |
| 1943 WebElement element = const_cast<WebNode&>(toNode).to<WebElement>(); | 1943 WebElement element = const_cast<WebNode&>(toNode).to<WebElement>(); |
| 1944 node_bounds = gfx::Rect(element.boundsInViewport()); | 1944 blink::WebRect rect = element.boundsInViewport(); |
| 1945 convertViewportToWindow(&rect); |
| 1946 node_bounds = gfx::Rect(rect); |
| 1945 is_editable = element.isEditable(); | 1947 is_editable = element.isEditable(); |
| 1946 } | 1948 } |
| 1947 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, is_editable, | 1949 Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, is_editable, |
| 1948 node_bounds)); | 1950 node_bounds)); |
| 1949 | 1951 |
| 1950 // TODO(estade): remove. | 1952 // TODO(estade): remove. |
| 1951 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(toNode)); | 1953 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(toNode)); |
| 1952 | 1954 |
| 1953 RenderFrameImpl* previous_frame = nullptr; | 1955 RenderFrameImpl* previous_frame = nullptr; |
| 1954 if (!fromNode.isNull()) | 1956 if (!fromNode.isNull()) |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 | 2131 |
| 2130 SSLStatus result; | 2132 SSLStatus result; |
| 2131 CHECK(DeserializeSecurityInfo(security_info, &result)); | 2133 CHECK(DeserializeSecurityInfo(security_info, &result)); |
| 2132 return result; | 2134 return result; |
| 2133 } | 2135 } |
| 2134 | 2136 |
| 2135 const std::string& RenderViewImpl::GetAcceptLanguages() const { | 2137 const std::string& RenderViewImpl::GetAcceptLanguages() const { |
| 2136 return renderer_preferences_.accept_languages; | 2138 return renderer_preferences_.accept_languages; |
| 2137 } | 2139 } |
| 2138 | 2140 |
| 2141 void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) { |
| 2142 if (IsUseZoomForDSFEnabled()) { |
| 2143 float reverse = 1 / device_scale_factor_; |
| 2144 // TODO(oshima): We may wait to allow pixel precision here as the the |
| 2145 // anchor element can be placed at half pixel. |
| 2146 gfx::Rect window_rect = |
| 2147 gfx::ScaleToEnclosedRect(gfx::Rect(*rect), reverse); |
| 2148 rect->x = window_rect.x(); |
| 2149 rect->y = window_rect.y(); |
| 2150 rect->width = window_rect.width(); |
| 2151 rect->height = window_rect.height(); |
| 2152 } |
| 2153 } |
| 2154 |
| 2139 void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, | 2155 void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, |
| 2140 WebIconURL::Type icon_type) { | 2156 WebIconURL::Type icon_type) { |
| 2141 if (frame->parent()) | 2157 if (frame->parent()) |
| 2142 return; | 2158 return; |
| 2143 | 2159 |
| 2144 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); | 2160 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); |
| 2145 std::vector<FaviconURL> urls; | 2161 std::vector<FaviconURL> urls; |
| 2146 for (size_t i = 0; i < icon_urls.size(); i++) { | 2162 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 2147 std::vector<gfx::Size> sizes; | 2163 std::vector<gfx::Size> sizes; |
| 2148 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 2164 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3720 if (IsUseZoomForDSFEnabled()) { | 3736 if (IsUseZoomForDSFEnabled()) { |
| 3721 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_); | 3737 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_); |
| 3722 webview()->setZoomFactorForDeviceScaleFactor( | 3738 webview()->setZoomFactorForDeviceScaleFactor( |
| 3723 device_scale_factor_); | 3739 device_scale_factor_); |
| 3724 } else { | 3740 } else { |
| 3725 webview()->setDeviceScaleFactor(device_scale_factor_); | 3741 webview()->setDeviceScaleFactor(device_scale_factor_); |
| 3726 } | 3742 } |
| 3727 } | 3743 } |
| 3728 | 3744 |
| 3729 } // namespace content | 3745 } // namespace content |
| OLD | NEW |