fix: return pointer instead of pointer's content (#16641)
This commit is contained in:
parent
440a3fa6d8
commit
8ab1309215
10 changed files with 344 additions and 324 deletions
|
@ -667,8 +667,8 @@ v8::Local<v8::Value> TopLevelWindow::GetNativeWindowHandle() {
|
|||
// TODO(MarshallOfSound): Replace once
|
||||
// https://chromium-review.googlesource.com/c/chromium/src/+/1253094/ has
|
||||
// landed
|
||||
auto handle = window_->GetNativeWindowHandlePointer();
|
||||
return ToBuffer(isolate(), std::get<0>(handle), std::get<1>(handle));
|
||||
NativeWindowHandle handle = window_->GetNativeWindowHandle();
|
||||
return ToBuffer(isolate(), &handle, sizeof(handle));
|
||||
}
|
||||
|
||||
void TopLevelWindow::SetProgressBar(double progress, mate::Arguments* args) {
|
||||
|
|
|
@ -45,6 +45,12 @@ class NativeBrowserView;
|
|||
|
||||
struct DraggableRegion;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
typedef NSView* NativeWindowHandle;
|
||||
#else
|
||||
typedef gfx::AcceleratedWidget NativeWindowHandle;
|
||||
#endif
|
||||
|
||||
class NativeWindow : public base::SupportsUserData,
|
||||
public views::WidgetDelegate {
|
||||
public:
|
||||
|
@ -151,7 +157,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual gfx::NativeView GetNativeView() const = 0;
|
||||
virtual gfx::NativeWindow GetNativeWindow() const = 0;
|
||||
virtual gfx::AcceleratedWidget GetAcceleratedWidget() const = 0;
|
||||
virtual std::tuple<void*, int> GetNativeWindowHandlePointer() const = 0;
|
||||
virtual NativeWindowHandle GetNativeWindowHandle() const = 0;
|
||||
|
||||
// Taskbar/Dock APIs.
|
||||
enum ProgressState {
|
||||
|
|
|
@ -104,7 +104,7 @@ class NativeWindowMac : public NativeWindow {
|
|||
gfx::NativeView GetNativeView() const override;
|
||||
gfx::NativeWindow GetNativeWindow() const override;
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget() const override;
|
||||
std::tuple<void*, int> GetNativeWindowHandlePointer() const override;
|
||||
NativeWindowHandle GetNativeWindowHandle() const override;
|
||||
void SetProgressBar(double progress, const ProgressState state) override;
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
|
|
|
@ -1081,9 +1081,8 @@ gfx::AcceleratedWidget NativeWindowMac::GetAcceleratedWidget() const {
|
|||
return gfx::kNullAcceleratedWidget;
|
||||
}
|
||||
|
||||
std::tuple<void*, int> NativeWindowMac::GetNativeWindowHandlePointer() const {
|
||||
NSView* view = [window_ contentView];
|
||||
return std::make_tuple(static_cast<void*>(view), sizeof(view));
|
||||
NativeWindowHandle NativeWindowMac::GetNativeWindowHandle() const {
|
||||
return [window_ contentView];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetProgressBar(double progress,
|
||||
|
|
|
@ -1047,9 +1047,8 @@ gfx::AcceleratedWidget NativeWindowViews::GetAcceleratedWidget() const {
|
|||
return GetNativeWindow()->GetHost()->GetAcceleratedWidget();
|
||||
}
|
||||
|
||||
std::tuple<void*, int> NativeWindowViews::GetNativeWindowHandlePointer() const {
|
||||
gfx::AcceleratedWidget handle = GetAcceleratedWidget();
|
||||
return std::make_tuple(static_cast<void*>(&handle), sizeof(handle));
|
||||
NativeWindowHandle NativeWindowViews::GetNativeWindowHandle() const {
|
||||
return GetAcceleratedWidget();
|
||||
}
|
||||
|
||||
gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds(
|
||||
|
|
|
@ -124,7 +124,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
bool IsVisibleOnAllWorkspaces() override;
|
||||
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget() const override;
|
||||
std::tuple<void*, int> GetNativeWindowHandlePointer() const override;
|
||||
NativeWindowHandle GetNativeWindowHandle() const override;
|
||||
|
||||
gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override;
|
||||
gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override;
|
||||
|
|
2
spec/.hash
Normal file
2
spec/.hash
Normal file
|
@ -0,0 +1,2 @@
|
|||
24d8222313d02ffe2a2181b9c82fbfa5ab8372aec6442839302622fbf45cbe47
|
||||
null
|
|
@ -2790,6 +2790,19 @@ describe('BrowserWindow module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('window.getNativeWindowHandle()', () => {
|
||||
if (!nativeModulesEnabled) {
|
||||
this.skip()
|
||||
}
|
||||
|
||||
it('returns valid handle', () => {
|
||||
// The module's source code is hosted at
|
||||
// https://github.com/electron/node-is-valid-window
|
||||
const isValidWindow = remote.require('is-valid-window')
|
||||
assert.ok(isValidWindow(w.getNativeWindowHandle()))
|
||||
})
|
||||
})
|
||||
|
||||
describe('extensions and dev tools extensions', () => {
|
||||
let showPanelTimeoutId
|
||||
|
||||
|
|
626
spec/package-lock.json
generated
626
spec/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -15,6 +15,7 @@
|
|||
"dbus-native": "^0.2.5",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"graceful-fs": "^4.1.11",
|
||||
"is-valid-window": "^0.0.3",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^5.2.0",
|
||||
"mocha-junit-reporter": "^1.17.0",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue