2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
23 #include "AlternativeTextClient.h"
24 #include "AnimationController.h"
25 #include "BackForwardController.h"
26 #include "BackForwardList.h"
28 #include "ChromeClient.h"
29 #include "ClientRectList.h"
30 #include "ContextMenuClient.h"
31 #include "ContextMenuController.h"
32 #include "DOMWindow.h"
33 #include "DocumentMarkerController.h"
34 #include "DocumentStyleSheetCollection.h"
35 #include "DragController.h"
37 #include "EditorClient.h"
39 #include "EventNames.h"
40 #include "ExceptionCode.h"
41 #include "ExceptionCodePlaceholder.h"
42 #include "FileSystem.h"
43 #include "FocusController.h"
45 #include "FrameLoader.h"
46 #include "FrameLoaderClient.h"
47 #include "FrameSelection.h"
48 #include "FrameTree.h"
49 #include "FrameView.h"
50 #include "HTMLElement.h"
51 #include "HistoryController.h"
52 #include "HistoryItem.h"
53 #include "InspectorController.h"
54 #include "InspectorInstrumentation.h"
56 #include "MediaCanStartListener.h"
57 #include "Navigator.h"
58 #include "NetworkStateNotifier.h"
59 #include "PageActivityAssertionToken.h"
60 #include "PageCache.h"
61 #include "PageConsole.h"
62 #include "PageGroup.h"
63 #include "PageThrottler.h"
64 #include "PlugInClient.h"
65 #include "PluginData.h"
66 #include "PluginView.h"
67 #include "PointerLockController.h"
68 #include "ProgressTracker.h"
69 #include "RenderArena.h"
70 #include "RenderLayerCompositor.h"
71 #include "RenderTheme.h"
72 #include "RenderView.h"
73 #include "RenderWidget.h"
74 #include "RuntimeEnabledFeatures.h"
75 #include "SchemeRegistry.h"
76 #include "ScriptController.h"
77 #include "ScrollingCoordinator.h"
79 #include "SharedBuffer.h"
80 #include "StorageArea.h"
81 #include "StorageNamespace.h"
82 #include "StyleResolver.h"
83 #include "TextResourceDecoder.h"
84 #include "VisitedLinkState.h"
85 #include "VoidCallback.h"
87 #include <wtf/HashMap.h>
88 #include <wtf/RefCountedLeakCounter.h>
89 #include <wtf/StdLibExtras.h>
90 #include <wtf/text/Base64.h>
91 #include <wtf/text/StringHash.h>
95 static HashSet<Page*>* allPages;
97 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, pageCounter, ("Page"));
99 static void networkStateChanged(bool isOnLine)
101 Vector<RefPtr<Frame> > frames;
103 // Get all the frames of all the pages in all the page groups
104 HashSet<Page*>::iterator end = allPages->end();
105 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) {
106 for (Frame* frame = &(*it)->mainFrame(); frame; frame = frame->tree().traverseNext())
107 frames.append(frame);
108 InspectorInstrumentation::networkStateChanged(*it);
111 AtomicString eventName = isOnLine ? eventNames().onlineEvent : eventNames().offlineEvent;
112 for (unsigned i = 0; i < frames.size(); i++)
113 frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false));
116 float deviceScaleFactor(Frame* frame)
120 Page* page = frame->page();
123 return page->deviceScaleFactor();
126 Page::Page(PageClients& pageClients)
127 : m_chrome(Chrome::create(this, pageClients.chromeClient))
128 , m_dragCaretController(DragCaretController::create())
129 #if ENABLE(DRAG_SUPPORT)
130 , m_dragController(DragController::create(this, pageClients.dragClient))
132 , m_focusController(FocusController::create(this))
133 #if ENABLE(CONTEXT_MENUS)
134 , m_contextMenuController(ContextMenuController::create(this, pageClients.contextMenuClient))
136 #if ENABLE(INSPECTOR)
137 , m_inspectorController(InspectorController::create(this, pageClients.inspectorClient))
139 #if ENABLE(POINTER_LOCK)
140 , m_pointerLockController(PointerLockController::create(this))
142 , m_settings(Settings::create(this))
143 , m_progress(ProgressTracker::create())
144 , m_backForwardController(BackForwardController::create(this, pageClients.backForwardClient))
145 , m_mainFrame(Frame::create(this, 0, pageClients.loaderClientForMainFrame))
146 , m_theme(RenderTheme::themeForPage(this))
147 , m_editorClient(pageClients.editorClient)
148 , m_plugInClient(pageClients.plugInClient)
149 , m_validationMessageClient(pageClients.validationMessageClient)
151 , m_openedByDOM(false)
152 , m_tabKeyCyclesThroughElements(true)
153 , m_defersLoading(false)
154 , m_defersLoadingCallCount(0)
155 , m_inLowQualityInterpolationMode(false)
156 , m_cookieEnabled(true)
157 , m_areMemoryCacheClientCallsEnabled(true)
159 , m_pageScaleFactor(1)
160 , m_deviceScaleFactor(1)
161 , m_suppressScrollbarAnimations(false)
162 , m_didLoadUserStyleSheet(false)
163 , m_userStyleSheetModificationTime(0)
166 , m_customHTMLTokenizerTimeDelay(-1)
167 , m_customHTMLTokenizerChunkSize(-1)
168 , m_canStartMedia(true)
169 #if ENABLE(VIEW_MODE_CSS_MEDIA)
170 , m_viewMode(ViewModeWindowed)
171 #endif // ENABLE(VIEW_MODE_CSS_MEDIA)
172 , m_minimumTimerInterval(Settings::defaultMinDOMTimerInterval())
173 , m_timerAlignmentInterval(Settings::defaultDOMTimerAlignmentInterval())
174 , m_isEditable(false)
177 #if ENABLE(PAGE_VISIBILITY_API)
178 , m_visibilityState(PageVisibilityStateVisible)
180 , m_requestedLayoutMilestones(0)
183 , m_isCountingRelevantRepaintedObjects(false)
185 , m_isPainting(false)
187 , m_alternativeTextClient(pageClients.alternativeTextClient)
188 , m_scriptedAnimationsSuspended(false)
189 , m_pageThrottler(PageThrottler::create(this))
190 , m_console(PageConsole::create(this))
191 , m_lastSpatialNavigationCandidatesCount(0) // NOTE: Only called from Internals for Spatial Navigation testing.
192 , m_framesHandlingBeforeUnloadEvent(0)
194 ASSERT(m_editorClient);
197 allPages = new HashSet<Page*>;
199 networkStateNotifier().addNetworkStateChangeListener(networkStateChanged);
202 ASSERT(!allPages->contains(this));
206 pageCounter.increment();
212 m_mainFrame->setView(0);
213 setGroupName(String());
214 allPages->remove(this);
216 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
217 frame->willDetachPage();
218 frame->detachFromPage();
221 m_editorClient->pageDestroyed();
223 m_plugInClient->pageDestroyed();
224 if (m_alternativeTextClient)
225 m_alternativeTextClient->pageDestroyed();
227 #if ENABLE(INSPECTOR)
228 m_inspectorController->inspectedPageDestroyed();
231 if (m_scrollingCoordinator)
232 m_scrollingCoordinator->pageDestroyed();
234 backForward()->close();
237 pageCounter.decrement();
240 m_pageThrottler.clear();
243 ArenaSize Page::renderTreeSize() const
245 ArenaSize total(0, 0);
246 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
247 if (!frame->document())
249 if (RenderArena* arena = frame->document()->renderArena()) {
250 total.treeSize += arena->totalRenderArenaSize();
251 total.allocated += arena->totalRenderArenaAllocatedBytes();
257 ViewportArguments Page::viewportArguments() const
259 return mainFrame().document() ? mainFrame().document()->viewportArguments() : ViewportArguments();
262 ScrollingCoordinator* Page::scrollingCoordinator()
264 if (!m_scrollingCoordinator && m_settings->scrollingCoordinatorEnabled())
265 m_scrollingCoordinator = ScrollingCoordinator::create(this);
267 return m_scrollingCoordinator.get();
270 String Page::scrollingStateTreeAsText()
272 if (Document* document = m_mainFrame->document())
273 document->updateLayout();
275 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
276 return scrollingCoordinator->scrollingStateTreeAsText();
281 String Page::mainThreadScrollingReasonsAsText()
283 if (Document* document = m_mainFrame->document())
284 document->updateLayout();
286 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
287 return scrollingCoordinator->mainThreadScrollingReasonsAsText();
292 PassRefPtr<ClientRectList> Page::nonFastScrollableRects(const Frame* frame)
294 if (Document* document = m_mainFrame->document())
295 document->updateLayout();
297 Vector<IntRect> rects;
298 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
299 rects = scrollingCoordinator->computeNonFastScrollableRegion(frame, IntPoint()).rects();
301 Vector<FloatQuad> quads(rects.size());
302 for (size_t i = 0; i < rects.size(); ++i)
303 quads[i] = FloatRect(rects[i]);
304 return ClientRectList::create(quads);
307 #if ENABLE(VIEW_MODE_CSS_MEDIA)
308 struct ViewModeInfo {
312 static const int viewModeMapSize = 5;
313 static ViewModeInfo viewModeMap[viewModeMapSize] = {
314 {"windowed", Page::ViewModeWindowed},
315 {"floating", Page::ViewModeFloating},
316 {"fullscreen", Page::ViewModeFullscreen},
317 {"maximized", Page::ViewModeMaximized},
318 {"minimized", Page::ViewModeMinimized}
321 Page::ViewMode Page::stringToViewMode(const String& text)
323 for (int i = 0; i < viewModeMapSize; ++i) {
324 if (text == viewModeMap[i].name)
325 return viewModeMap[i].type;
327 return Page::ViewModeInvalid;
330 void Page::setViewMode(ViewMode viewMode)
332 if (viewMode == m_viewMode || viewMode == ViewModeInvalid)
335 m_viewMode = viewMode;
340 if (m_mainFrame->view())
341 m_mainFrame->view()->forceLayout();
343 if (m_mainFrame->document())
344 m_mainFrame->document()->styleResolverChanged(RecalcStyleImmediately);
346 #endif // ENABLE(VIEW_MODE_CSS_MEDIA)
348 bool Page::openedByDOM() const
350 return m_openedByDOM;
353 void Page::setOpenedByDOM()
355 m_openedByDOM = true;
358 BackForwardList* Page::backForwardList() const
360 return m_backForwardController->client();
365 HistoryItem* item = backForward()->backItem();
368 goToItem(item, FrameLoadTypeBack);
374 bool Page::goForward()
376 HistoryItem* item = backForward()->forwardItem();
379 goToItem(item, FrameLoadTypeForward);
385 bool Page::canGoBackOrForward(int distance) const
389 if (distance > 0 && distance <= backForward()->forwardCount())
391 if (distance < 0 && -distance <= backForward()->backCount())
396 void Page::goBackOrForward(int distance)
401 HistoryItem* item = backForward()->itemAtIndex(distance);
404 if (int forwardCount = backForward()->forwardCount())
405 item = backForward()->itemAtIndex(forwardCount);
407 if (int backCount = backForward()->backCount())
408 item = backForward()->itemAtIndex(-backCount);
415 goToItem(item, FrameLoadTypeIndexedBackForward);
418 void Page::goToItem(HistoryItem* item, FrameLoadType type)
420 // stopAllLoaders may end up running onload handlers, which could cause further history traversals that may lead to the passed in HistoryItem
421 // being deref()-ed. Make sure we can still use it with HistoryController::goToItem later.
422 RefPtr<HistoryItem> protector(item);
424 if (m_mainFrame->loader().history().shouldStopLoadingForHistoryItem(item))
425 m_mainFrame->loader().stopAllLoaders();
427 m_mainFrame->loader().history().goToItem(item, type);
430 int Page::getHistoryLength()
432 return backForward()->backCount() + 1 + backForward()->forwardCount();
435 void Page::setGroupName(const String& name)
437 if (m_group && !m_group->name().isEmpty()) {
438 ASSERT(m_group != m_singlePageGroup.get());
439 ASSERT(!m_singlePageGroup);
440 m_group->removePage(this);
444 m_group = m_singlePageGroup.get();
446 m_singlePageGroup.clear();
447 m_group = PageGroup::pageGroup(name);
448 m_group->addPage(this);
452 const String& Page::groupName() const
454 return m_group ? m_group->name() : nullAtom.string();
457 void Page::initGroup()
459 ASSERT(!m_singlePageGroup);
461 m_singlePageGroup = PageGroup::create(this);
462 m_group = m_singlePageGroup.get();
465 void Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment()
469 HashSet<Page*>::iterator end = allPages->end();
470 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it)
471 for (Frame* frame = &(*it)->mainFrame(); frame; frame = frame->tree().traverseNext()) {
472 // If a change in the global environment has occurred, we need to
473 // make sure all the properties a recomputed, therefore we invalidate
474 // the properties cache.
475 if (StyleResolver* styleResolver = frame->document()->styleResolverIfExists())
476 styleResolver->invalidateMatchedPropertiesCache();
477 frame->document()->scheduleForcedStyleRecalc();
481 void Page::setNeedsRecalcStyleInAllFrames()
483 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
484 if (Document* document = frame->document())
485 document->styleResolverChanged(DeferRecalcStyle);
489 void Page::refreshPlugins(bool reload)
494 PluginData::refresh();
496 Vector<RefPtr<Frame> > framesNeedingReload;
498 HashSet<Page*>::iterator end = allPages->end();
499 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) {
502 // Clear out the page's plug-in data.
503 if (page->m_pluginData)
504 page->m_pluginData = 0;
509 for (Frame* frame = &(*it)->mainFrame(); frame; frame = frame->tree().traverseNext()) {
510 if (frame->loader().subframeLoader()->containsPlugins())
511 framesNeedingReload.append(frame);
515 for (size_t i = 0; i < framesNeedingReload.size(); ++i)
516 framesNeedingReload[i]->loader().reload();
519 PluginData* Page::pluginData() const
522 m_pluginData = PluginData::create(this);
523 return m_pluginData.get();
526 inline MediaCanStartListener* Page::takeAnyMediaCanStartListener()
528 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
529 if (MediaCanStartListener* listener = frame->document()->takeAnyMediaCanStartListener())
535 void Page::setCanStartMedia(bool canStartMedia)
537 if (m_canStartMedia == canStartMedia)
540 m_canStartMedia = canStartMedia;
542 while (m_canStartMedia) {
543 MediaCanStartListener* listener = takeAnyMediaCanStartListener();
546 listener->mediaCanStart();
550 static Frame* incrementFrame(Frame* curr, bool forward, bool wrapFlag)
553 ? curr->tree().traverseNextWithWrap(wrapFlag)
554 : curr->tree().traversePreviousWithWrap(wrapFlag);
557 bool Page::findString(const String& target, TextCaseSensitivity caseSensitivity, FindDirection direction, bool shouldWrap)
559 return findString(target, (caseSensitivity == TextCaseInsensitive ? CaseInsensitive : 0) | (direction == FindDirectionBackward ? Backwards : 0) | (shouldWrap ? WrapAround : 0));
562 bool Page::findString(const String& target, FindOptions options)
564 if (target.isEmpty())
567 bool shouldWrap = options & WrapAround;
568 Frame* frame = focusController().focusedOrMainFrame();
569 Frame* startFrame = frame;
571 if (frame->editor().findString(target, (options & ~WrapAround) | StartInSelection)) {
572 if (frame != startFrame)
573 startFrame->selection().clear();
574 focusController().setFocusedFrame(frame);
577 frame = incrementFrame(frame, !(options & Backwards), shouldWrap);
578 } while (frame && frame != startFrame);
580 // Search contents of startFrame, on the other side of the selection that we did earlier.
581 // We cheat a bit and just research with wrap on
582 if (shouldWrap && !startFrame->selection().isNone()) {
583 bool found = startFrame->editor().findString(target, options | WrapAround | StartInSelection);
584 focusController().setFocusedFrame(frame);
591 void Page::findStringMatchingRanges(const String& target, FindOptions options, int limit, Vector<RefPtr<Range> >* matchRanges, int& indexForSelection)
593 indexForSelection = 0;
595 Frame* frame = &mainFrame();
596 Frame* frameWithSelection = 0;
598 frame->editor().countMatchesForText(target, 0, options, limit ? (limit - matchRanges->size()) : 0, true, matchRanges);
599 if (frame->selection().isRange())
600 frameWithSelection = frame;
601 frame = incrementFrame(frame, true, false);
604 if (matchRanges->isEmpty())
607 if (frameWithSelection) {
608 indexForSelection = NoMatchAfterUserSelection;
609 RefPtr<Range> selectedRange = frameWithSelection->selection().selection().firstRange();
610 if (options & Backwards) {
611 for (size_t i = matchRanges->size(); i > 0; --i) {
612 if (selectedRange->compareBoundaryPoints(Range::END_TO_START, matchRanges->at(i - 1).get(), IGNORE_EXCEPTION) > 0) {
613 indexForSelection = i - 1;
618 for (size_t i = 0; i < matchRanges->size(); ++i) {
619 if (selectedRange->compareBoundaryPoints(Range::START_TO_END, matchRanges->at(i).get(), IGNORE_EXCEPTION) < 0) {
620 indexForSelection = i;
626 if (options & Backwards)
627 indexForSelection = matchRanges->size() - 1;
629 indexForSelection = 0;
633 PassRefPtr<Range> Page::rangeOfString(const String& target, Range* referenceRange, FindOptions options)
635 if (target.isEmpty())
638 if (referenceRange && referenceRange->ownerDocument()->page() != this)
641 bool shouldWrap = options & WrapAround;
642 Frame* frame = referenceRange ? referenceRange->ownerDocument()->frame() : &mainFrame();
643 Frame* startFrame = frame;
645 if (RefPtr<Range> resultRange = frame->editor().rangeOfString(target, frame == startFrame ? referenceRange : 0, options & ~WrapAround))
646 return resultRange.release();
648 frame = incrementFrame(frame, !(options & Backwards), shouldWrap);
649 } while (frame && frame != startFrame);
651 // Search contents of startFrame, on the other side of the reference range that we did earlier.
652 // We cheat a bit and just search again with wrap on.
653 if (shouldWrap && referenceRange) {
654 if (RefPtr<Range> resultRange = startFrame->editor().rangeOfString(target, referenceRange, options | WrapAround | StartInSelection))
655 return resultRange.release();
661 unsigned Page::findMatchesForText(const String& target, FindOptions options, unsigned maxMatchCount, ShouldHighlightMatches shouldHighlightMatches, ShouldMarkMatches shouldMarkMatches)
663 if (target.isEmpty())
666 unsigned matchCount = 0;
668 Frame* frame = &mainFrame();
670 if (shouldMarkMatches == MarkMatches)
671 frame->editor().setMarkedTextMatchesAreHighlighted(shouldHighlightMatches == HighlightMatches);
672 matchCount += frame->editor().countMatchesForText(target, 0, options, maxMatchCount ? (maxMatchCount - matchCount) : 0, shouldMarkMatches == MarkMatches, 0);
673 frame = incrementFrame(frame, true, false);
679 unsigned Page::markAllMatchesForText(const String& target, FindOptions options, bool shouldHighlight, unsigned maxMatchCount)
681 return findMatchesForText(target, options, maxMatchCount, shouldHighlight ? HighlightMatches : DoNotHighlightMatches, MarkMatches);
684 unsigned Page::countFindMatches(const String& target, FindOptions options, unsigned maxMatchCount)
686 return findMatchesForText(target, options, maxMatchCount, DoNotHighlightMatches, DoNotMarkMatches);
689 void Page::unmarkAllTextMatches()
691 Frame* frame = &mainFrame();
693 frame->document()->markers().removeMarkers(DocumentMarker::TextMatch);
694 frame = incrementFrame(frame, true, false);
698 const VisibleSelection& Page::selection() const
700 return focusController().focusedOrMainFrame()->selection().selection();
703 void Page::setDefersLoading(bool defers)
705 if (!m_settings->loadDeferringEnabled())
708 if (m_settings->wantsBalancedSetDefersLoadingBehavior()) {
709 ASSERT(defers || m_defersLoadingCallCount);
710 if (defers && ++m_defersLoadingCallCount > 1)
712 if (!defers && --m_defersLoadingCallCount)
715 ASSERT(!m_defersLoadingCallCount);
716 if (defers == m_defersLoading)
720 m_defersLoading = defers;
721 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
722 frame->loader().setDefersLoading(defers);
725 void Page::clearUndoRedoOperations()
727 m_editorClient->clearUndoRedoOperations();
730 bool Page::inLowQualityImageInterpolationMode() const
732 return m_inLowQualityInterpolationMode;
735 void Page::setInLowQualityImageInterpolationMode(bool mode)
737 m_inLowQualityInterpolationMode = mode;
740 void Page::setMediaVolume(float volume)
742 if (volume < 0 || volume > 1)
745 if (m_mediaVolume == volume)
748 m_mediaVolume = volume;
749 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
750 frame->document()->mediaVolumeDidChange();
754 void Page::setPageScaleFactor(float scale, const IntPoint& origin)
756 Document* document = mainFrame().document();
757 FrameView* view = document->view();
759 if (scale == m_pageScaleFactor) {
760 if (view && (view->scrollPosition() != origin || view->delegatesScrolling())) {
761 if (!m_settings->applyPageScaleFactorInCompositor())
762 document->updateLayoutIgnorePendingStylesheets();
763 view->setScrollPosition(origin);
768 m_pageScaleFactor = scale;
770 if (!m_settings->applyPageScaleFactorInCompositor()) {
771 if (document->renderer())
772 document->renderer()->setNeedsLayout(true);
774 document->recalcStyle(Style::Force);
776 // Transform change on RenderView doesn't trigger repaint on non-composited contents.
777 mainFrame().view()->invalidateRect(IntRect(LayoutRect::infiniteRect()));
780 #if USE(ACCELERATED_COMPOSITING)
781 mainFrame().deviceOrPageScaleFactorChanged();
784 if (view && view->fixedElementsLayoutRelativeToFrame())
785 view->setViewportConstrainedObjectsNeedLayout();
787 if (view && view->scrollPosition() != origin) {
788 if (!m_settings->applyPageScaleFactorInCompositor() && document->renderer() && document->renderer()->needsLayout() && view->didFirstLayout())
790 view->setScrollPosition(origin);
795 void Page::setDeviceScaleFactor(float scaleFactor)
797 if (m_deviceScaleFactor == scaleFactor)
800 m_deviceScaleFactor = scaleFactor;
801 setNeedsRecalcStyleInAllFrames();
803 #if USE(ACCELERATED_COMPOSITING)
804 mainFrame().deviceOrPageScaleFactorChanged();
805 pageCache()->markPagesForDeviceScaleChanged(this);
808 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
809 frame->editor().deviceScaleFactorChanged();
811 pageCache()->markPagesForFullStyleRecalc(this);
814 void Page::setShouldSuppressScrollbarAnimations(bool suppressAnimations)
816 if (suppressAnimations == m_suppressScrollbarAnimations)
819 if (!suppressAnimations) {
820 // If animations are not going to be suppressed anymore, then there is nothing to do here but
821 // change the cached value.
822 m_suppressScrollbarAnimations = suppressAnimations;
826 // On the other hand, if we are going to start suppressing animations, then we need to make sure we
827 // finish any current scroll animations first.
828 FrameView* view = mainFrame().view();
832 view->finishCurrentScrollAnimations();
834 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
835 FrameView* frameView = frame->view();
839 const HashSet<ScrollableArea*>* scrollableAreas = frameView->scrollableAreas();
840 if (!scrollableAreas)
843 for (HashSet<ScrollableArea*>::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
844 ScrollableArea* scrollableArea = *it;
845 ASSERT(scrollableArea->scrollbarsCanBeActive());
847 scrollableArea->finishCurrentScrollAnimations();
851 m_suppressScrollbarAnimations = suppressAnimations;
854 bool Page::rubberBandsAtBottom()
856 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
857 return scrollingCoordinator->rubberBandsAtBottom();
862 void Page::setRubberBandsAtBottom(bool rubberBandsAtBottom)
864 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
865 scrollingCoordinator->setRubberBandsAtBottom(rubberBandsAtBottom);
868 bool Page::rubberBandsAtTop()
870 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
871 return scrollingCoordinator->rubberBandsAtTop();
876 void Page::setRubberBandsAtTop(bool rubberBandsAtTop)
878 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
879 scrollingCoordinator->setRubberBandsAtTop(rubberBandsAtTop);
882 void Page::setPagination(const Pagination& pagination)
884 if (m_pagination == pagination)
887 m_pagination = pagination;
889 setNeedsRecalcStyleInAllFrames();
890 pageCache()->markPagesForFullStyleRecalc(this);
893 unsigned Page::pageCount() const
895 if (m_pagination.mode == Pagination::Unpaginated)
898 if (Document* document = mainFrame().document())
899 document->updateLayoutIgnorePendingStylesheets();
901 RenderView* contentRenderer = mainFrame().contentRenderer();
902 return contentRenderer ? contentRenderer->columnCount(contentRenderer->columnInfo()) : 0;
905 void Page::didMoveOnscreen()
909 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
910 if (FrameView* frameView = frame->view())
911 frameView->didMoveOnscreen();
914 resumeScriptedAnimations();
917 void Page::willMoveOffscreen()
919 m_isOnscreen = false;
921 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
922 if (FrameView* frameView = frame->view())
923 frameView->willMoveOffscreen();
926 suspendScriptedAnimations();
929 void Page::setIsInWindow(bool isInWindow)
931 if (m_isInWindow == isInWindow)
934 m_isInWindow = isInWindow;
936 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
937 if (FrameView* frameView = frame->view())
938 frameView->setIsInWindow(isInWindow);
942 void Page::suspendScriptedAnimations()
944 m_scriptedAnimationsSuspended = true;
945 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
946 if (frame->document())
947 frame->document()->suspendScriptedAnimationControllerCallbacks();
951 void Page::resumeScriptedAnimations()
953 m_scriptedAnimationsSuspended = false;
954 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
955 if (frame->document())
956 frame->document()->resumeScriptedAnimationControllerCallbacks();
960 void Page::setThrottled(bool throttled)
962 m_pageThrottler->setThrottled(throttled);
965 void Page::userStyleSheetLocationChanged()
967 // FIXME: Eventually we will move to a model of just being handed the sheet
968 // text instead of loading the URL ourselves.
969 KURL url = m_settings->userStyleSheetLocation();
971 // Allow any local file URL scheme to be loaded.
972 if (SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol()))
973 m_userStyleSheetPath = url.fileSystemPath();
975 m_userStyleSheetPath = String();
977 m_didLoadUserStyleSheet = false;
978 m_userStyleSheet = String();
979 m_userStyleSheetModificationTime = 0;
981 // Data URLs with base64-encoded UTF-8 style sheets are common. We can process them
982 // synchronously and avoid using a loader.
983 if (url.protocolIsData() && url.string().startsWith("data:text/css;charset=utf-8;base64,")) {
984 m_didLoadUserStyleSheet = true;
986 Vector<char> styleSheetAsUTF8;
987 if (base64Decode(decodeURLEscapeSequences(url.string().substring(35)), styleSheetAsUTF8, Base64IgnoreWhitespace))
988 m_userStyleSheet = String::fromUTF8(styleSheetAsUTF8.data(), styleSheetAsUTF8.size());
991 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
992 if (frame->document())
993 frame->document()->styleSheetCollection()->updatePageUserSheet();
997 const String& Page::userStyleSheet() const
999 if (m_userStyleSheetPath.isEmpty())
1000 return m_userStyleSheet;
1003 if (!getFileModificationTime(m_userStyleSheetPath, modTime)) {
1004 // The stylesheet either doesn't exist, was just deleted, or is
1005 // otherwise unreadable. If we've read the stylesheet before, we should
1006 // throw away that data now as it no longer represents what's on disk.
1007 m_userStyleSheet = String();
1008 return m_userStyleSheet;
1011 // If the stylesheet hasn't changed since the last time we read it, we can
1012 // just return the old data.
1013 if (m_didLoadUserStyleSheet && modTime <= m_userStyleSheetModificationTime)
1014 return m_userStyleSheet;
1016 m_didLoadUserStyleSheet = true;
1017 m_userStyleSheet = String();
1018 m_userStyleSheetModificationTime = modTime;
1020 // FIXME: It would be better to load this asynchronously to avoid blocking
1021 // the process, but we will first need to create an asynchronous loading
1022 // mechanism that is not tied to a particular Frame. We will also have to
1023 // determine what our behavior should be before the stylesheet is loaded
1024 // and what should happen when it finishes loading, especially with respect
1025 // to when the load event fires, when Document::close is called, and when
1026 // layout/paint are allowed to happen.
1027 RefPtr<SharedBuffer> data = SharedBuffer::createWithContentsOfFile(m_userStyleSheetPath);
1029 return m_userStyleSheet;
1031 RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("text/css");
1032 m_userStyleSheet = decoder->decode(data->data(), data->size());
1033 m_userStyleSheet.append(decoder->flush());
1035 return m_userStyleSheet;
1038 void Page::removeAllVisitedLinks()
1042 HashSet<PageGroup*> groups;
1043 HashSet<Page*>::iterator pagesEnd = allPages->end();
1044 for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) {
1045 if (PageGroup* group = (*it)->groupPtr())
1048 HashSet<PageGroup*>::iterator groupsEnd = groups.end();
1049 for (HashSet<PageGroup*>::iterator it = groups.begin(); it != groupsEnd; ++it)
1050 (*it)->removeVisitedLinks();
1053 void Page::allVisitedStateChanged(PageGroup* group)
1059 HashSet<Page*>::iterator pagesEnd = allPages->end();
1060 for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) {
1062 if (page->m_group != group)
1064 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree().traverseNext())
1065 frame->document()->visitedLinkState().invalidateStyleForAllLinks();
1069 void Page::visitedStateChanged(PageGroup* group, LinkHash linkHash)
1075 HashSet<Page*>::iterator pagesEnd = allPages->end();
1076 for (HashSet<Page*>::iterator it = allPages->begin(); it != pagesEnd; ++it) {
1078 if (page->m_group != group)
1080 for (Frame* frame = page->m_mainFrame.get(); frame; frame = frame->tree().traverseNext())
1081 frame->document()->visitedLinkState().invalidateStyleForLink(linkHash);
1085 void Page::setDebuggerForAllPages(JSC::Debugger* debugger)
1089 HashSet<Page*>::iterator end = allPages->end();
1090 for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it)
1091 (*it)->setDebugger(debugger);
1094 void Page::setDebugger(JSC::Debugger* debugger)
1096 if (m_debugger == debugger)
1099 m_debugger = debugger;
1101 for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext())
1102 frame->script().attachDebugger(m_debugger);
1105 StorageNamespace* Page::sessionStorage(bool optionalCreate)
1107 if (!m_sessionStorage && optionalCreate)
1108 m_sessionStorage = StorageNamespace::sessionStorageNamespace(this);
1110 return m_sessionStorage.get();
1113 void Page::setSessionStorage(PassRefPtr<StorageNamespace> newStorage)
1115 m_sessionStorage = newStorage;
1118 void Page::setCustomHTMLTokenizerTimeDelay(double customHTMLTokenizerTimeDelay)
1120 if (customHTMLTokenizerTimeDelay < 0) {
1121 m_customHTMLTokenizerTimeDelay = -1;
1124 m_customHTMLTokenizerTimeDelay = customHTMLTokenizerTimeDelay;
1127 void Page::setCustomHTMLTokenizerChunkSize(int customHTMLTokenizerChunkSize)
1129 if (customHTMLTokenizerChunkSize < 0) {
1130 m_customHTMLTokenizerChunkSize = -1;
1133 m_customHTMLTokenizerChunkSize = customHTMLTokenizerChunkSize;
1136 void Page::setMemoryCacheClientCallsEnabled(bool enabled)
1138 if (m_areMemoryCacheClientCallsEnabled == enabled)
1141 m_areMemoryCacheClientCallsEnabled = enabled;
1145 for (RefPtr<Frame> frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
1146 frame->loader().tellClientAboutPastMemoryCacheLoads();
1149 void Page::setMinimumTimerInterval(double minimumTimerInterval)
1151 double oldTimerInterval = m_minimumTimerInterval;
1152 m_minimumTimerInterval = minimumTimerInterval;
1153 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNextWithWrap(false)) {
1154 if (frame->document())
1155 frame->document()->adjustMinimumTimerInterval(oldTimerInterval);
1159 double Page::minimumTimerInterval() const
1161 return m_minimumTimerInterval;
1164 void Page::setTimerAlignmentInterval(double interval)
1166 if (interval == m_timerAlignmentInterval)
1169 m_timerAlignmentInterval = interval;
1170 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNextWithWrap(false)) {
1171 if (frame->document())
1172 frame->document()->didChangeTimerAlignmentInterval();
1176 double Page::timerAlignmentInterval() const
1178 return m_timerAlignmentInterval;
1181 void Page::dnsPrefetchingStateChanged()
1183 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
1184 frame->document()->initDNSPrefetch();
1187 void Page::collectPluginViews(Vector<RefPtr<PluginViewBase>, 32>& pluginViewBases)
1189 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
1190 FrameView* view = frame->view();
1194 const HashSet<RefPtr<Widget> >* children = view->children();
1197 HashSet<RefPtr<Widget> >::const_iterator end = children->end();
1198 for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != end; ++it) {
1199 Widget* widget = (*it).get();
1200 if (widget->isPluginViewBase())
1201 pluginViewBases.append(toPluginViewBase(widget));
1206 void Page::storageBlockingStateChanged()
1208 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
1209 frame->document()->storageBlockingStateDidChange();
1211 // Collect the PluginViews in to a vector to ensure that action the plug-in takes
1212 // from below storageBlockingStateChanged does not affect their lifetime.
1213 Vector<RefPtr<PluginViewBase>, 32> pluginViewBases;
1214 collectPluginViews(pluginViewBases);
1216 for (size_t i = 0; i < pluginViewBases.size(); ++i)
1217 pluginViewBases[i]->storageBlockingStateChanged();
1220 void Page::privateBrowsingStateChanged()
1222 bool privateBrowsingEnabled = m_settings->privateBrowsingEnabled();
1224 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
1225 frame->document()->privateBrowsingStateDidChange();
1227 // Collect the PluginViews in to a vector to ensure that action the plug-in takes
1228 // from below privateBrowsingStateChanged does not affect their lifetime.
1229 Vector<RefPtr<PluginViewBase>, 32> pluginViewBases;
1230 collectPluginViews(pluginViewBases);
1232 for (size_t i = 0; i < pluginViewBases.size(); ++i)
1233 pluginViewBases[i]->privateBrowsingStateChanged(privateBrowsingEnabled);
1236 #if !ASSERT_DISABLED
1237 void Page::checkSubframeCountConsistency() const
1239 ASSERT(m_subframeCount >= 0);
1241 int subframeCount = 0;
1242 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
1245 ASSERT(m_subframeCount + 1 == subframeCount);
1249 void Page::throttleTimers()
1251 #if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
1252 if (m_settings->hiddenPageDOMTimerThrottlingEnabled())
1253 setTimerAlignmentInterval(Settings::hiddenPageDOMTimerAlignmentInterval());
1257 void Page::unthrottleTimers()
1259 #if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
1260 if (m_settings->hiddenPageDOMTimerThrottlingEnabled())
1261 setTimerAlignmentInterval(Settings::defaultDOMTimerAlignmentInterval());
1265 #if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
1266 void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitialState)
1268 #if !ENABLE(PAGE_VISIBILITY_API)
1269 UNUSED_PARAM(isInitialState);
1271 // FIXME: The visibility state should be stored on the top-level document.
1272 // https://bugs.webkit.org/show_bug.cgi?id=116769
1274 if (m_visibilityState == visibilityState)
1276 m_visibilityState = visibilityState;
1278 if (!isInitialState) {
1279 Vector<RefPtr<Document>> documents;
1280 for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext())
1281 documents.append(frame->document());
1282 for (size_t i = 0, size = documents.size(); i < size; ++i)
1283 documents[i]->dispatchEvent(Event::create(eventNames().visibilitychangeEvent, false, false));
1287 if (visibilityState == WebCore::PageVisibilityStateHidden) {
1288 if (m_pageThrottler->shouldThrottleTimers())
1290 if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
1291 mainFrame().animation().suspendAnimations();
1294 if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
1295 mainFrame().animation().resumeAnimations();
1298 #endif // ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
1300 #if ENABLE(PAGE_VISIBILITY_API)
1301 PageVisibilityState Page::visibilityState() const
1303 return m_visibilityState;
1307 #if ENABLE(RUBBER_BANDING)
1308 void Page::addHeaderWithHeight(int headerHeight)
1310 m_headerHeight = headerHeight;
1312 FrameView* frameView = mainFrame().view();
1316 RenderView* renderView = frameView->renderView();
1320 frameView->setHeaderHeight(m_headerHeight);
1321 renderView->compositor().updateLayerForHeader(m_headerHeight);
1324 void Page::addFooterWithHeight(int footerHeight)
1326 m_footerHeight = footerHeight;
1328 FrameView* frameView = mainFrame().view();
1332 RenderView* renderView = frameView->renderView();
1336 frameView->setFooterHeight(m_footerHeight);
1337 renderView->compositor().updateLayerForFooter(m_footerHeight);
1341 void Page::addLayoutMilestones(LayoutMilestones milestones)
1343 // In the future, we may want a function that replaces m_layoutMilestones instead of just adding to it.
1344 m_requestedLayoutMilestones |= milestones;
1347 void Page::removeLayoutMilestones(LayoutMilestones milestones)
1349 m_requestedLayoutMilestones &= ~milestones;
1352 // These are magical constants that might be tweaked over time.
1353 static double gMinimumPaintedAreaRatio = 0.1;
1354 static double gMaximumUnpaintedAreaRatio = 0.04;
1356 bool Page::isCountingRelevantRepaintedObjects() const
1358 return m_isCountingRelevantRepaintedObjects && (m_requestedLayoutMilestones & DidHitRelevantRepaintedObjectsAreaThreshold);
1361 void Page::startCountingRelevantRepaintedObjects()
1363 // Reset everything in case we didn't hit the threshold last time.
1364 resetRelevantPaintedObjectCounter();
1366 m_isCountingRelevantRepaintedObjects = true;
1369 void Page::resetRelevantPaintedObjectCounter()
1371 m_isCountingRelevantRepaintedObjects = false;
1372 m_relevantUnpaintedRenderObjects.clear();
1373 m_topRelevantPaintedRegion = Region();
1374 m_bottomRelevantPaintedRegion = Region();
1375 m_relevantUnpaintedRegion = Region();
1378 static LayoutRect relevantViewRect(RenderView* view)
1380 // DidHitRelevantRepaintedObjectsAreaThreshold is a LayoutMilestone intended to indicate that
1381 // a certain relevant amount of content has been drawn to the screen. This is the rect that
1382 // has been determined to be relevant in the context of this goal. We may choose to tweak
1383 // the rect over time, much like we may choose to tweak gMinimumPaintedAreaRatio and
1384 // gMaximumUnpaintedAreaRatio. But this seems to work well right now.
1385 LayoutRect relevantViewRect = LayoutRect(0, 0, 980, 1300);
1387 LayoutRect viewRect = view->viewRect();
1388 // If the viewRect is wider than the relevantViewRect, center the relevantViewRect.
1389 if (viewRect.width() > relevantViewRect.width())
1390 relevantViewRect.setX((viewRect.width() - relevantViewRect.width()) / 2);
1392 return relevantViewRect;
1395 void Page::addRelevantRepaintedObject(RenderObject* object, const LayoutRect& objectPaintRect)
1397 if (!isCountingRelevantRepaintedObjects())
1400 // Objects inside sub-frames are not considered to be relevant.
1401 if (&object->frame() != &mainFrame())
1404 LayoutRect relevantRect = relevantViewRect(&object->view());
1406 // The objects are only relevant if they are being painted within the viewRect().
1407 if (!objectPaintRect.intersects(pixelSnappedIntRect(relevantRect)))
1410 IntRect snappedPaintRect = pixelSnappedIntRect(objectPaintRect);
1412 // If this object was previously counted as an unpainted object, remove it from that HashSet
1413 // and corresponding Region. FIXME: This doesn't do the right thing if the objects overlap.
1414 HashSet<RenderObject*>::iterator it = m_relevantUnpaintedRenderObjects.find(object);
1415 if (it != m_relevantUnpaintedRenderObjects.end()) {
1416 m_relevantUnpaintedRenderObjects.remove(it);
1417 m_relevantUnpaintedRegion.subtract(snappedPaintRect);
1420 // Split the relevantRect into a top half and a bottom half. Making sure we have coverage in
1421 // both halves helps to prevent cases where we have a fully loaded menu bar or masthead with
1422 // no content beneath that.
1423 LayoutRect topRelevantRect = relevantRect;
1424 topRelevantRect.contract(LayoutSize(0, relevantRect.height() / 2));
1425 LayoutRect bottomRelevantRect = topRelevantRect;
1426 bottomRelevantRect.setY(relevantRect.height() / 2);
1428 // If the rect straddles both Regions, split it appropriately.
1429 if (topRelevantRect.intersects(snappedPaintRect) && bottomRelevantRect.intersects(snappedPaintRect)) {
1430 IntRect topIntersection = snappedPaintRect;
1431 topIntersection.intersect(pixelSnappedIntRect(topRelevantRect));
1432 m_topRelevantPaintedRegion.unite(topIntersection);
1434 IntRect bottomIntersection = snappedPaintRect;
1435 bottomIntersection.intersect(pixelSnappedIntRect(bottomRelevantRect));
1436 m_bottomRelevantPaintedRegion.unite(bottomIntersection);
1437 } else if (topRelevantRect.intersects(snappedPaintRect))
1438 m_topRelevantPaintedRegion.unite(snappedPaintRect);
1440 m_bottomRelevantPaintedRegion.unite(snappedPaintRect);
1442 float topPaintedArea = m_topRelevantPaintedRegion.totalArea();
1443 float bottomPaintedArea = m_bottomRelevantPaintedRegion.totalArea();
1444 float viewArea = relevantRect.width() * relevantRect.height();
1446 float ratioThatIsPaintedOnTop = topPaintedArea / viewArea;
1447 float ratioThatIsPaintedOnBottom = bottomPaintedArea / viewArea;
1448 float ratioOfViewThatIsUnpainted = m_relevantUnpaintedRegion.totalArea() / viewArea;
1450 if (ratioThatIsPaintedOnTop > (gMinimumPaintedAreaRatio / 2) && ratioThatIsPaintedOnBottom > (gMinimumPaintedAreaRatio / 2)
1451 && ratioOfViewThatIsUnpainted < gMaximumUnpaintedAreaRatio) {
1452 m_isCountingRelevantRepaintedObjects = false;
1453 resetRelevantPaintedObjectCounter();
1454 if (Frame* frame = &mainFrame())
1455 frame->loader().didLayout(DidHitRelevantRepaintedObjectsAreaThreshold);
1459 void Page::addRelevantUnpaintedObject(RenderObject* object, const LayoutRect& objectPaintRect)
1461 if (!isCountingRelevantRepaintedObjects())
1464 // The objects are only relevant if they are being painted within the relevantViewRect().
1465 if (!objectPaintRect.intersects(pixelSnappedIntRect(relevantViewRect(&object->view()))))
1468 m_relevantUnpaintedRenderObjects.add(object);
1469 m_relevantUnpaintedRegion.unite(pixelSnappedIntRect(objectPaintRect));
1472 void Page::suspendActiveDOMObjectsAndAnimations()
1474 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
1475 frame->suspendActiveDOMObjectsAndAnimations();
1478 void Page::resumeActiveDOMObjectsAndAnimations()
1480 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
1481 frame->resumeActiveDOMObjectsAndAnimations();
1484 bool Page::hasSeenAnyPlugin() const
1486 return !m_seenPlugins.isEmpty();
1489 bool Page::hasSeenPlugin(const String& serviceType) const
1491 return m_seenPlugins.contains(serviceType);
1494 void Page::sawPlugin(const String& serviceType)
1496 m_seenPlugins.add(serviceType);
1499 void Page::resetSeenPlugins()
1501 m_seenPlugins.clear();
1504 bool Page::hasSeenAnyMediaEngine() const
1506 return !m_seenMediaEngines.isEmpty();
1509 bool Page::hasSeenMediaEngine(const String& engineDescription) const
1511 return m_seenMediaEngines.contains(engineDescription);
1514 void Page::sawMediaEngine(const String& engineDescription)
1516 m_seenMediaEngines.add(engineDescription);
1519 void Page::resetSeenMediaEngines()
1521 m_seenMediaEngines.clear();
1524 PassOwnPtr<PageActivityAssertionToken> Page::createActivityToken()
1526 return adoptPtr(new PageActivityAssertionToken(m_pageThrottler.get()));
1529 #if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
1530 void Page::hiddenPageDOMTimerThrottlingStateChanged()
1532 if (m_settings->hiddenPageDOMTimerThrottlingEnabled()) {
1533 #if ENABLE(PAGE_VISIBILITY_API)
1534 if (m_pageThrottler->shouldThrottleTimers())
1535 setTimerAlignmentInterval(Settings::hiddenPageDOMTimerAlignmentInterval());
1538 setTimerAlignmentInterval(Settings::defaultDOMTimerAlignmentInterval());
1542 #if (ENABLE_PAGE_VISIBILITY_API)
1543 void Page::hiddenPageCSSAnimationSuspensionStateChanged()
1545 if (m_visibilityState == WebCore::PageVisibilityStateHidden) {
1546 if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
1547 mainFrame().animation().suspendAnimations();
1549 mainFrame().animation().resumeAnimations();
1554 #if ENABLE(VIDEO_TRACK)
1555 void Page::captionPreferencesChanged()
1557 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
1558 frame->document()->captionPreferencesChanged();
1562 void Page::incrementFrameHandlingBeforeUnloadEventCount()
1564 ++m_framesHandlingBeforeUnloadEvent;
1567 void Page::decrementFrameHandlingBeforeUnloadEventCount()
1569 ASSERT(m_framesHandlingBeforeUnloadEvent);
1570 --m_framesHandlingBeforeUnloadEvent;
1573 bool Page::isAnyFrameHandlingBeforeUnloadEvent()
1575 return m_framesHandlingBeforeUnloadEvent;
1578 Page::PageClients::PageClients()
1579 : alternativeTextClient(0)
1581 #if ENABLE(CONTEXT_MENUS)
1582 , contextMenuClient(0)
1586 , inspectorClient(0)
1588 , validationMessageClient(0)
1589 , loaderClientForMainFrame(0)
1593 Page::PageClients::~PageClients()
1597 } // namespace WebCore