Aways have a PageThrottler (sometimes have a UserActivity::Impl)
https://bugs.webkit.org/show_bug.cgi?id=136892

Reviewed by Geoffrey Garen.

Some instances of Page have a PageThrottler to track activity on the Page, and some do not.
(Specifically, those created from WebPage in WK2 do, those related to WK1, SVG & inspector do not).

We do this for three reasons:
    * We do not need to take AppNap assertions on WK1.
    * Some Pages do not track their visibility correctly, and would always claim to be visible.
    * Page VisibilityState is not set until after construction, so if we instantiate

Creating the entire PageThrottler lazily has the drawback that we have to check for its existence at
numerous points throughout the code, and we'll miss activity that occurs between the Page being created
& the PageThrottler added to it (really a theoretical problem right now, since they're currently always
created pretty much back to back).

Instead, Page should always have a PageThrottler, & instead make the UserActivity::Impl on the
PageThrottler be added later.

Source/WebCore:

* WebCore.exp.in:
    - createPageThrottler -> enablePageThrottler
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
    - Page::pageThrottler now returns a reference rather than a pointer
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::started):
    - Page::pageThrottler now returns a reference rather than a pointer
* page/Page.cpp:
(WebCore::Page::Page):
    - instantiate PageThrottler in constructor
(WebCore::Page::enablePageThrottler):
    - renamed from createPageThrottler, instead of creating the PageThrottler this method now
      instruct PageThrottler to create a UserActivity::Impl
(WebCore::Page::setViewState):
    - m_pageThrottler is not a pointer
(WebCore::Page::createPageThrottler): Deleted.
    - renamed to enablePageThrottler
* page/Page.h:
(WebCore::Page::pageThrottler):
    - now returns a reference
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
    - no longer instantiate m_activity
(WebCore::PageThrottler::createUserActivity):
    - lazily instantiate m_activity, call updateUserActivity
(WebCore::PageThrottler::updateUserActivity):
    - m_activity may not yet be instantiated; added early return
* page/PageThrottler.h:
    - m_activity becomes a std::unique_ptr, added createUserActivity

Source/WebKit2:

* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::evaluate):
    - createPageThrottler -> enablePageThrottler
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::mouseEvent):
(WebKit::WebPage::wheelEvent):
(WebKit::WebPage::keyEvent):
    - Page::pageThrottler now returns a reference rather than a pointer



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173696 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 450624b..cd716d9 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -1154,8 +1154,8 @@
 
 void FrameLoader::started()
 {
-    if (m_frame.page() && m_frame.page()->pageThrottler())
-        m_activityAssertion = m_frame.page()->pageThrottler()->pageLoadActivityToken();
+    if (m_frame.page())
+        m_activityAssertion = m_frame.page()->pageThrottler().pageLoadActivityToken();
     for (Frame* frame = &m_frame; frame; frame = frame->tree().parent())
         frame->loader().m_isComplete = false;
 }