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 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2433 } | 2433 } |
2434 | 2434 |
2435 void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) { | 2435 void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) { |
2436 OnUpdateWebPreferences(preferences); | 2436 OnUpdateWebPreferences(preferences); |
2437 } | 2437 } |
2438 | 2438 |
2439 blink::WebView* RenderViewImpl::GetWebView() { | 2439 blink::WebView* RenderViewImpl::GetWebView() { |
2440 return webview(); | 2440 return webview(); |
2441 } | 2441 } |
2442 | 2442 |
2443 blink::WebElement RenderViewImpl::GetFocusedElement() const { | |
2444 if (!webview()) | |
2445 return WebElement(); | |
2446 WebFrame* focused_frame = webview()->focusedFrame(); | |
2447 if (focused_frame) { | |
2448 WebDocument doc = focused_frame->document(); | |
2449 if (!doc.isNull()) | |
2450 return doc.focusedElement(); | |
2451 } | |
2452 | |
2453 return WebElement(); | |
2454 } | |
2455 | |
2456 bool RenderViewImpl::IsEditableNode(const WebNode& node) const { | 2443 bool RenderViewImpl::IsEditableNode(const WebNode& node) const { |
2457 if (node.isNull()) | 2444 if (node.isNull()) |
2458 return false; | 2445 return false; |
2459 | 2446 |
2460 if (node.isContentEditable()) | 2447 if (node.isContentEditable()) |
2461 return true; | 2448 return true; |
2462 | 2449 |
2463 if (node.isElementNode()) { | 2450 if (node.isElementNode()) { |
2464 const WebElement& element = node.toConst<WebElement>(); | 2451 const WebElement& element = node.toConst<WebElement>(); |
2465 if (element.isTextFormControlElement()) { | 2452 if (element.isTextFormControlElement()) { |
2466 if (!(element.hasAttribute("readonly") || | 2453 if (!(element.hasAttribute("readonly") || |
2467 element.hasAttribute("disabled"))) | 2454 element.hasAttribute("disabled"))) |
2468 return true; | 2455 return true; |
2469 } | 2456 } |
2470 | 2457 |
2471 // Also return true if it has an ARIA role of 'textbox'. | 2458 // Also return true if it has an ARIA role of 'textbox'. |
2472 for (unsigned i = 0; i < element.attributeCount(); ++i) { | 2459 for (unsigned i = 0; i < element.attributeCount(); ++i) { |
2473 if (LowerCaseEqualsASCII(element.attributeLocalName(i), "role")) { | 2460 if (LowerCaseEqualsASCII(element.attributeLocalName(i), "role")) { |
2474 if (LowerCaseEqualsASCII(element.attributeValue(i), "textbox")) | 2461 if (LowerCaseEqualsASCII(element.attributeValue(i), "textbox")) |
2475 return true; | 2462 return true; |
2476 break; | 2463 break; |
2477 } | 2464 } |
2478 } | 2465 } |
2479 } | 2466 } |
2480 | 2467 |
2481 return false; | 2468 return false; |
2482 } | 2469 } |
2483 | 2470 |
2484 bool RenderViewImpl::NodeContainsPoint(const WebNode& node, | |
2485 const gfx::Point& point) const { | |
2486 blink::WebHitTestResult hit_test = | |
2487 webview()->hitTestResultAt(WebPoint(point.x(), point.y())); | |
2488 return node.containsIncludingShadowDOM(hit_test.node()); | |
2489 } | |
2490 | |
2491 bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const { | 2471 bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const { |
2492 return (!send_preferred_size_changes_ || | 2472 return (!send_preferred_size_changes_ || |
2493 (disable_scrollbars_size_limit_.width() <= width || | 2473 (disable_scrollbars_size_limit_.width() <= width || |
2494 disable_scrollbars_size_limit_.height() <= height)); | 2474 disable_scrollbars_size_limit_.height() <= height)); |
2495 } | 2475 } |
2496 | 2476 |
2497 int RenderViewImpl::GetEnabledBindings() const { | 2477 int RenderViewImpl::GetEnabledBindings() const { |
2498 return enabled_bindings_; | 2478 return enabled_bindings_; |
2499 } | 2479 } |
2500 | 2480 |
(...skipping 12 matching lines...) Expand all Loading... |
2513 void RenderViewImpl::DidStopLoading() { | 2493 void RenderViewImpl::DidStopLoading() { |
2514 main_render_frame_->didStopLoading(); | 2494 main_render_frame_->didStopLoading(); |
2515 } | 2495 } |
2516 | 2496 |
2517 void RenderViewImpl::SyncNavigationState() { | 2497 void RenderViewImpl::SyncNavigationState() { |
2518 if (!webview()) | 2498 if (!webview()) |
2519 return; | 2499 return; |
2520 SendUpdateState(history_controller_->GetCurrentEntry()); | 2500 SendUpdateState(history_controller_->GetCurrentEntry()); |
2521 } | 2501 } |
2522 | 2502 |
| 2503 blink::WebElement RenderViewImpl::GetFocusedElement() const { |
| 2504 if (!webview()) |
| 2505 return WebElement(); |
| 2506 WebFrame* focused_frame = webview()->focusedFrame(); |
| 2507 if (focused_frame) { |
| 2508 WebDocument doc = focused_frame->document(); |
| 2509 if (!doc.isNull()) |
| 2510 return doc.focusedElement(); |
| 2511 } |
| 2512 |
| 2513 return WebElement(); |
| 2514 } |
| 2515 |
2523 blink::WebPlugin* RenderViewImpl::GetWebPluginForFind() { | 2516 blink::WebPlugin* RenderViewImpl::GetWebPluginForFind() { |
2524 if (!webview()) | 2517 if (!webview()) |
2525 return NULL; | 2518 return NULL; |
2526 | 2519 |
2527 WebFrame* main_frame = webview()->mainFrame(); | 2520 WebFrame* main_frame = webview()->mainFrame(); |
2528 if (main_frame->isWebLocalFrame() && | 2521 if (main_frame->isWebLocalFrame() && |
2529 main_frame->document().isPluginDocument()) | 2522 main_frame->document().isPluginDocument()) |
2530 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); | 2523 return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
2531 | 2524 |
2532 #if defined(ENABLE_PLUGINS) | 2525 #if defined(ENABLE_PLUGINS) |
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4099 std::vector<gfx::Size> sizes; | 4092 std::vector<gfx::Size> sizes; |
4100 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4093 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4101 if (!url.isEmpty()) | 4094 if (!url.isEmpty()) |
4102 urls.push_back( | 4095 urls.push_back( |
4103 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4096 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4104 } | 4097 } |
4105 SendUpdateFaviconURL(urls); | 4098 SendUpdateFaviconURL(urls); |
4106 } | 4099 } |
4107 | 4100 |
4108 } // namespace content | 4101 } // namespace content |
OLD | NEW |