Code cleanup for native_window_mac
Method definitions should matche sequence of declarations.
This commit is contained in:
parent
a432fb0c34
commit
f5abae31a3
2 changed files with 42 additions and 39 deletions
|
@ -10,8 +10,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "content/public/browser/render_widget_host.h"
|
#include "content/public/browser/render_widget_host.h"
|
||||||
|
|
||||||
@class AtomNSWindow;
|
@class AtomNSWindow;
|
||||||
|
@ -88,12 +88,16 @@ class NativeWindowMac : public NativeWindow,
|
||||||
void SetProgressBar(double progress) override;
|
void SetProgressBar(double progress) override;
|
||||||
void SetOverlayIcon(const gfx::Image& overlay,
|
void SetOverlayIcon(const gfx::Image& overlay,
|
||||||
const std::string& description) override;
|
const std::string& description) override;
|
||||||
|
|
||||||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||||
bool IsVisibleOnAllWorkspaces() override;
|
bool IsVisibleOnAllWorkspaces() override;
|
||||||
|
|
||||||
|
// content::RenderWidgetHost::InputEventObserver:
|
||||||
void OnInputEvent(const blink::WebInputEvent& event) override;
|
void OnInputEvent(const blink::WebInputEvent& event) override;
|
||||||
|
|
||||||
|
// content::WebContentsObserver:
|
||||||
|
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
||||||
|
content::RenderViewHost* new_host) override;
|
||||||
|
|
||||||
// Refresh the DraggableRegion views.
|
// Refresh the DraggableRegion views.
|
||||||
void UpdateDraggableRegionViews() {
|
void UpdateDraggableRegionViews() {
|
||||||
UpdateDraggableRegionViews(draggable_regions_);
|
UpdateDraggableRegionViews(draggable_regions_);
|
||||||
|
@ -132,8 +136,6 @@ class NativeWindowMac : public NativeWindow,
|
||||||
|
|
||||||
void RegisterInputEventObserver(content::RenderViewHost* host);
|
void RegisterInputEventObserver(content::RenderViewHost* host);
|
||||||
void UnregisterInputEventObserver(content::RenderViewHost* host);
|
void UnregisterInputEventObserver(content::RenderViewHost* host);
|
||||||
void RenderViewHostChanged(content::RenderViewHost* old_host,
|
|
||||||
content::RenderViewHost* new_host);
|
|
||||||
|
|
||||||
base::scoped_nsobject<AtomNSWindow> window_;
|
base::scoped_nsobject<AtomNSWindow> window_;
|
||||||
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;
|
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;
|
||||||
|
@ -156,6 +158,7 @@ class NativeWindowMac : public NativeWindow,
|
||||||
// The "titleBarStyle" option.
|
// The "titleBarStyle" option.
|
||||||
TitleBarStyle title_bar_style_;
|
TitleBarStyle title_bar_style_;
|
||||||
|
|
||||||
|
// Whether user has scrolled the page to edge.
|
||||||
bool is_edge_;
|
bool is_edge_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
||||||
|
|
|
@ -429,10 +429,10 @@ struct Converter<atom::NativeWindowMac::TitleBarStyle> {
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
NativeWindowMac::NativeWindowMac(
|
NativeWindowMac::NativeWindowMac(
|
||||||
brightray::InspectableWebContents* iWeb_contents,
|
brightray::InspectableWebContents* web_contents,
|
||||||
const mate::Dictionary& options,
|
const mate::Dictionary& options,
|
||||||
NativeWindow* parent)
|
NativeWindow* parent)
|
||||||
: NativeWindow(iWeb_contents, options, parent),
|
: NativeWindow(web_contents, options, parent),
|
||||||
is_kiosk_(false),
|
is_kiosk_(false),
|
||||||
attention_request_id_(0),
|
attention_request_id_(0),
|
||||||
title_bar_style_(NORMAL),
|
title_bar_style_(NORMAL),
|
||||||
|
@ -575,7 +575,7 @@ NativeWindowMac::NativeWindowMac(
|
||||||
if ([[event window] windowNumber] != [window_ windowNumber])
|
if ([[event window] windowNumber] != [window_ windowNumber])
|
||||||
return event;
|
return event;
|
||||||
|
|
||||||
if (!iWeb_contents)
|
if (!web_contents)
|
||||||
return event;
|
return event;
|
||||||
|
|
||||||
if (!began && is_edge_ && (([event phase] == NSEventPhaseMayBegin) ||
|
if (!began && is_edge_ && (([event phase] == NSEventPhaseMayBegin) ||
|
||||||
|
@ -598,25 +598,8 @@ NativeWindowMac::NativeWindowMac(
|
||||||
// by calls to other APIs.
|
// by calls to other APIs.
|
||||||
SetMaximizable(maximizable);
|
SetMaximizable(maximizable);
|
||||||
|
|
||||||
RegisterInputEventObserver(web_contents()->GetRenderViewHost());
|
RegisterInputEventObserver(
|
||||||
}
|
web_contents->GetWebContents()->GetRenderViewHost());
|
||||||
void NativeWindowMac::RegisterInputEventObserver(
|
|
||||||
content::RenderViewHost* host) {
|
|
||||||
if (host != nullptr)
|
|
||||||
host->GetWidget()->AddInputEventObserver(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindowMac::UnregisterInputEventObserver(
|
|
||||||
content::RenderViewHost* host) {
|
|
||||||
if (host != nullptr)
|
|
||||||
host->GetWidget()->RemoveInputEventObserver(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindowMac::RenderViewHostChanged(
|
|
||||||
content::RenderViewHost* old_host,
|
|
||||||
content::RenderViewHost* new_host) {
|
|
||||||
UnregisterInputEventObserver(old_host);
|
|
||||||
RegisterInputEventObserver(new_host);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeWindowMac::~NativeWindowMac() {
|
NativeWindowMac::~NativeWindowMac() {
|
||||||
|
@ -1047,6 +1030,25 @@ bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
||||||
return collectionBehavior & NSWindowCollectionBehaviorCanJoinAllSpaces;
|
return collectionBehavior & NSWindowCollectionBehaviorCanJoinAllSpaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
|
||||||
|
switch (event.type) {
|
||||||
|
case blink::WebInputEvent::GestureScrollBegin:
|
||||||
|
case blink::WebInputEvent::GestureScrollUpdate:
|
||||||
|
case blink::WebInputEvent::GestureScrollEnd:
|
||||||
|
is_edge_ = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::RenderViewHostChanged(
|
||||||
|
content::RenderViewHost* old_host,
|
||||||
|
content::RenderViewHost* new_host) {
|
||||||
|
UnregisterInputEventObserver(old_host);
|
||||||
|
RegisterInputEventObserver(new_host);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<gfx::Rect> NativeWindowMac::CalculateNonDraggableRegions(
|
std::vector<gfx::Rect> NativeWindowMac::CalculateNonDraggableRegions(
|
||||||
const std::vector<DraggableRegion>& regions, int width, int height) {
|
const std::vector<DraggableRegion>& regions, int width, int height) {
|
||||||
std::vector<gfx::Rect> result;
|
std::vector<gfx::Rect> result;
|
||||||
|
@ -1220,18 +1222,16 @@ void NativeWindowMac::SetCollectionBehavior(bool on, NSUInteger flag) {
|
||||||
SetMaximizable(was_maximizable);
|
SetMaximizable(was_maximizable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
|
void NativeWindowMac::RegisterInputEventObserver(
|
||||||
switch (event.type) {
|
content::RenderViewHost* host) {
|
||||||
case blink::WebInputEvent::GestureScrollBegin:
|
if (host)
|
||||||
case blink::WebInputEvent::GestureScrollUpdate:
|
host->GetWidget()->AddInputEventObserver(this);
|
||||||
case blink::WebInputEvent::GestureScrollEnd:
|
}
|
||||||
{
|
|
||||||
is_edge_ = true;
|
void NativeWindowMac::UnregisterInputEventObserver(
|
||||||
break;
|
content::RenderViewHost* host) {
|
||||||
}
|
if (host)
|
||||||
default:
|
host->GetWidget()->RemoveInputEventObserver(this);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue