Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2623483003: Support tracking focused node element for OOPIFs. (Closed)
Patch Set: Added the missing forward declaration Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 5b98a031a79c21e96dc63a393fde43edf3ac1b59..574053731784ad9ff8fe33c4698fa58c0368b09e 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -94,6 +94,7 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/download_url_parameters.h"
+#include "content/public/browser/focused_node_details.h"
#include "content/public/browser/guest_mode.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/javascript_dialog_manager.h"
@@ -138,6 +139,11 @@
#include "ui/events/blink/web_input_event_traits.h"
#include "ui/gl/gl_switches.h"
+#if defined(OS_WIN)
+#include "content/browser/renderer_host/dip_util.h"
+#include "ui/gfx/geometry/dip_util.h"
+#endif
+
#if defined(OS_ANDROID)
#include "content/browser/android/content_video_view.h"
#include "content/browser/android/date_time_chooser_android.h"
@@ -4185,6 +4191,16 @@ bool WebContentsImpl::HideDownloadUI() const {
return is_overlay_content_;
}
+bool WebContentsImpl::IsFocusedElementEditable() {
+ RenderFrameHostImpl* frame = GetFocusedFrame();
+ return frame && frame->has_focused_editable_element();
+}
+
+void WebContentsImpl::ClearFocusedElement() {
+ if (auto* frame = GetFocusedFrame())
+ frame->ClearFocusedElement();
+}
+
bool WebContentsImpl::IsNeverVisible() {
if (!delegate_)
return false;
@@ -4688,6 +4704,33 @@ void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node,
frame_tree_.SetFocusedFrame(node, source);
}
+void WebContentsImpl::OnFocusedElementChangedInFrame(
+ RenderFrameHostImpl* frame,
+ const gfx::Rect& bounds_in_root_view) {
+ RenderWidgetHostViewBase* root_view =
+ static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView());
+ if (!root_view || !frame->GetView())
+ return;
+
+ // Converting to screen coordinates.
+ gfx::Point origin = bounds_in_root_view.origin();
+ origin += root_view->GetViewBounds().OffsetFromOrigin();
+ gfx::Rect bounds_in_screen(origin, bounds_in_root_view.size());
+
+ root_view->FocusedNodeChanged(frame->has_focused_editable_element(),
+ bounds_in_screen);
+
+ FocusedNodeDetails details = {frame->has_focused_editable_element(),
+ bounds_in_screen};
+
+ // TODO(ekaramad): We should replace this with an observer notification
+ // (https://crbug.com/675975).
+ NotificationService::current()->Notify(
+ NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
+ Source<RenderViewHost>(GetRenderViewHost()),
+ Details<FocusedNodeDetails>(&details));
+}
+
bool WebContentsImpl::DidAddMessageToConsole(int32_t level,
const base::string16& message,
int32_t line_no,
@@ -5283,4 +5326,19 @@ void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) {
binding_sets_.erase(it);
}
+void WebContentsImpl::FocusedNodeTouched(bool editable) {
+#if defined(OS_WIN)
+ // We use the cursor position to determine where the touch occurred.
+ RenderWidgetHostView* view = GetRenderWidgetHostView();
+ if (!view)
+ return;
+ POINT cursor_pos = {};
+ ::GetCursorPos(&cursor_pos);
+ float scale = GetScaleFactorForView(view);
+ gfx::Point location_dips_screen =
+ gfx::ConvertPointToDIP(scale, gfx::Point(cursor_pos));
+ view->FocusedNodeTouched(location_dips_screen, editable);
+#endif
+}
+
} // namespace content
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698