HTMLPlugInElement::isUserObservable() is causing layout
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Sep 2014 05:57:48 +0000 (05:57 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Sep 2014 05:57:48 +0000 (05:57 +0000)
commitb1fbc8af191dd70895942de6a23b17ba32fec3eb
treeac602f28370795a5582d08205fb4e04b2e19ec09
parent1833571ccd9bcebf9ef54f9bef4dd82971f1a705
HTMLPlugInElement::isUserObservable() is causing layout
https://bugs.webkit.org/show_bug.cgi?id=137156

Reviewed by Ryosuke Niwa.

While profiling the page load of nytimes.com, I noticed that we were
spending ~4-5% of cpu time in HTMLPlugInElement::isUserObservable().
The reason is that the function calls pluginWidget(), which causes a
layout update in HTMLObjectElement::renderWidgetForJSBindings(), to
make sure the plugin is loaded and its renderer is created.

HTMLPlugInElement::isUserObservable() shouldn't need to do a layout.
This patch does the following to address the problem:
- Rename renderWidgetForJSBindings() to renderWidgetLoadingPlugin()
  because this function is not always called from the JS Bindings
  nowadays. The new name makes it clearer that this will load the
  plugin if needed (to make sure the renderer is created, and by
  doing a layout).
- Add a PluginLoadingPolicy argument to
  HTMLPlugInElement::pluginWidget() to let the caller control if the
  plugin should be loaded or not.
- Update the call to pluginWidget() in isUserObservable() so that
  we do not attempt to load the plugin (thus not causing a layout).

No new tests, no behavior change.

* WebCore.exp.in:
* WebCore.order:
* html/HTMLAppletElement.cpp:
(WebCore::HTMLAppletElement::renderWidgetLoadingPlugin):
(WebCore::HTMLAppletElement::renderWidgetForJSBindings): Deleted.
* html/HTMLAppletElement.h:
* html/HTMLEmbedElement.cpp:
(WebCore::HTMLEmbedElement::renderWidgetLoadingPlugin):
(WebCore::HTMLEmbedElement::renderWidgetForJSBindings): Deleted.
* html/HTMLEmbedElement.h:
* html/HTMLObjectElement.cpp:
(WebCore::HTMLObjectElement::renderWidgetLoadingPlugin):
(WebCore::HTMLObjectElement::renderWidgetForJSBindings): Deleted.
* html/HTMLObjectElement.h:
* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::pluginWidget):
(WebCore::HTMLPlugInElement::isUserObservable):
* html/HTMLPlugInElement.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174040 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.order
Source/WebCore/html/HTMLAppletElement.cpp
Source/WebCore/html/HTMLAppletElement.h
Source/WebCore/html/HTMLEmbedElement.cpp
Source/WebCore/html/HTMLEmbedElement.h
Source/WebCore/html/HTMLObjectElement.cpp
Source/WebCore/html/HTMLObjectElement.h
Source/WebCore/html/HTMLPlugInElement.cpp
Source/WebCore/html/HTMLPlugInElement.h