Merge remote-tracking branch 'upstream/master' into speedup-gpu

This commit is contained in:
gellert 2016-08-01 12:00:34 +02:00
commit 439ad94afe
85 changed files with 1592 additions and 757 deletions

View file

@ -8,7 +8,6 @@
#include "atom/browser/api/atom_api_menu.h"
#include "atom/browser/browser.h"
#include "atom/browser/ui/tray_icon.h"
#include "atom/common/api/atom_api_native_image.h"
#include "atom/common/native_mate_converters/gfx_converter.h"
#include "atom/common/native_mate_converters/image_converter.h"
@ -18,6 +17,45 @@
#include "native_mate/dictionary.h"
#include "ui/gfx/image/image.h"
namespace mate {
template<>
struct Converter<atom::TrayIcon::HighlightMode> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
atom::TrayIcon::HighlightMode* out) {
std::string mode;
if (ConvertFromV8(isolate, val, &mode)) {
if (mode == "always") {
*out = atom::TrayIcon::HighlightMode::ALWAYS;
return true;
}
if (mode == "selection") {
*out = atom::TrayIcon::HighlightMode::SELECTION;
return true;
}
if (mode == "never") {
*out = atom::TrayIcon::HighlightMode::NEVER;
return true;
}
}
// Support old boolean parameter
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
bool highlight;
if (ConvertFromV8(isolate, val, &highlight)) {
if (highlight)
*out = atom::TrayIcon::HighlightMode::SELECTION;
else
*out = atom::TrayIcon::HighlightMode::NEVER;
return true;
}
return false;
}
};
} // namespace mate
namespace atom {
namespace api {
@ -117,8 +155,8 @@ void Tray::SetTitle(const std::string& title) {
tray_icon_->SetTitle(title);
}
void Tray::SetHighlightMode(bool highlight) {
tray_icon_->SetHighlightMode(highlight);
void Tray::SetHighlightMode(TrayIcon::HighlightMode mode) {
tray_icon_->SetHighlightMode(mode);
}
void Tray::DisplayBalloon(mate::Arguments* args,

View file

@ -10,6 +10,7 @@
#include <vector>
#include "atom/browser/api/trackable_object.h"
#include "atom/browser/ui/tray_icon.h"
#include "atom/browser/ui/tray_icon_observer.h"
#include "native_mate/handle.h"
@ -62,7 +63,7 @@ class Tray : public mate::TrackableObject<Tray>,
void SetPressedImage(v8::Isolate* isolate, mate::Handle<NativeImage> image);
void SetToolTip(const std::string& tool_tip);
void SetTitle(const std::string& title);
void SetHighlightMode(bool highlight);
void SetHighlightMode(TrayIcon::HighlightMode mode);
void DisplayBalloon(mate::Arguments* args, const mate::Dictionary& options);
void PopUpContextMenu(mate::Arguments* args);
void SetContextMenu(v8::Isolate* isolate, mate::Handle<Menu> menu);

View file

@ -772,7 +772,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
}
// There are three ways of destroying a webContents:
// 1. call webContents.destory();
// 1. call webContents.destroy();
// 2. garbage collection;
// 3. user closes the window of webContents;
// For webview only #1 will happen, for BrowserWindow both #1 and #3 may
@ -1175,6 +1175,12 @@ void WebContents::ShowDefinitionForSelection() {
#endif
}
void WebContents::CopyImageAt(int x, int y) {
const auto host = web_contents()->GetRenderViewHost();
if (host)
host->CopyImageAt(x, y);
}
void WebContents::Focus() {
web_contents()->Focus();
}
@ -1518,6 +1524,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
.SetMethod("showDefinitionForSelection",
&WebContents::ShowDefinitionForSelection)
.SetMethod("copyImageAt", &WebContents::CopyImageAt)
.SetMethod("capturePage", &WebContents::CapturePage)
.SetMethod("isFocused", &WebContents::IsFocused)
.SetMethod("isOffscreen", &WebContents::IsOffScreen)

View file

@ -129,6 +129,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
uint32_t FindInPage(mate::Arguments* args);
void StopFindInPage(content::StopFindAction action);
void ShowDefinitionForSelection();
void CopyImageAt(int x, int y);
// Focus.
void Focus();

View file

@ -13,6 +13,9 @@ namespace atom {
namespace api {
bool WebContents::IsFocused() const {
auto view = web_contents()->GetRenderWidgetHostView();
if (!view) return false;
if (GetType() != BACKGROUND_PAGE) {
auto window = web_contents()->GetTopLevelNativeWindow();
// On Mac the render widget host view does not lose focus when the window
@ -21,8 +24,7 @@ bool WebContents::IsFocused() const {
return false;
}
auto view = web_contents()->GetRenderWidgetHostView();
return view && view->HasFocus();
return view->HasFocus();
}
} // namespace api