英文原文来自:http://www.chromium.org/developers/design-documents/browser-window
该设计文档发表于2009年2月,在内容有些老,仅供参考。
在Chromium中,浏览器窗口(browser window)是由一些的对象共同构成,下面的图表中描绘了其中的一些对象以及他们之间的关系。
![](http://www.chromium.org/_/rsrc/1235884937125/developers/design-documents/browser-window/BrowserWindow2.png)
Frame
The frame is the portion of the browser window that includes the title bar, sizing borders, and other areas traditionally known as the "non-client" areas in Windows terminology. We supply a frame (called BrowserFrame) that subclasses the views::Widget class that adds some additional handling on Vista for DWM adjustments behind the TabStrip, etc.
Frame是浏览器窗口的一部分,包括标题栏,可调边框以及一些其他的区域,这部分区域在传统windows系统中被称为非客户区(non-client)。我们通过子类化views::Widget得到了一个Frame(BrowserFrame),这个Frame用于在Vista上增加一些额外的的处理,诸如DWM(Desktop Window Manager)在TabStrip(译者注:浏览器每个tab页上面显示标题的那部分,或者叫做tab选项卡)后做了一些调整,等等。(此句译者觉得翻译得不太好,请读者给予修改意见)
---------------------------------------------------------------------------------
On Windows Vista, we only use the glass mode when desktop compositing is enabled; in Classic or Vista Basic modes we use the XP Luna mode. Because the user is able to toggle the compositing on and off by changing Windows themes, we need to be able to dynamically change frame mode. For more information about how this is done in views, see the views::Widget documentation. The browser window provides two NonClientFrameView subclasses - GlassBrowserFrameView and OpaqueBrowserFrameView which are swapped in the BrowserFrame's NonClientView when DWM is toggled.
在Windows Vista上,当桌面合成功能开启时,我们只使用glass模式(译者注:就是vista以及win7上的毛玻璃效果);在经典模式或者Vista Basic模式中,我们使用XP的Luna模式(译者注:vista现在应该没有多少人用吧,win7默认的就是这种glass模式开启的)。因为用户可以通过更换windows主题来启用或者关闭桌面合成功能,因此我们需要能够动态的调整Frame的模式。如果需要了解这一功能在views中如何实现,那么请参考views::Widget document。浏览器窗口提供了两个NonClientFrameView的子类——GlassBrowserFrameView和OpaqueBrowserFrameView。当DWM触发后,这两个子类在BrowserFrame的NonClientView中动态切换。
---------------------------------------------------------------------------------
Browser View
The BrowserView object contains all of the elements that are common between the frames that are part of the presentation of the browser window - the tab strip, the toolbar, the bookmarks bar, and other elements of the UI. When the frame changes, this View is inserted into the new NonClientView.
The BrowserView implements an interface called BrowserWindow, which the Browser object uses to interact with the View.
BrowserView对象是浏览器窗口呈现的一部分,它包含了不同frame间所有的常用元素——标签选项卡,工具条,书签条以及其他的UI元素。每当frame发生变化,BrowserView就被插入新的NonClientView中。
BrowserView实现了BrowserWindow这个接口,这个接口被Browser对象用来和BrowserView交互。
--------------------------------------------------------------------------------
Browser
This is the core state and command execution component of a Browser window. It interacts with an abstract Browser Window interface to update the UI. This allows us to write unit tests that supply a windowless "testing view" and then execute high-level functionality within the browser from within the unit testing framework, rather than running UI tests.
Browser是存储浏览器窗口的核心状态和以及执行命令的组件。Browser通过和抽象层面的Browser Window交互来更新UI。有了这么个Browser对象,在单元测试框架下,我们就可以写一个无窗口的“testing view”来进行高层次功能性(译者觉得这应该是逻辑层面功能)的单元测试,而不再需要在UI测试用例下测试该部分功能。