Skip to content

Commit c344eca

Browse files
miniakcodebytere
authored andcommitted
fix: HTML5 fullscreen APIs not working in <webview> (electron#20432)
1 parent 530bf8b commit c344eca

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

atom/browser/api/atom_api_web_contents.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,7 @@ void WebContents::DevToolsOpened() {
983983

984984
// Inherit owner window in devtools when it doesn't have one.
985985
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
986-
bool has_window =
987-
devtools->GetUserData(NativeWindowRelay::kNativeWindowRelayUserDataKey);
986+
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
988987
if (owner_window() && !has_window)
989988
handle->SetOwnerWindow(devtools, owner_window());
990989

atom/browser/common_web_contents_delegate.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ void CommonWebContentsDelegate::SetOwnerWindow(
211211
owner_window->GetWeakPtr());
212212
} else {
213213
owner_window_ = nullptr;
214-
web_contents->RemoveUserData(
215-
NativeWindowRelay::kNativeWindowRelayUserDataKey);
214+
web_contents->RemoveUserData(NativeWindowRelay::UserDataKey());
216215
}
217216
#if BUILDFLAG(ENABLE_OSR)
218217
auto* osr_wcv = GetOffScreenWebContentsView();

atom/browser/native_window.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -575,18 +575,15 @@ const views::Widget* NativeWindow::GetWidget() const {
575575
return widget();
576576
}
577577

578-
// static
579-
const void* const NativeWindowRelay::kNativeWindowRelayUserDataKey =
580-
&NativeWindowRelay::kNativeWindowRelayUserDataKey;
581-
582578
// static
583579
void NativeWindowRelay::CreateForWebContents(
584580
content::WebContents* web_contents,
585581
base::WeakPtr<NativeWindow> window) {
586582
DCHECK(web_contents);
587-
DCHECK(!web_contents->GetUserData(kNativeWindowRelayUserDataKey));
588-
web_contents->SetUserData(kNativeWindowRelayUserDataKey,
589-
base::WrapUnique(new NativeWindowRelay(window)));
583+
if (!web_contents->GetUserData(UserDataKey())) {
584+
web_contents->SetUserData(UserDataKey(),
585+
base::WrapUnique(new NativeWindowRelay(window)));
586+
}
590587
}
591588

592589
NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window)

atom/browser/native_window.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,18 @@ class NativeWindow : public base::SupportsUserData,
354354
class NativeWindowRelay
355355
: public content::WebContentsUserData<NativeWindowRelay> {
356356
public:
357-
static const void* const kNativeWindowRelayUserDataKey;
358-
359357
static void CreateForWebContents(content::WebContents*,
360358
base::WeakPtr<NativeWindow>);
361359

362360
~NativeWindowRelay() override;
363361

364362
NativeWindow* GetNativeWindow() const { return native_window_.get(); }
365363

364+
// UserDataKey() is protected in content::WebContentsUserData<T>
365+
static inline const void* UserDataKey() {
366+
return content::WebContentsUserData<NativeWindowRelay>::UserDataKey();
367+
}
368+
366369
private:
367370
friend class content::WebContentsUserData<NativeWindow>;
368371
explicit NativeWindowRelay(base::WeakPtr<NativeWindow> window);

0 commit comments

Comments
 (0)