Merge branch 'master' into window-transparency
Conflicts: script/lib/config.py
This commit is contained in:
commit
21ba5b867d
47 changed files with 504 additions and 199 deletions
|
@ -1,6 +1,17 @@
|
|||
binding = process.atomBinding 'screen'
|
||||
|
||||
checkAppIsReady = ->
|
||||
unless process.type is 'renderer' or require('app').isReady()
|
||||
throw new Error('Can not use screen module before the "ready" event of app module gets emitted')
|
||||
|
||||
module.exports =
|
||||
if process.platform in ['linux', 'win32'] and process.type is 'renderer'
|
||||
# On Linux we could not access screen in renderer process.
|
||||
require('remote').require 'screen'
|
||||
else
|
||||
process.atomBinding 'screen'
|
||||
getCursorScreenPoint: ->
|
||||
checkAppIsReady()
|
||||
binding.getCursorScreenPoint()
|
||||
getPrimaryDisplay: ->
|
||||
checkAppIsReady()
|
||||
binding.getPrimaryDisplay()
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#define ATOM_MAJOR_VERSION 0
|
||||
#define ATOM_MINOR_VERSION 20
|
||||
#define ATOM_PATCH_VERSION 2
|
||||
#define ATOM_PATCH_VERSION 5
|
||||
|
||||
#define ATOM_VERSION_IS_RELEASE 1
|
||||
|
||||
|
|
|
@ -12,9 +12,12 @@
|
|||
#include "base/strings/string_util.h"
|
||||
#include "ui/gfx/codec/jpeg_codec.h"
|
||||
#include "ui/gfx/codec/png_codec.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
#include "ui/base/layout.h"
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
|
||||
namespace mate {
|
||||
|
||||
namespace {
|
||||
|
@ -29,6 +32,8 @@ ScaleFactorPair kScaleFactorPairs[] = {
|
|||
{ "@2x" , 2.0f },
|
||||
{ "@3x" , 3.0f },
|
||||
{ "@1x" , 1.0f },
|
||||
{ "@4x" , 4.0f },
|
||||
{ "@5x" , 5.0f },
|
||||
{ "@1.25x" , 1.25f },
|
||||
{ "@1.33x" , 1.33f },
|
||||
{ "@1.4x" , 1.4f },
|
||||
|
@ -40,10 +45,6 @@ ScaleFactorPair kScaleFactorPairs[] = {
|
|||
float GetScaleFactorFromPath(const base::FilePath& path) {
|
||||
std::string filename(path.BaseName().RemoveExtension().AsUTF8Unsafe());
|
||||
|
||||
// There is no scale info in the file path.
|
||||
if (!EndsWith(filename, "x", true))
|
||||
return 1.0f;
|
||||
|
||||
// We don't try to convert string to float here because it is very very
|
||||
// expensive.
|
||||
for (unsigned i = 0; i < arraysize(kScaleFactorPairs); ++i) {
|
||||
|
@ -54,27 +55,9 @@ float GetScaleFactorFromPath(const base::FilePath& path) {
|
|||
return 1.0f;
|
||||
}
|
||||
|
||||
void AppendIfExists(std::vector<base::FilePath>* paths,
|
||||
const base::FilePath& path) {
|
||||
if (base::PathExists(path))
|
||||
paths->push_back(path);
|
||||
}
|
||||
|
||||
void PopulatePossibleFilePaths(std::vector<base::FilePath>* paths,
|
||||
const base::FilePath& path) {
|
||||
AppendIfExists(paths, path);
|
||||
|
||||
std::string filename(path.BaseName().RemoveExtension().AsUTF8Unsafe());
|
||||
if (MatchPattern(filename, "*@*x"))
|
||||
return;
|
||||
|
||||
for (unsigned i = 0; i < arraysize(kScaleFactorPairs); ++i)
|
||||
AppendIfExists(paths,
|
||||
path.InsertBeforeExtensionASCII(kScaleFactorPairs[i].name));
|
||||
}
|
||||
|
||||
bool AddImageSkiaRepFromPath(gfx::ImageSkia* image,
|
||||
const base::FilePath& path) {
|
||||
bool AddImageSkiaRep(gfx::ImageSkia* image,
|
||||
const base::FilePath& path,
|
||||
double scale_factor) {
|
||||
std::string file_contents;
|
||||
if (!base::ReadFileToString(path, &file_contents))
|
||||
return false;
|
||||
|
@ -89,13 +72,28 @@ bool AddImageSkiaRepFromPath(gfx::ImageSkia* image,
|
|||
// Try JPEG.
|
||||
decoded.reset(gfx::JPEGCodec::Decode(data, size));
|
||||
|
||||
if (decoded) {
|
||||
image->AddRepresentation(gfx::ImageSkiaRep(
|
||||
*decoded.release(), GetScaleFactorFromPath(path)));
|
||||
return true;
|
||||
}
|
||||
if (!decoded)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
image->AddRepresentation(gfx::ImageSkiaRep(*decoded.release(), scale_factor));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image,
|
||||
const base::FilePath& path) {
|
||||
bool succeed = false;
|
||||
std::string filename(path.BaseName().RemoveExtension().AsUTF8Unsafe());
|
||||
if (MatchPattern(filename, "*@*x"))
|
||||
// Don't search for other representations if the DPI has been specified.
|
||||
return AddImageSkiaRep(image, path, GetScaleFactorFromPath(path));
|
||||
else
|
||||
succeed |= AddImageSkiaRep(image, path, 1.0f);
|
||||
|
||||
for (const ScaleFactorPair& pair : kScaleFactorPairs)
|
||||
succeed |= AddImageSkiaRep(image,
|
||||
path.InsertBeforeExtensionASCII(pair.name),
|
||||
pair.scale);
|
||||
return succeed;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -103,21 +101,27 @@ bool AddImageSkiaRepFromPath(gfx::ImageSkia* image,
|
|||
bool Converter<gfx::ImageSkia>::FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
gfx::ImageSkia* out) {
|
||||
base::FilePath path;
|
||||
if (Converter<base::FilePath>::FromV8(isolate, val, &path)) {
|
||||
std::vector<base::FilePath> paths;
|
||||
PopulatePossibleFilePaths(&paths, path);
|
||||
if (paths.empty())
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < paths.size(); ++i) {
|
||||
if (!AddImageSkiaRepFromPath(out, paths[i]))
|
||||
return false;
|
||||
}
|
||||
if (val->IsNull())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
base::FilePath path;
|
||||
if (!Converter<base::FilePath>::FromV8(isolate, val, &path))
|
||||
return false;
|
||||
|
||||
return PopulateImageSkiaRepsFromPath(out, path);
|
||||
}
|
||||
|
||||
bool Converter<gfx::Image>::FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
gfx::Image* out) {
|
||||
gfx::ImageSkia image;
|
||||
if (!ConvertFromV8(isolate, val, &image))
|
||||
return false;
|
||||
|
||||
*out = gfx::Image(image);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "native_mate/converter.h"
|
||||
|
||||
namespace gfx {
|
||||
class Image;
|
||||
class ImageSkia;
|
||||
}
|
||||
|
||||
|
@ -20,6 +21,13 @@ struct Converter<gfx::ImageSkia> {
|
|||
gfx::ImageSkia* out);
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<gfx::Image> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
gfx::Image* out);
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
#endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_IMAGE_CONVERTER_H_
|
||||
|
|
60
atom/common/native_mate_converters/image_converter_mac.mm
Normal file
60
atom/common/native_mate_converters/image_converter_mac.mm
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "base/mac/foundation_util.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsTemplateImage(const std::string& path) {
|
||||
return (MatchPattern(path, "*Template.*") ||
|
||||
MatchPattern(path, "*Template@*x.*"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace mate {
|
||||
|
||||
bool Converter<gfx::ImageSkia>::FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
gfx::ImageSkia* out) {
|
||||
gfx::Image image;
|
||||
if (!ConvertFromV8(isolate, val, &image))
|
||||
return false;
|
||||
|
||||
*out = image.AsImageSkia();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Converter<gfx::Image>::FromV8(v8::Isolate* isolate,
|
||||
v8::Handle<v8::Value> val,
|
||||
gfx::Image* out) {
|
||||
if (val->IsNull())
|
||||
return true;
|
||||
|
||||
std::string path;
|
||||
if (!ConvertFromV8(isolate, val, &path))
|
||||
return false;
|
||||
|
||||
base::scoped_nsobject<NSImage> image([[NSImage alloc]
|
||||
initByReferencingFile:base::SysUTF8ToNSString(path)]);
|
||||
if (![image isValid])
|
||||
return false;
|
||||
|
||||
if (IsTemplateImage(path))
|
||||
[image setTemplate:YES];
|
||||
|
||||
*out = gfx::Image(image.release());
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace mate
|
|
@ -16,7 +16,7 @@ namespace atom {
|
|||
|
||||
namespace {
|
||||
|
||||
const int kMaxRecursionDepth = 100;
|
||||
const int kMaxRecursionDepth = 20;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -294,10 +294,7 @@ base::Value* V8ValueConverter::FromV8Array(
|
|||
if (!val->HasRealIndexedProperty(i))
|
||||
continue;
|
||||
|
||||
// When parsing elements in an array, we use a new state so we can have the
|
||||
// same object showed twice in array.
|
||||
FromV8ValueState new_state;
|
||||
base::Value* child = FromV8ValueImpl(&new_state, child_v8, isolate);
|
||||
base::Value* child = FromV8ValueImpl(state, child_v8, isolate);
|
||||
if (child)
|
||||
result->Append(child);
|
||||
else
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
// Include common headers for using node APIs.
|
||||
|
||||
#undef ASSERT
|
||||
#undef CHECK
|
||||
#undef CHECK_EQ
|
||||
#undef CHECK_NE
|
||||
|
@ -15,6 +16,7 @@
|
|||
#undef CHECK_LE
|
||||
#undef CHECK_LT
|
||||
#undef DISALLOW_COPY_AND_ASSIGN
|
||||
#undef NO_RETURN
|
||||
#undef debug_string // This is defined in OS X 10.9 SDK in AssertMacros.h.
|
||||
#include "vendor/node/src/env.h"
|
||||
#include "vendor/node/src/env-inl.h"
|
||||
|
|
|
@ -80,6 +80,9 @@ const char kOverlayScrollbars[] = "overlay-scrollbars";
|
|||
const char kOverlayFullscreenVideo[] = "overlay-fullscreen-video";
|
||||
const char kSharedWorker[] = "shared-worker";
|
||||
|
||||
// Disable HTTP cache.
|
||||
const char kDisableHttpCache[] = "disable-http-cache";
|
||||
|
||||
} // namespace switches
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -48,6 +48,8 @@ extern const char kOverlayScrollbars[];
|
|||
extern const char kOverlayFullscreenVideo[];
|
||||
extern const char kSharedWorker[];
|
||||
|
||||
extern const char kDisableHttpCache[];
|
||||
|
||||
} // namespace switches
|
||||
|
||||
} // namespace atom
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue