mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: color select eyedropper not working within DevTools (#29752)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -3463,6 +3463,30 @@ void WebContents::DevToolsSearchInPath(int request_id,
|
||||
file_system_path));
|
||||
}
|
||||
|
||||
void WebContents::DevToolsSetEyeDropperActive(bool active) {
|
||||
auto* web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
if (active) {
|
||||
eye_dropper_ = std::make_unique<DevToolsEyeDropper>(
|
||||
web_contents, base::BindRepeating(&WebContents::ColorPickedInEyeDropper,
|
||||
base::Unretained(this)));
|
||||
} else {
|
||||
eye_dropper_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::ColorPickedInEyeDropper(int r, int g, int b, int a) {
|
||||
base::DictionaryValue color;
|
||||
color.SetInteger("r", r);
|
||||
color.SetInteger("g", g);
|
||||
color.SetInteger("b", b);
|
||||
color.SetInteger("a", a);
|
||||
inspectable_web_contents_->CallClientFunction(
|
||||
"DevToolsAPI.eyeDropperPickedColor", &color, nullptr, nullptr);
|
||||
}
|
||||
|
||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MAC)
|
||||
ui::ImageModel WebContents::GetDevToolsWindowIcon() {
|
||||
return owner_window() ? owner_window()->GetWindowAppIcon() : ui::ImageModel{};
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/observer_list_types.h"
|
||||
#include "chrome/browser/devtools/devtools_eye_dropper.h"
|
||||
#include "chrome/browser/devtools/devtools_file_system_indexer.h"
|
||||
#include "content/common/cursors/webcursor.h"
|
||||
#include "content/common/frame.mojom.h"
|
||||
@@ -657,6 +658,7 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||
void DevToolsSearchInPath(int request_id,
|
||||
const std::string& file_system_path,
|
||||
const std::string& query) override;
|
||||
void DevToolsSetEyeDropperActive(bool active) override;
|
||||
|
||||
// InspectableWebContentsViewDelegate:
|
||||
#if defined(TOOLKIT_VIEWS) && !defined(OS_MAC)
|
||||
@@ -667,6 +669,8 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||
std::string* class_name) override;
|
||||
#endif
|
||||
|
||||
void ColorPickedInEyeDropper(int r, int g, int b, int a);
|
||||
|
||||
// DevTools index event callbacks.
|
||||
void OnDevToolsIndexingWorkCalculated(int request_id,
|
||||
const std::string& file_system_path,
|
||||
@@ -739,6 +743,8 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||
|
||||
scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_;
|
||||
|
||||
std::unique_ptr<DevToolsEyeDropper> eye_dropper_;
|
||||
|
||||
ElectronBrowserContext* browser_context_;
|
||||
|
||||
// The stored InspectableWebContents object.
|
||||
|
||||
Reference in New Issue
Block a user