Use BrowserWindow's backgroundColor as renderer view's background color
This commit is contained in:
parent
70ca49e36a
commit
cb470cb94b
12 changed files with 88 additions and 36 deletions
34
atom/common/color_util.cc
Normal file
34
atom/common/color_util.cc
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/common/color_util.h"
|
||||
|
||||
#include "base/strings/string_util.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
SkColor ParseHexColor(const std::string& name) {
|
||||
auto color = name.substr(1);
|
||||
unsigned length = color.size();
|
||||
SkColor result = (length != 8 ? 0xFF000000 : 0x00000000);
|
||||
unsigned value = 0;
|
||||
if (length != 3 && length != 6 && length != 8)
|
||||
return result;
|
||||
for (unsigned i = 0; i < length; ++i) {
|
||||
if (!base::IsHexDigit(color[i]))
|
||||
return result;
|
||||
value <<= 4;
|
||||
value |= (color[i] < 'A' ? color[i] - '0' : (color[i] - 'A' + 10) & 0xF);
|
||||
}
|
||||
if (length == 6 || length == 8) {
|
||||
result |= value;
|
||||
return result;
|
||||
}
|
||||
result |= (value & 0xF00) << 12 | (value & 0xF00) << 8
|
||||
| (value & 0xF0) << 8 | (value & 0xF0) << 4
|
||||
| (value & 0xF) << 4 | (value & 0xF);
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace atom
|
19
atom/common/color_util.h
Normal file
19
atom/common/color_util.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) 2016 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_COMMON_COLOR_UTIL_H_
|
||||
#define ATOM_COMMON_COLOR_UTIL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
// Parse hex color like "#FFF" or "#EFEFEF"
|
||||
SkColor ParseHexColor(const std::string& name);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_COMMON_COLOR_UTIL_H_
|
|
@ -142,12 +142,13 @@ const char kCipherSuiteBlacklist[] = "cipher-suite-blacklist";
|
|||
const char kAppUserModelId[] = "app-user-model-id";
|
||||
|
||||
// The command line switch versions of the options.
|
||||
const char kZoomFactor[] = "zoom-factor";
|
||||
const char kPreloadScript[] = "preload";
|
||||
const char kPreloadURL[] = "preload-url";
|
||||
const char kNodeIntegration[] = "node-integration";
|
||||
const char kGuestInstanceID[] = "guest-instance-id";
|
||||
const char kOpenerID[] = "opener-id";
|
||||
const char kBackgroundColor[] = "background-color";
|
||||
const char kZoomFactor[] = "zoom-factor";
|
||||
const char kPreloadScript[] = "preload";
|
||||
const char kPreloadURL[] = "preload-url";
|
||||
const char kNodeIntegration[] = "node-integration";
|
||||
const char kGuestInstanceID[] = "guest-instance-id";
|
||||
const char kOpenerID[] = "opener-id";
|
||||
|
||||
// Widevine options
|
||||
// Path to Widevine CDM binaries.
|
||||
|
|
|
@ -76,6 +76,7 @@ extern const char kSSLVersionFallbackMin[];
|
|||
extern const char kCipherSuiteBlacklist[];
|
||||
extern const char kAppUserModelId[];
|
||||
|
||||
extern const char kBackgroundColor[];
|
||||
extern const char kZoomFactor[];
|
||||
extern const char kPreloadScript[];
|
||||
extern const char kPreloadURL[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue