Add Invalidate method to NativeWindow and add Mac implementation

This commit is contained in:
Gary Wilber 2017-02-13 19:41:24 -08:00
parent 11e1f6b56c
commit f19924bcb0
6 changed files with 16 additions and 6 deletions

View file

@ -1496,12 +1496,8 @@ void WebContents::Invalidate() {
osr_rwhv->Invalidate(); osr_rwhv->Invalidate();
} else { } else {
const auto ownerWindow = owner_window(); const auto ownerWindow = owner_window();
const auto nativeWindow = ownerWindow ? ownerWindow->GetNativeWindow() : if (ownerWindow) {
nullptr; ownerWindow->Invalidate();
if (nativeWindow) {
const gfx::Rect& bounds = nativeWindow->bounds();
nativeWindow->SchedulePaintInRect(
gfx::Rect(0, 0, bounds.width(), bounds.height()));
} }
} }
} }

View file

@ -124,6 +124,7 @@ class NativeWindow : public base::SupportsUserData,
std::string* error = nullptr) = 0; std::string* error = nullptr) = 0;
virtual bool IsAlwaysOnTop() = 0; virtual bool IsAlwaysOnTop() = 0;
virtual void Center() = 0; virtual void Center() = 0;
virtual void Invalidate() = 0;
virtual void SetTitle(const std::string& title) = 0; virtual void SetTitle(const std::string& title) = 0;
virtual std::string GetTitle() = 0; virtual std::string GetTitle() = 0;
virtual void FlashFrame(bool flash) = 0; virtual void FlashFrame(bool flash) = 0;

View file

@ -71,6 +71,7 @@ class NativeWindowMac : public NativeWindow,
int relativeLevel, std::string* error) override; int relativeLevel, std::string* error) override;
bool IsAlwaysOnTop() override; bool IsAlwaysOnTop() override;
void Center() override; void Center() override;
void Invalidate() override;
void SetTitle(const std::string& title) override; void SetTitle(const std::string& title) override;
std::string GetTitle() override; std::string GetTitle() override;
void FlashFrame(bool flash) override; void FlashFrame(bool flash) override;

View file

@ -1101,6 +1101,11 @@ void NativeWindowMac::Center() {
[window_ center]; [window_ center];
} }
void NativeWindowMac::Invalidate() {
[window_ flushWindow];
[[window_ contentView] setNeedsDisplay:TRUE];
}
void NativeWindowMac::SetTitle(const std::string& title) { void NativeWindowMac::SetTitle(const std::string& title) {
// For macOS <= 10.9, the setTitleVisibility API is not available, we have // For macOS <= 10.9, the setTitleVisibility API is not available, we have
// to avoid calling setTitle for frameless window. // to avoid calling setTitle for frameless window.

View file

@ -695,6 +695,12 @@ void NativeWindowViews::Center() {
window_->CenterWindow(GetSize()); window_->CenterWindow(GetSize());
} }
void NativeWindowViews::Invalidate() {
const gfx::Rect& bounds = GetBounds();
window_->SchedulePaintInRect(
gfx::Rect(0, 0, bounds.width(), bounds.height()));
}
void NativeWindowViews::SetTitle(const std::string& title) { void NativeWindowViews::SetTitle(const std::string& title) {
title_ = title; title_ = title;
window_->UpdateWindowTitle(); window_->UpdateWindowTitle();

View file

@ -90,6 +90,7 @@ class NativeWindowViews : public NativeWindow,
int relativeLevel, std::string* error) override; int relativeLevel, std::string* error) override;
bool IsAlwaysOnTop() override; bool IsAlwaysOnTop() override;
void Center() override; void Center() override;
void Invalidate() override;
void SetTitle(const std::string& title) override; void SetTitle(const std::string& title) override;
std::string GetTitle() override; std::string GetTitle() override;
void FlashFrame(bool flash) override; void FlashFrame(bool flash) override;