diff options
author | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 01:36:30 +0000 |
---|---|---|
committer | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-14 01:36:30 +0000 |
commit | af7e9d3a7278d4f0754bf63e077d2e7842b2b7c5 (patch) | |
tree | 2499457ad672561387ab63dc33d5b91f8613912d | |
parent | abae4464eee1c5794d87dc470a656532d2ccf1c2 (diff) | |
download | chromium_src-af7e9d3a7278d4f0754bf63e077d2e7842b2b7c5.zip chromium_src-af7e9d3a7278d4f0754bf63e077d2e7842b2b7c5.tar.gz chromium_src-af7e9d3a7278d4f0754bf63e077d2e7842b2b7c5.tar.bz2 |
Fixed initial rendering of toolbar.
IE will create empty properly rendered toolbar instead of white box. Then chrome frame will be placed above.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6245001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71404 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ceee/ie/plugin/toolband/tool_band.cc | 40 | ||||
-rw-r--r-- | ceee/ie/plugin/toolband/tool_band.h | 25 |
2 files changed, 31 insertions, 34 deletions
diff --git a/ceee/ie/plugin/toolband/tool_band.cc b/ceee/ie/plugin/toolband/tool_band.cc index cb12732..2b4d73f 100644 --- a/ceee/ie/plugin/toolband/tool_band.cc +++ b/ceee/ie/plugin/toolband/tool_band.cc @@ -330,7 +330,6 @@ HRESULT ToolBand::Teardown() { if (chrome_frame_) { ChromeFrameEvents::DispEventUnadvise(chrome_frame_); } - chrome_frame_window_ = NULL; if (web_browser_ && listening_to_browser_events_) { HostingBrowserEvents::DispEventUnadvise(web_browser_, @@ -349,6 +348,11 @@ LRESULT ToolBand::OnCreate(LPCREATESTRUCT lpCreateStruct) { // Grab a self-reference. GetUnknown()->AddRef(); + if (NULL == chrome_frame_container_window_.Create(m_hWnd)) { + LOG(ERROR) << "Failed to create window. " << com::LogWe(); + return -1; + } + // Create a host window instance. base::win::ScopedComPtr<IAxWinHostWindow> host; HRESULT hr = CAxHostWindow::CreateInstance(host.Receive()); @@ -372,23 +376,14 @@ LRESULT ToolBand::OnCreate(LPCREATESTRUCT lpCreateStruct) { } // And attach it to our window. - hr = host->AttachControl(chrome_frame_, m_hWnd); + hr = host->AttachControl(chrome_frame_, + chrome_frame_container_window_.m_hWnd); if (FAILED(hr)) { LOG(ERROR) << "Failed to attach Chrome Frame to the host. " << com::LogHr(hr); return 1; } - // Get the GCF window and hide it for now. - CComQIPtr<IOleWindow> ole_window(chrome_frame_); - DCHECK(ole_window != NULL); - if (SUCCEEDED(ole_window->GetWindow(&chrome_frame_window_.m_hWnd))) { - // We hide the chrome frame window until onload in order to avoid - // seeing the "Aw Snap" that sometimes otherwise occurs during Chrome - // initialization. - chrome_frame_window_.ShowWindow(SW_HIDE); - } - // Hook up the chrome frame event listener. hr = ChromeFrameEvents::DispEventAdvise(chrome_frame_); if (FAILED(hr)) { @@ -398,23 +393,6 @@ LRESULT ToolBand::OnCreate(LPCREATESTRUCT lpCreateStruct) { return 0; } -void ToolBand::OnPaint(CDCHandle dc) { - RECT rc = {}; - if (GetUpdateRect(&rc, FALSE)) { - PAINTSTRUCT ps = {}; - BeginPaint(&ps); - - BOOL ret = GetClientRect(&rc); - DCHECK(ret); - CString text; - text.Format(L"Google CEEE. No Chrome Frame found. Instance: 0x%p. ID: %d!)", - this, band_id_); - ::DrawText(ps.hdc, text, -1, &rc, DT_SINGLELINE | DT_BOTTOM | DT_CENTER); - - EndPaint(&ps); - } -} - void ToolBand::OnSize(UINT type, CSize size) { LOG(INFO) << "ToolBand::OnSize(" << type << ", " << size.cx << "x" << size.cy << ")"; @@ -584,9 +562,9 @@ STDMETHODIMP_(void) ToolBand::OnCfGetEnabledExtensionsComplete( } STDMETHODIMP_(void) ToolBand::OnCfOnload(IDispatch* event) { - if (chrome_frame_window_.IsWindow()) { + if (chrome_frame_container_window_.IsWindow()) { VLOG(1) << "Showing the Chrome Frame window."; - chrome_frame_window_.ShowWindow(SW_SHOW); + chrome_frame_container_window_.ShowWindow(SW_SHOW); } } diff --git a/ceee/ie/plugin/toolband/tool_band.h b/ceee/ie/plugin/toolband/tool_band.h index 543a2ea..38ccab4 100644 --- a/ceee/ie/plugin/toolband/tool_band.h +++ b/ceee/ie/plugin/toolband/tool_band.h @@ -50,11 +50,22 @@ class ATL_NO_VTABLE ToolBand : public CComObjectRootEx<CComSingleThreadModel>, public IPersistStream, public ChromeFrameEvents, public HostingBrowserEvents, - public CWindowImpl<ToolBand> { + // WS_CHILD | WS_VISIBLE | TBSTYLE_TRANSPARENT | CCS_NODIVIDER are critical + // for painting toolband background while chrome frame is hidden. + // TBSTYLE_TRANSPARENT makes toolbar same color as rest of IE controls. + // CCS_NODIVIDER removes line above toolbar. + // Rest was copied from IE favorite bar. + public CWindowImpl<ToolBand, CWindow, CWinTraits< + WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | + TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT | TBSTYLE_LIST | TBSTYLE_FLAT | + CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_TOP, 0>> { public: ToolBand(); ~ToolBand(); + // Subclass TOOLBARCLASSNAME to use TBSTYLE_TRANSPARENT. + DECLARE_WND_SUPERCLASS(NULL, TOOLBARCLASSNAME) + DECLARE_REGISTRY_RESOURCEID_EX(IDR_TOOL_BAND) BEGIN_REGISTRY_MAP(ToolBand) REGMAP_UUID("CLSID", CLSID_ToolBand) @@ -179,7 +190,6 @@ class ATL_NO_VTABLE ToolBand : public CComObjectRootEx<CComSingleThreadModel>, // @name Message handlers. // @{ - void OnPaint(CDCHandle dc); void OnSize(UINT type, CSize size); // @} @@ -198,6 +208,13 @@ class ATL_NO_VTABLE ToolBand : public CComObjectRootEx<CComSingleThreadModel>, virtual HRESULT SendSessionIdToBho(IUnknown* bho); private: + class EmptyWindow : + public CWindowImpl<EmptyWindow, CWindow, CWinTraits<WS_CHILD, 0>> { + public: + BEGIN_MSG_MAP(EmptyWindow) + END_MSG_MAP() + }; + // Initializes the toolband to the given site. // Called from SetSite. HRESULT Initialize(IUnknown *site); @@ -240,7 +257,9 @@ class ATL_NO_VTABLE ToolBand : public CComObjectRootEx<CComSingleThreadModel>, // Our Chrome frame instance and its window. CComPtr<IChromeFrame> chrome_frame_; - CWindow chrome_frame_window_; + + // Hides chrome frame during initialization. + EmptyWindow chrome_frame_container_window_; // Indicates whether CloseDW() is being called on this tool band. bool is_quitting_; |