Merge pull request #8628 from Spacetech/master
Implement invalidate for non-offscreen mode
This commit is contained in:
commit
9be42db8d5
7 changed files with 23 additions and 6 deletions
|
@ -1500,13 +1500,16 @@ int WebContents::GetFrameRate() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::Invalidate() {
|
void WebContents::Invalidate() {
|
||||||
if (!IsOffScreen())
|
if (IsOffScreen()) {
|
||||||
return;
|
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
||||||
|
|
||||||
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
|
|
||||||
web_contents()->GetRenderWidgetHostView());
|
web_contents()->GetRenderWidgetHostView());
|
||||||
if (osr_rwhv)
|
if (osr_rwhv)
|
||||||
osr_rwhv->Invalidate();
|
osr_rwhv->Invalidate();
|
||||||
|
} else {
|
||||||
|
const auto owner_window = owner_window();
|
||||||
|
if (owner_window)
|
||||||
|
owner_window->Invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::SetZoomLevel(double level) {
|
void WebContents::SetZoomLevel(double level) {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -1101,6 +1101,11 @@ void NativeWindowMac::Center() {
|
||||||
[window_ center];
|
[window_ center];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::Invalidate() {
|
||||||
|
[window_ flushWindow];
|
||||||
|
[[window_ contentView] setNeedsDisplay:YES];
|
||||||
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
|
|
@ -695,6 +695,10 @@ void NativeWindowViews::Center() {
|
||||||
window_->CenterWindow(GetSize());
|
window_->CenterWindow(GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowViews::Invalidate() {
|
||||||
|
window_->SchedulePaintInRect(gfx::Rect(GetBounds().size()));
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetTitle(const std::string& title) {
|
void NativeWindowViews::SetTitle(const std::string& title) {
|
||||||
title_ = title;
|
title_ = title;
|
||||||
window_->UpdateWindowTitle();
|
window_->UpdateWindowTitle();
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -1239,6 +1239,8 @@ Returns `Integer` - If *offscreen rendering* is enabled returns the current fram
|
||||||
|
|
||||||
#### `contents.invalidate()`
|
#### `contents.invalidate()`
|
||||||
|
|
||||||
|
Schedules a full repaint of the window this web contents is in.
|
||||||
|
|
||||||
If *offscreen rendering* is enabled invalidates the frame and generates a new
|
If *offscreen rendering* is enabled invalidates the frame and generates a new
|
||||||
one through the `'paint'` event.
|
one through the `'paint'` event.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue