Chrome 39的新功能

罗光华
2023-12-01

Despite being six years old, Chrome is rapidly approaching middle age in version numbers. Chrome 39 has been released and you probably have it installed. There are several good new features … plus one or two slightly suspect additions.

尽管已有6年历史,但Chrome浏览器的版本号正Swift接近中年。 Chrome 39已发布,您可能已经安装了它。 有几个不错的新功能…加上一两个可疑的附加功能。

ECMAScript 6生成器 (ECMAScript 6 Generators)

Generators are special functions declared with function* which create iterators. An iterator is an object with a next() method which is called to return a value. The generator function uses a yield statement to provide the next value in the sequence.

生成器是用function*声明的特殊函数,它们创建迭代器。 迭代器是具有next()方法的对象,该方法被调用以返回值。 生成器函数使用yield语句提供序列中的下一个值。

Arunoda Susiripala provides a basic example in JavaScript Generators and Preventing Callback Hell:

Arunoda Susiripala在JavaScript生成器和防止回调地狱中提供了一个基本示例:

function* HelloGen() {
    yield 100;
    yield 400;
}

var gen = HelloGen();

console.log(gen.next()); // {value: 100, done: false}
console.log(gen.next()); // {value: 400, done: false}
console.log(gen.next()); // {value: undefined, done: true}

ECMAScript 6 Generators are supported in Chrome, Opera and Firefox 31+.

Chrome,Opera和Firefox 31+支持ECMAScript 6 Generators。

信标API (The Beacon API)

The new Beacon API lets you send data to a server without having to wait for a response. Requests are queued and sent by the browser as soon as possible but — importantly — it doesn’t delay unloading of the current page or loading of the next.

新的Beacon API使您无需等待响应即可将数据发送到服务器。 请求由浏览器尽快排入队列并发送,但重要的是,它不会延迟当前页面的卸载或下一页的加载。

navigator.sendBeacon() is passed a URL and data — perhaps a string or FormData value. Typically, it could be used when transmitting statistical information, e.g.

navigator.sendBeacon()传递了URL和数据-可能是字符串或FormData值。 通常,它可以在传输统计信息时使用,例如

navigator.sendBeacon('/log', 'page-unloaded');

The method returns true if the browser successfully queues the beacon request. I’m not sure what you could do if false was returned but beacons should not be used for essential functionality or messaging.

如果浏览器成功将信标请求放入队列,则该方法返回true 。 我不确定如果返回false怎么办,但是信标不应用于基本功能或消息传递。

The Beacon API is supported in Chrome, Opera and Firefox 31+.

Chrome,Opera和Firefox 31+支持Beacon API。

网络动画控件 (Web Animation Controls)

Web Animations were introduced in Chrome 36. The idea is to permit simple CSS3-like keyframe and animation declarations from JavaScript, e.g.

Web动画是在Chrome 36中引入的。其想法是允许从JavaScript进行类似CSS3的简单关键帧和动画声明,例如

var myanimation = myelement.animate([
    { color: "#f00" },
    { left: "20em" },
    { transform: "rotate(180deg)" }
], {
    duration: 1000,
    iterations: 1,
    delay: 0
});

The advantage is you can then control and synchronize playback according to user input or other conditions. Chrome 39 adds playback methods such as play(), pause(), reverse(), finish() (puts the animation into its final state) and cancel() (clears all effects).

这样的好处是您可以根据用户输入或其他条件控制和同步播放。 Chrome 39添加了播放方法,例如play()pause()reverse()finish() (将动画置于最终状态)和cancel() (清除所有效果)。

Think of Web Animation as a compromise between simple CSS3 animations and complex JavaScript full-frame control using requestAnimationFrame and your own timing functions. It’s possibly overkill for general web page effects but not powerful enough for games. Apps and presentations may be good use cases?

可以将Web Animation视为简单CSS3动画和使用requestAnimationFrame和您自己的计时功能的复杂JavaScript全帧控件之间的折衷。 对于一般的网页效果来说,这可能是过分的了,但对于游戏来说却不够强大。 应用程序和演示文稿可能是很好的用例?

Chrome and Opera are currently the only browsers to support Web Animation. There’s support in Firefox nightlies and a polyfill is available but the technology won’t be stable for some time yet.

Chrome和Opera是目前唯一支持Web动画的浏览器。 Firefox每晚都有支持,并且可以使用 polyfill,但该技术在一段时间内仍不稳定。

Web应用程序清单 (Web Application Manifest)

Not to be confused with the Application Cache Manifest, the Web Application Manifest is a JSON file where you can place meta data such as the name, start address, icons, display mode, orientation etc.

不要与Application Cache Manifest混淆, Web Application Manifest是一个JSON文件,您可以在其中放置元数据,例如名称,起始地址,图标,显示模式,方向等。

You’ll require a link in your HTML head:

您需要在HTML head一个link

<link rel="manifest" href="manifest.json">

and the manifest file itself, e.g.

和清单文件本身,例如

{
    "name": "My Application",
    "icons": [{
        "src": "icon/lowres",
        "sizes": "64x64"
      }, {
        "src": "icon/small",
        "sizes": "64x64"
      }, {
        "src": "icon/hd_hi",
        "sizes": "128x128",
        "density": 2
      }],
    "start_url": "/index.html",
    "display": "fullscreen",
    "orientation": "landscape"
}

This eventually means we can remove the 57 iOS icon size alternatives from the top of every page … presuming Apple decide to implement the technology in Safari!

最终,这意味着我们可以从每个页面的顶部删除57种iOS图标大小的替代方案…… 假设Apple决定在Safari中实现该技术!

Cross-browser support is patchy. Firefox uses the manifest for its Marketplace, but there appear to be some differences in property names.

跨浏览器支持不完整。 Firefox将清单用于其Marketplace,但属性名称似乎有所不同。

Windows 7沉浸式模式 (Windows 7 Immersive Mode)

Switching to Immersive Mode on Windows 7 makes Chrome act a little like a Windows 8 full-screen Metro application. Bizarrely, it then places a Chrome OS-like semi-transparent taskbar above the Windows taskbar — with it’s own start button and clock.

在Windows 7上切换到沉浸式模式会使Chrome的行为有点像Windows 8全屏Metro应用程序。 奇怪的是,然后将类似Chrome OS的半透明任务栏放置在Windows任务栏上方-带有自己的开始按钮和时钟。

Why? If Windows 7 users want a Windows 8 experience they can upgrade. However, there’s a reason many Windows 7 choose to stick with that OS: they don’t want Windows 8!

为什么? 如果Windows 7用户想要Windows 8体验,则可以升级。 但是,许多Windows 7选择坚持使用该操作系统是有原因的:他们不希望Windows 8!

I’m also confused by Google’s insistence on sneaking Chrome OS widgets into other operating systems. A Chrome App icon here and there is fine — but replicating native features is pointless. Perhaps they’re hoping to entice people to Chrome OS but annoying them won’t help.

我也对Google坚持将Chrome OS小部件潜入其他操作系统感到困惑。 可以使用Chrome应用程序图标-可以,但是复制本机功能毫无意义。 也许他们希望吸引人们使用Chrome操作系统,但使他们烦恼无济于事。

杂项更新 (Miscellaneous Updates)

A few more minor features…

其他一些次要功能…

  • You can now install free Chrome Apps from the Play Store without being signed in.

    现在,您无需登录即可从Play商店安装免费的Chrome应用。
  • scrollTop and scrollLeft now return fractions of a pixel on high-DPI/Retina screens. If you thought pixel-perfection was bad, wait until clients start demanding sub-pixel perfection!

    现在, scrollTopscrollLeft返回高DPI / Retina屏幕上的像素分数。 如果您认为像素完美不好,请等到客户开始要求亚像素完美!

  • Saved passwords can now be edited.

    现在可以编辑已保存的密码。
  • The 64-bit edition of Chrome is now the only version available on Mac OS.

    现在,64位版本的Chrome是Mac OS上唯一可用的版本。
  • SHA-1 encryption is being phased out in favor of SHA-2.

    SHA-1加密正在逐步被SHA-2取代。
  • Experimental support for extension buttons icons inside the menu has been added (set Enable extension toolbar redesign in about:flags).

    对菜单内扩展按钮图标的实验性支持已添加(在about:flags中设置启用扩展工具栏重新设计 )。

Despite a few dodgy additions and some Firefox catch-ups, version 39 is another great update. Chrome remains fast, stable and the browser of choice for almost half the web. Recommended.

尽管增加了一些狡猾的功能和Firefox的一些新功能,但版本39是另一个不错的更新。 Chrome保持快速,稳定,并且几乎是整个网络的首选浏览器。 推荐的。

翻译自: https://www.sitepoint.com/whats-new-chrome-39/

 类似资料: