Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
add link hover and load progress events
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed Jun 8, 2016
1 parent ee24eec commit 04b032e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/screen.h"

#include "atom/common/node_includes.h"

Expand Down Expand Up @@ -493,7 +494,16 @@ void WebContents::ActivateContents(content::WebContents* source) {

void WebContents::UpdateTargetURL(content::WebContents* source,
const GURL& url) {
Emit("update-target-url", url);
const gfx::Point& location = gfx::Screen::GetScreen()->GetCursorScreenPoint();
const gfx::Rect& bounds = web_contents()->GetContainerBounds();
int x = location.x() - bounds.x();
int y = location.y() - bounds.y();
Emit("update-target-url", url, x, y);
}

void WebContents::LoadProgressChanged(content::WebContents* source,
double progress) {
Emit("load-progress-changed", progress);
}

bool WebContents::IsPopupOrPanel(const content::WebContents* source) const {
Expand Down
2 changes: 2 additions & 0 deletions atom/browser/api/atom_api_web_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
void CloseContents(content::WebContents* source) override;
void ActivateContents(content::WebContents* contents) override;
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
void LoadProgressChanged(content::WebContents* source,
double progress) override;
bool IsPopupOrPanel(const content::WebContents* source) const override;
void HandleKeyboardEvent(
content::WebContents* source,
Expand Down
1 change: 1 addition & 0 deletions lib/browser/guest-view-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let supportedWebViewEvents = [
'found-in-page',
'did-change-theme-color',
'update-target-url',
'load-progress-changed',
'set-active',
'context-menu'
]
Expand Down
3 changes: 2 additions & 1 deletion lib/renderer/web-view/guest-view-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ var WEB_VIEW_EVENTS = {
'media-paused': [],
'found-in-page': ['result'],
'did-change-theme-color': ['themeColor'],
'update-target-url': ['url'],
'update-target-url': ['url', 'x', 'y'],
'load-progress-changed': ['progress'],
'set-active': ['active'],
'context-menu': ['params']
}
Expand Down

0 comments on commit 04b032e

Please sign in to comment.