Kaydet (Commit) 4a0f506f authored tarafından Miklos Vajna's avatar Miklos Vajna

framework: disable layout manager in hidden frames

The point of hidden frames is that they are not visible on the UI, only their
doc model / layout is accessible via the API or file format conversion. That
means that laying out the UI elements like menus and toolbars is pointless.

So change Frame::initialize() and Frame::setLayoutManager() to not enable the
layout manager for hidden frames. To do this, we need a new window style flag,
as both hidden and visible frames have an underlying hidden window at the time
the framework layout manager would be enabled.

Times for 200 hello world inputs: 5780 -> 5054 ms is spent in XHTML-load + ODT
export + close (87% of original).

Change-Id: I841507bbb62f8fc2979d20e2d579d0bb47b98f37
Reviewed-on: https://gerrit.libreoffice.org/48068Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst c4075744
......@@ -27,6 +27,7 @@
#include <com/sun/star/uno/Reference.hxx>
#include <rtl/ustring.hxx>
#include <unotools/mediadescriptor.hxx>
namespace framework{
......@@ -53,7 +54,7 @@ class TaskCreator final
TaskCreator( const css::uno::Reference< css::uno::XComponentContext >& xContext );
~TaskCreator( );
css::uno::Reference< css::frame::XFrame > createTask( const OUString& sName );
css::uno::Reference< css::frame::XFrame > createTask( const OUString& sName, const utl::MediaDescriptor& rDesciprtor );
}; // class TaskCreator
......
......@@ -57,7 +57,7 @@ TaskCreator::~TaskCreator()
/*-****************************************************************************************************
TODO document me
*//*-*****************************************************************************************************/
css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName )
css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName, const utl::MediaDescriptor& rDescriptor )
{
css::uno::Reference< css::lang::XSingleServiceFactory > xCreator;
OUString sCreator = IMPLEMENTATIONNAME_FWK_TASKCREATOR;
......@@ -86,7 +86,7 @@ css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUStrin
if ( ! xCreator.is())
xCreator = css::frame::TaskCreator::create(m_xContext);
css::uno::Sequence< css::uno::Any > lArgs(5);
css::uno::Sequence< css::uno::Any > lArgs(6);
css::beans::NamedValue aArg;
aArg.Name = ARGUMENT_PARENTFRAME;
......@@ -109,6 +109,12 @@ css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUStrin
aArg.Value <<= sName;
lArgs[4] <<= aArg;
bool bHidden
= rDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(), false);
aArg.Name = "Hidden";
aArg.Value <<= bHidden;
lArgs[5] <<= aArg;
css::uno::Reference< css::frame::XFrame > xTask(xCreator->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
return xTask;
}
......
......@@ -87,6 +87,7 @@
#include <vcl/svapp.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/profilezone.hxx>
#include <classes/taskcreator.hxx>
const char PROP_TYPES[] = "Types";
const char PROP_NAME[] = "Name";
......@@ -989,7 +990,8 @@ bool LoadEnv::impl_loadContent()
{
if (! impl_furtherDocsAllowed())
return false;
m_xTargetFrame = m_xBaseFrame->findFrame(SPECIALTARGET_BLANK, 0);
TaskCreator aCreator(m_xContext);
m_xTargetFrame = aCreator.createTask(SPECIALTARGET_BLANK, m_lMediaDescriptor);
m_bCloseFrameOnError = m_xTargetFrame.is();
}
else
......
......@@ -967,7 +967,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
if ( sTargetFrameName==SPECIALTARGET_BLANK )
{
TaskCreator aCreator( m_xContext );
xTarget = aCreator.createTask(sTargetFrameName);
xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor());
}
// I.II) "_top"
......@@ -1051,7 +1051,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS
)
{
TaskCreator aCreator( m_xContext );
xTarget = aCreator.createTask(sTargetFrameName);
xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor());
}
}
......
......@@ -412,6 +412,8 @@ private:
bool m_bSelfClose;
/// indicates, if this frame is used in hidden mode or not
bool m_bIsHidden;
/// The container window has WindowExtendedStyle::DocHidden set.
bool m_bDocHidden = false;
/// is used to layout the child windows of the frame.
css::uno::Reference< css::frame::XLayoutManager2 > m_xLayoutManager;
css::uno::Reference< css::frame::XDispatchInformationProvider > m_xDispatchInfoHelper;
......@@ -772,8 +774,13 @@ void SAL_CALL Frame::initialize( const css::uno::Reference< css::awt::XWindow >&
// if window is initially visible, we will never get a windowShowing event
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xWindow);
if (pWindow && pWindow->IsVisible())
m_bIsHidden = false;
if (pWindow)
{
if (pWindow->IsVisible())
m_bIsHidden = false;
m_bDocHidden
= static_cast<bool>(pWindow->GetExtendedStyle() & WindowExtendedStyle::DocHidden);
}
css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager = m_xLayoutManager;
......@@ -782,7 +789,9 @@ void SAL_CALL Frame::initialize( const css::uno::Reference< css::awt::XWindow >&
aWriteLock.clear();
/* UNSAFE AREA --------------------------------------------------------------------------------------------- */
if (xLayoutManager.is())
// Avoid enabling the layout manager for hidden frames: it's expensive and
// provides little value.
if (xLayoutManager.is() && !m_bDocHidden)
lcl_enableLayoutManager(xLayoutManager, this);
// create progress helper
......@@ -971,7 +980,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const OUStr
if ( sTargetFrameName==SPECIALTARGET_BLANK )
{
TaskCreator aCreator(m_xContext);
xTarget = aCreator.createTask(sTargetFrameName);
xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor());
}
// I.II) "_parent"
......@@ -1171,7 +1180,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Frame::findFrame( const OUStr
)
{
TaskCreator aCreator(m_xContext);
xTarget = aCreator.createTask(sTargetFrameName);
xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor());
}
}
......@@ -1825,7 +1834,7 @@ void SAL_CALL Frame::setLayoutManager(const css::uno::Reference<css::uno::XInter
m_xLayoutManager = xNewLayoutManager;
if (xOldLayoutManager.is())
disableLayoutManager(xOldLayoutManager);
if (xNewLayoutManager.is())
if (xNewLayoutManager.is() && !m_bDocHidden)
lcl_enableLayoutManager(xNewLayoutManager, this);
}
}
......@@ -2738,7 +2747,7 @@ void Frame::impl_setPropertyValue(sal_Int32 nHandle,
m_xLayoutManager = xNewLayoutManager;
if (xOldLayoutManager.is())
disableLayoutManager(xOldLayoutManager);
if (xNewLayoutManager.is())
if (xNewLayoutManager.is() && !m_bDocHidden)
lcl_enableLayoutManager(xNewLayoutManager, this);
}
}
......
......@@ -129,6 +129,8 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI
css::uno::Reference< css::awt::XWindow > xContainerWindow = lArgs.getUnpackedValueOrDefault(ARGUMENT_CONTAINERWINDOW , css::uno::Reference< css::awt::XWindow >() );
bool bSupportPersistentWindowState = lArgs.getUnpackedValueOrDefault(ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE , false );
bool bEnableTitleBarUpdate = lArgs.getUnpackedValueOrDefault(ARGUMENT_ENABLE_TITLEBARUPDATE , true );
// If the frame is explicitly requested to be hidden.
bool bHidden = lArgs.getUnpackedValueOrDefault("Hidden", false);
// We use FrameName property to set it as API name of the new created frame later.
// But those frame names must be different from the set of special target names as e.g. _blank, _self etcpp !
......@@ -167,6 +169,13 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createI
//------------------->
// create the new frame
VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow(xContainerWindow);
if (pContainerWindow && bHidden)
{
WindowExtendedStyle eStyle = pContainerWindow->GetExtendedStyle();
eStyle |= WindowExtendedStyle::DocHidden;
pContainerWindow->SetExtendedStyle(eStyle);
}
css::uno::Reference< css::frame::XFrame2 > xFrame = implts_createFrame(xParentFrame, xContainerWindow, sRightName);
// special freature:
......
......@@ -470,9 +470,14 @@ enum class WindowExtendedStyle {
NONE = 0x0000,
Document = 0x0001,
DocModified = 0x0002,
/**
* This is a frame window that is requested to be hidden (not just "not yet
* shown").
*/
DocHidden = 0x0004,
};
namespace o3tl {
template<> struct typed_flags<WindowExtendedStyle> : is_typed_flags<WindowExtendedStyle, 0x0003> {};
template<> struct typed_flags<WindowExtendedStyle> : is_typed_flags<WindowExtendedStyle, 0x0007> {};
};
namespace vcl {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment