2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
28 #include "FrameView.h"
30 #include "AXObjectCache.h"
31 #include "CSSStyleSelector.h"
33 #include "ChromeClient.h"
34 #include "DocLoader.h"
35 #include "EventHandler.h"
36 #include "FloatRect.h"
37 #include "FocusController.h"
39 #include "FrameLoader.h"
40 #include "FrameLoaderClient.h"
41 #include "FrameTree.h"
42 #include "GraphicsContext.h"
43 #include "HTMLDocument.h"
44 #include "HTMLFrameElement.h"
45 #include "HTMLFrameSetElement.h"
46 #include "HTMLNames.h"
47 #include "InspectorTimelineAgent.h"
48 #include "OverflowEvent.h"
49 #include "RenderEmbeddedObject.h"
50 #include "RenderLayer.h"
51 #include "RenderPart.h"
52 #include "RenderScrollbar.h"
53 #include "RenderScrollbarPart.h"
54 #include "RenderTheme.h"
55 #include "RenderView.h"
57 #include "TextResourceDecoder.h"
58 #include <wtf/CurrentTime.h>
60 #ifdef ANDROID_INSTRUMENT
61 #include "FrameTree.h"
62 #include "TimeCounter.h"
65 #if USE(ACCELERATED_COMPOSITING)
66 #include "RenderLayerCompositor.h"
70 #include "SVGDocument.h"
71 #include "SVGLocatable.h"
73 #include "SVGPreserveAspectRatio.h"
74 #include "SVGSVGElement.h"
75 #include "SVGViewElement.h"
76 #include "SVGViewSpec.h"
79 #if ENABLE(TILED_BACKING_STORE)
80 #include "TiledBackingStore.h"
84 #include "WebCoreFrameBridge.h"
89 using namespace HTMLNames;
91 double FrameView::sCurrentPaintTimeStamp = 0.0;
93 // REPAINT_THROTTLING now chooses default values for throttling parameters.
94 // Should be removed when applications start using runtime configuration.
95 #if ENABLE(REPAINT_THROTTLING)
97 double FrameView::s_deferredRepaintDelay = 0.025;
98 // Negative value would mean that first few repaints happen without a delay
99 double FrameView::s_initialDeferredRepaintDelayDuringLoading = 0;
100 // The delay grows on each repaint to this maximum value
101 double FrameView::s_maxDeferredRepaintDelayDuringLoading = 2.5;
102 // On each repaint the delay increses by this amount
103 double FrameView::s_deferredRepaintDelayIncrementDuringLoading = 0.5;
105 // FIXME: Repaint throttling could be good to have on all platform.
106 // The balance between CPU use and repaint frequency will need some tuning for desktop.
107 // More hooks may be needed to reset the delay on things like GIF and CSS animations.
108 double FrameView::s_deferredRepaintDelay = 0;
109 double FrameView::s_initialDeferredRepaintDelayDuringLoading = 0;
110 double FrameView::s_maxDeferredRepaintDelayDuringLoading = 0;
111 double FrameView::s_deferredRepaintDelayIncrementDuringLoading = 0;
114 // The maximum number of updateWidgets iterations that should be done before returning.
115 static const unsigned maxUpdateWidgetsIterations = 2;
117 struct ScheduledEvent : Noncopyable {
118 RefPtr<Event> m_event;
119 RefPtr<Node> m_eventTarget;
122 static inline float parentZoomFactor(Frame* frame)
124 Frame* parent = frame->tree()->parent();
127 FrameView* parentView = parent->view();
130 return parentView->zoomFactor();
133 FrameView::FrameView(Frame* frame)
135 , m_canHaveScrollbars(true)
136 , m_slowRepaintObjectCount(0)
137 , m_fixedObjectCount(0)
138 , m_layoutTimer(this, &FrameView::layoutTimerFired)
140 , m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired)
141 , m_isTransparent(false)
142 , m_baseBackgroundColor(Color::white)
143 , m_mediaType("screen")
145 , m_overflowStatusDirty(true)
146 , m_viewportRenderer(0)
147 , m_wasScrolledByUser(false)
148 , m_inProgrammaticScroll(false)
149 , m_deferredRepaintTimer(this, &FrameView::deferredRepaintTimerFired)
150 , m_shouldUpdateWhileOffscreen(true)
151 , m_deferSetNeedsLayouts(0)
152 , m_setNeedsLayoutWasDeferred(false)
154 , m_zoomFactor(parentZoomFactor(frame))
159 PassRefPtr<FrameView> FrameView::create(Frame* frame)
161 RefPtr<FrameView> view = adoptRef(new FrameView(frame));
163 return view.release();
166 PassRefPtr<FrameView> FrameView::create(Frame* frame, const IntSize& initialSize)
168 RefPtr<FrameView> view = adoptRef(new FrameView(frame));
169 view->Widget::setFrameRect(IntRect(view->pos(), initialSize));
171 return view.release();
174 FrameView::~FrameView()
176 if (m_postLayoutTasksTimer.isActive()) {
177 m_postLayoutTasksTimer.stop();
178 m_scheduledEvents.clear();
184 // Custom scrollbars should already be destroyed at this point
185 ASSERT(!horizontalScrollbar() || !horizontalScrollbar()->isCustomScrollbar());
186 ASSERT(!verticalScrollbar() || !verticalScrollbar()->isCustomScrollbar());
188 setHasHorizontalScrollbar(false); // Remove native scrollbars now before we lose the connection to the HostWindow.
189 setHasVerticalScrollbar(false);
191 ASSERT(!m_scrollCorner);
192 ASSERT(m_scheduledEvents.isEmpty());
193 ASSERT(!m_enqueueEvents);
196 ASSERT(m_frame->view() != this || !m_frame->contentRenderer());
197 RenderPart* renderer = m_frame->ownerRenderer();
198 if (renderer && renderer->widget() == this)
199 renderer->setWidget(0);
203 void FrameView::reset()
205 m_useSlowRepaints = false;
206 m_isOverlapped = false;
207 m_contentIsOpaque = false;
210 m_layoutTimer.stop();
212 m_delayedLayout = false;
213 m_doFullRepaint = true;
214 m_layoutSchedulingEnabled = true;
217 m_nestedLayoutCount = 0;
218 m_postLayoutTasksTimer.stop();
219 m_firstLayout = true;
220 m_firstLayoutCallbackPending = false;
221 m_wasScrolledByUser = false;
222 m_lastLayoutSize = IntSize();
223 m_lastZoomFactor = 1.0f;
224 m_deferringRepaints = 0;
226 m_repaintRects.clear();
227 m_deferredRepaintDelay = s_initialDeferredRepaintDelayDuringLoading;
228 m_deferredRepaintTimer.stop();
230 m_paintBehavior = PaintBehaviorNormal;
231 m_isPainting = false;
232 m_isVisuallyNonEmpty = false;
233 m_firstVisuallyNonEmptyLayoutCallbackPending = true;
234 m_maintainScrollPositionAnchor = 0;
237 bool FrameView::isFrameView() const
242 void FrameView::clearFrame()
247 void FrameView::resetScrollbars()
249 // Reset the document's scrollbars back to our defaults before we yield the floor.
250 m_firstLayout = true;
251 setScrollbarsSuppressed(true);
252 if (m_canHaveScrollbars)
253 setScrollbarModes(ScrollbarAuto, ScrollbarAuto);
255 setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff);
256 setScrollbarsSuppressed(false);
259 void FrameView::init()
263 m_margins = IntSize(-1, -1); // undefined
266 // Propagate the marginwidth/height and scrolling modes to the view.
267 Element* ownerElement = m_frame && m_frame->document() ? m_frame->document()->ownerElement() : 0;
268 if (ownerElement && (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag))) {
269 HTMLFrameElement* frameElt = static_cast<HTMLFrameElement*>(ownerElement);
270 if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
271 setCanHaveScrollbars(false);
272 int marginWidth = frameElt->getMarginWidth();
273 int marginHeight = frameElt->getMarginHeight();
274 if (marginWidth != -1)
275 setMarginWidth(marginWidth);
276 if (marginHeight != -1)
277 setMarginHeight(marginHeight);
281 void FrameView::detachCustomScrollbars()
286 Scrollbar* horizontalBar = horizontalScrollbar();
287 if (horizontalBar && horizontalBar->isCustomScrollbar())
288 setHasHorizontalScrollbar(false);
290 Scrollbar* verticalBar = verticalScrollbar();
291 if (verticalBar && verticalBar->isCustomScrollbar())
292 setHasVerticalScrollbar(false);
294 if (m_scrollCorner) {
295 m_scrollCorner->destroy();
300 void FrameView::clear()
302 setCanBlitOnScroll(true);
307 if (RenderPart* renderer = m_frame->ownerRenderer())
308 renderer->viewCleared();
311 setScrollbarsSuppressed(true);
314 bool FrameView::didFirstLayout() const
316 return !m_firstLayout;
319 void FrameView::invalidateRect(const IntRect& rect)
323 hostWindow()->invalidateContentsAndWindow(rect, false /*immediate*/);
330 RenderPart* renderer = m_frame->ownerRenderer();
334 IntRect repaintRect = rect;
335 repaintRect.move(renderer->borderLeft() + renderer->paddingLeft(),
336 renderer->borderTop() + renderer->paddingTop());
337 renderer->repaintRectangle(repaintRect);
340 void FrameView::setFrameRect(const IntRect& newRect)
342 IntRect oldRect = frameRect();
343 if (newRect == oldRect)
346 ScrollView::setFrameRect(newRect);
348 #if USE(ACCELERATED_COMPOSITING)
349 if (RenderView* root = m_frame->contentRenderer()) {
350 if (root->usesCompositing())
351 root->compositor()->frameViewDidChangeSize();
356 void FrameView::setMarginWidth(int w)
358 // make it update the rendering area when set
359 m_margins.setWidth(w);
362 void FrameView::setMarginHeight(int h)
364 // make it update the rendering area when set
365 m_margins.setHeight(h);
368 bool FrameView::avoidScrollbarCreation()
372 // with frame flattening no subframe can have scrollbars
373 // but we also cannot turn scrollbars of as we determine
374 // our flattening policy using that.
376 if (!m_frame->ownerElement())
379 if (!m_frame->settings() || m_frame->settings()->frameFlatteningEnabled())
385 void FrameView::setCanHaveScrollbars(bool canHaveScrollbars)
387 m_canHaveScrollbars = canHaveScrollbars;
388 ScrollView::setCanHaveScrollbars(canHaveScrollbars);
391 void FrameView::updateCanHaveScrollbars()
395 scrollbarModes(hMode, vMode);
396 if (hMode == ScrollbarAlwaysOff && vMode == ScrollbarAlwaysOff)
397 m_canHaveScrollbars = false;
399 m_canHaveScrollbars = true;
402 PassRefPtr<Scrollbar> FrameView::createScrollbar(ScrollbarOrientation orientation)
404 // FIXME: We need to update the scrollbar dynamically as documents change (or as doc elements and bodies get discovered that have custom styles).
405 Document* doc = m_frame->document();
407 // Try the <body> element first as a scrollbar source.
408 Element* body = doc ? doc->body() : 0;
409 if (body && body->renderer() && body->renderer()->style()->hasPseudoStyle(SCROLLBAR))
410 return RenderScrollbar::createCustomScrollbar(this, orientation, body->renderer()->enclosingBox());
412 // If the <body> didn't have a custom style, then the root element might.
413 Element* docElement = doc ? doc->documentElement() : 0;
414 if (docElement && docElement->renderer() && docElement->renderer()->style()->hasPseudoStyle(SCROLLBAR))
415 return RenderScrollbar::createCustomScrollbar(this, orientation, docElement->renderBox());
417 // If we have an owning iframe/frame element, then it can set the custom scrollbar also.
418 RenderPart* frameRenderer = m_frame->ownerRenderer();
419 if (frameRenderer && frameRenderer->style()->hasPseudoStyle(SCROLLBAR))
420 return RenderScrollbar::createCustomScrollbar(this, orientation, frameRenderer);
422 // Nobody set a custom style, so we just use a native scrollbar.
423 return ScrollView::createScrollbar(orientation);
426 void FrameView::setContentsSize(const IntSize& size)
428 if (size == contentsSize())
431 m_deferSetNeedsLayouts++;
433 ScrollView::setContentsSize(size);
435 Page* page = frame() ? frame()->page() : 0;
439 page->chrome()->contentsSizeChanged(frame(), size); //notify only
441 m_deferSetNeedsLayouts--;
443 if (!m_deferSetNeedsLayouts)
444 m_setNeedsLayoutWasDeferred = false; // FIXME: Find a way to make the deferred layout actually happen.
447 void FrameView::adjustViewSize()
449 ASSERT(m_frame->view() == this);
450 RenderView* root = m_frame->contentRenderer();
454 setContentsSize(IntSize(root->rightLayoutOverflow(), root->bottomLayoutOverflow()));
457 void FrameView::applyOverflowToViewport(RenderObject* o, ScrollbarMode& hMode, ScrollbarMode& vMode)
459 // Handle the overflow:hidden/scroll case for the body/html elements. WinIE treats
460 // overflow:hidden and overflow:scroll on <body> as applying to the document's
461 // scrollbars. The CSS2.1 draft states that HTML UAs should use the <html> or <body> element and XML/XHTML UAs should
462 // use the root element.
463 switch (o->style()->overflowX()) {
465 hMode = ScrollbarAlwaysOff;
468 hMode = ScrollbarAlwaysOn;
471 hMode = ScrollbarAuto;
474 // Don't set it at all.
478 switch (o->style()->overflowY()) {
480 vMode = ScrollbarAlwaysOff;
483 vMode = ScrollbarAlwaysOn;
486 vMode = ScrollbarAuto;
489 // Don't set it at all.
493 m_viewportRenderer = o;
496 #if USE(ACCELERATED_COMPOSITING)
497 void FrameView::updateCompositingLayers()
499 RenderView* view = m_frame->contentRenderer();
503 // This call will make sure the cached hasAcceleratedCompositing is updated from the pref
504 view->compositor()->cacheAcceleratedCompositingFlags();
505 view->compositor()->updateCompositingLayers(CompositingUpdateAfterLayoutOrStyleChange);
508 void FrameView::setNeedsOneShotDrawingSynchronization()
510 Page* page = frame() ? frame()->page() : 0;
512 page->chrome()->client()->setNeedsOneShotDrawingSynchronization();
515 #endif // USE(ACCELERATED_COMPOSITING)
517 bool FrameView::hasCompositedContent() const
519 #if USE(ACCELERATED_COMPOSITING)
520 if (RenderView* view = m_frame->contentRenderer())
521 return view->compositor()->inCompositingMode();
526 // Sometimes (for plug-ins) we need to eagerly go into compositing mode.
527 void FrameView::enterCompositingMode()
529 #if USE(ACCELERATED_COMPOSITING)
530 if (RenderView* view = m_frame->contentRenderer())
531 view->compositor()->enableCompositingMode();
535 bool FrameView::isEnclosedInCompositingLayer() const
537 #if USE(ACCELERATED_COMPOSITING)
538 RenderObject* frameOwnerRenderer = m_frame->ownerRenderer();
539 return frameOwnerRenderer && frameOwnerRenderer->containerForRepaint();
545 bool FrameView::syncCompositingStateRecursive()
547 #if USE(ACCELERATED_COMPOSITING)
548 ASSERT(m_frame->view() == this);
549 RenderView* contentRenderer = m_frame->contentRenderer();
550 if (!contentRenderer)
551 return true; // We don't want to keep trying to update layers if we have no renderer.
553 // If we sync compositing layers when a layout is pending, we may cause painting of compositing
554 // layer content to occur before layout has happened, which will cause paintContents() to bail.
558 if (GraphicsLayer* rootLayer = contentRenderer->compositor()->rootPlatformLayer())
559 rootLayer->syncCompositingState();
561 bool allSubframesSynced = true;
562 const HashSet<RefPtr<Widget> >* viewChildren = children();
563 HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end();
564 for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin(); current != end; ++current) {
565 Widget* widget = (*current).get();
566 if (widget->isFrameView()) {
567 bool synced = static_cast<FrameView*>(widget)->syncCompositingStateRecursive();
568 allSubframesSynced &= synced;
571 return allSubframesSynced;
572 #else // USE(ACCELERATED_COMPOSITING)
577 bool FrameView::isSoftwareRenderable() const
579 #if USE(ACCELERATED_COMPOSITING)
580 RenderView* view = m_frame->contentRenderer();
584 return !view->compositor()->has3DContent();
590 void FrameView::didMoveOnscreen()
592 RenderView* view = m_frame->contentRenderer();
594 view->didMoveOnscreen();
597 void FrameView::willMoveOffscreen()
599 RenderView* view = m_frame->contentRenderer();
601 view->willMoveOffscreen();
604 RenderObject* FrameView::layoutRoot(bool onlyDuringLayout) const
606 return onlyDuringLayout && layoutPending() ? 0 : m_layoutRoot;
609 void FrameView::layout(bool allowSubtree)
614 m_layoutTimer.stop();
615 m_delayedLayout = false;
616 m_setNeedsLayoutWasDeferred = false;
618 // Protect the view from being deleted during layout (in recalcStyle)
619 RefPtr<FrameView> protector(this);
622 // FIXME: Do we need to set m_size.width here?
623 // FIXME: Should we set m_size.height here too?
624 m_size.setWidth(layoutWidth());
628 // we shouldn't enter layout() while painting
629 ASSERT(!isPainting());
633 #if ENABLE(INSPECTOR)
634 if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
635 timelineAgent->willLayout();
638 if (!allowSubtree && m_layoutRoot) {
639 m_layoutRoot->markContainingBlocksForLayout(false);
643 ASSERT(m_frame->view() == this);
644 // This early return should be removed when rdar://5598072 is resolved. In the meantime, there is a
645 // gigantic CrashTracer because of this issue, and the early return will hopefully cause graceful
647 if (m_frame->view() != this)
650 Document* document = m_frame->document();
652 m_layoutSchedulingEnabled = false;
654 if (!m_nestedLayoutCount && m_postLayoutTasksTimer.isActive()) {
655 // This is a new top-level layout. If there are any remaining tasks from the previous
656 // layout, finish them now.
657 m_postLayoutTasksTimer.stop();
658 performPostLayoutTasks();
661 // Viewport-dependent media queries may cause us to need completely different style information.
663 if (document->styleSelector()->affectedByViewportChange())
664 document->updateStyleSelector();
666 // Always ensure our style info is up-to-date. This can happen in situations where
667 // the layout beats any sort of style recalc update that needs to occur.
668 if (m_frame->needsReapplyStyles())
669 m_frame->reapplyStyles();
670 else if (document->childNeedsStyleRecalc())
671 document->recalcStyle();
673 bool subtree = m_layoutRoot;
675 // If there is only one ref to this view left, then its going to be destroyed as soon as we exit,
676 // so there's no point to continuing to layout
677 if (protector->hasOneRef())
680 RenderObject* root = subtree ? m_layoutRoot : document->renderer();
682 // FIXME: Do we need to set m_size here?
683 m_layoutSchedulingEnabled = true;
687 #ifdef ANDROID_INSTRUMENT
688 if (!m_frame->tree() || !m_frame->tree()->parent())
689 android::TimeCounter::start(android::TimeCounter::LayoutTimeCounter);
692 m_nestedLayoutCount++;
696 if (m_canHaveScrollbars) {
697 hMode = ScrollbarAuto;
698 vMode = ScrollbarAuto;
700 hMode = ScrollbarAlwaysOff;
701 vMode = ScrollbarAlwaysOff;
705 Node* documentElement = document->documentElement();
706 RenderObject* rootRenderer = documentElement ? documentElement->renderer() : 0;
707 Node* body = document->body();
708 if (body && body->renderer()) {
709 if (body->hasTagName(framesetTag) && m_frame->settings() && !m_frame->settings()->frameFlatteningEnabled()) {
710 #if !defined(ANDROID_FLATTEN_IFRAME) && !defined(ANDROID_FLATTEN_FRAMESET)
711 body->renderer()->setChildNeedsLayout(true);
712 vMode = ScrollbarAlwaysOff;
713 hMode = ScrollbarAlwaysOff;
715 } else if (body->hasTagName(bodyTag)) {
716 if (!m_firstLayout && m_size.height() != layoutHeight() && body->renderer()->enclosingBox()->stretchesToViewHeight())
717 body->renderer()->setChildNeedsLayout(true);
718 // It's sufficient to just check the X overflow,
719 // since it's illegal to have visible in only one direction.
720 RenderObject* o = rootRenderer->style()->overflowX() == OVISIBLE && document->documentElement()->hasTagName(htmlTag) ? body->renderer() : rootRenderer;
721 applyOverflowToViewport(o, hMode, vMode);
723 } else if (rootRenderer) {
725 if (documentElement->isSVGElement()) {
726 if (!m_firstLayout && (m_size.width() != layoutWidth() || m_size.height() != layoutHeight()))
727 rootRenderer->setChildNeedsLayout(true);
729 applyOverflowToViewport(rootRenderer, hMode, vMode);
731 applyOverflowToViewport(rootRenderer, hMode, vMode);
734 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
735 if (m_firstLayout && !document->ownerElement())
736 printf("Elapsed time before first layout: %d\n", document->elapsedTime());
740 m_doFullRepaint = !subtree && (m_firstLayout || toRenderView(root)->printing());
743 // Now set our scrollbar state for the layout.
744 ScrollbarMode currentHMode = horizontalScrollbarMode();
745 ScrollbarMode currentVMode = verticalScrollbarMode();
747 if (m_firstLayout || (hMode != currentHMode || vMode != currentVMode)) {
749 setScrollbarsSuppressed(true);
751 m_firstLayout = false;
752 m_firstLayoutCallbackPending = true;
753 m_lastLayoutSize = IntSize(width(), height());
754 m_lastZoomFactor = root->style()->zoom();
756 // Set the initial vMode to AlwaysOn if we're auto.
757 if (vMode == ScrollbarAuto)
758 setVerticalScrollbarMode(ScrollbarAlwaysOn); // This causes a vertical scrollbar to appear.
759 // Set the initial hMode to AlwaysOff if we're auto.
760 if (hMode == ScrollbarAuto)
761 setHorizontalScrollbarMode(ScrollbarAlwaysOff); // This causes a horizontal scrollbar to disappear.
763 setScrollbarModes(hMode, vMode);
764 setScrollbarsSuppressed(false, true);
766 setScrollbarModes(hMode, vMode);
769 IntSize oldSize = m_size;
771 m_size = IntSize(layoutWidth(), layoutHeight());
773 if (oldSize != m_size)
774 m_doFullRepaint = true;
777 RenderLayer* layer = root->enclosingLayer();
779 pauseScheduledEvents();
781 bool disableLayoutState = false;
783 RenderView* view = root->view();
784 disableLayoutState = view->shouldDisableLayoutStateForSubtree(root);
785 view->pushLayoutState(root);
786 if (disableLayoutState)
787 view->disableLayoutState();
791 beginDeferredRepaints();
793 endDeferredRepaints();
797 RenderView* view = root->view();
798 view->popLayoutState();
799 if (disableLayoutState)
800 view->enableLayoutState();
804 m_frame->selection()->setNeedsLayout();
805 m_frame->selection()->updateAppearance();
807 m_layoutSchedulingEnabled = true;
809 if (!subtree && !toRenderView(root)->printing())
812 // Now update the positions of all layers.
813 beginDeferredRepaints();
814 IntPoint cachedOffset;
815 layer->updateLayerPositions((m_doFullRepaint ? RenderLayer::DoFullRepaint : 0)
816 | RenderLayer::CheckForRepaint
817 | RenderLayer::IsCompositingUpdateRoot
818 | RenderLayer::UpdateCompositingLayers,
819 subtree ? 0 : &cachedOffset);
820 endDeferredRepaints();
822 #if USE(ACCELERATED_COMPOSITING)
823 updateCompositingLayers();
829 if (AXObjectCache::accessibilityEnabled())
830 root->document()->axObjectCache()->postNotification(root, AXObjectCache::AXLayoutComplete, true);
832 #if ENABLE(DASHBOARD_SUPPORT)
833 updateDashboardRegions();
836 #ifdef ANDROID_INSTRUMENT
837 if (!m_frame->tree()->parent())
838 android::TimeCounter::record(android::TimeCounter::LayoutTimeCounter, __FUNCTION__);
840 ASSERT(!root->needsLayout());
842 setCanBlitOnScroll(!useSlowRepaints());
844 if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
845 updateOverflowStatus(layoutWidth() < contentsWidth(),
846 layoutHeight() < contentsHeight());
848 if (!m_postLayoutTasksTimer.isActive()) {
849 // Calls resumeScheduledEvents()
850 performPostLayoutTasks();
852 if (!m_postLayoutTasksTimer.isActive() && needsLayout()) {
853 // Post-layout widget updates or an event handler made us need layout again.
854 // Lay out again, but this time defer widget updates and event dispatch until after
856 m_postLayoutTasksTimer.startOneShot(0);
857 pauseScheduledEvents();
861 resumeScheduledEvents();
862 ASSERT(m_enqueueEvents);
865 #if ENABLE(INSPECTOR)
866 if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
867 timelineAgent->didLayout();
870 m_nestedLayoutCount--;
873 void FrameView::addWidgetToUpdate(RenderEmbeddedObject* object)
875 if (!m_widgetUpdateSet)
876 m_widgetUpdateSet.set(new RenderEmbeddedObjectSet);
878 m_widgetUpdateSet->add(object);
881 void FrameView::removeWidgetToUpdate(RenderEmbeddedObject* object)
883 if (!m_widgetUpdateSet)
886 m_widgetUpdateSet->remove(object);
889 void FrameView::setMediaType(const String& mediaType)
891 m_mediaType = mediaType;
894 String FrameView::mediaType() const
896 // See if we have an override type.
897 String overrideType = m_frame->loader()->client()->overrideMediaType();
898 if (!overrideType.isNull())
903 void FrameView::adjustMediaTypeForPrinting(bool printing)
906 if (m_mediaTypeWhenNotPrinting.isNull())
907 m_mediaTypeWhenNotPrinting = mediaType();
908 setMediaType("print");
910 if (!m_mediaTypeWhenNotPrinting.isNull())
911 setMediaType(m_mediaTypeWhenNotPrinting);
912 m_mediaTypeWhenNotPrinting = String();
916 bool FrameView::useSlowRepaints() const
918 return m_useSlowRepaints || m_slowRepaintObjectCount > 0 || (platformWidget() && m_fixedObjectCount > 0) || m_isOverlapped || !m_contentIsOpaque;
921 bool FrameView::useSlowRepaintsIfNotOverlapped() const
923 return m_useSlowRepaints || m_slowRepaintObjectCount > 0 || (platformWidget() && m_fixedObjectCount > 0) || !m_contentIsOpaque;
926 void FrameView::setUseSlowRepaints()
928 m_useSlowRepaints = true;
929 setCanBlitOnScroll(false);
932 void FrameView::addSlowRepaintObject()
934 if (!m_slowRepaintObjectCount)
935 setCanBlitOnScroll(false);
936 m_slowRepaintObjectCount++;
939 void FrameView::removeSlowRepaintObject()
941 ASSERT(m_slowRepaintObjectCount > 0);
942 m_slowRepaintObjectCount--;
943 if (!m_slowRepaintObjectCount)
944 setCanBlitOnScroll(!useSlowRepaints());
947 void FrameView::addFixedObject()
949 if (!m_fixedObjectCount && platformWidget())
950 setCanBlitOnScroll(false);
951 ++m_fixedObjectCount;
954 void FrameView::removeFixedObject()
956 ASSERT(m_fixedObjectCount > 0);
957 --m_fixedObjectCount;
958 if (!m_fixedObjectCount)
959 setCanBlitOnScroll(!useSlowRepaints());
962 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
964 const size_t fixedObjectThreshold = 5;
966 RenderBlock::PositionedObjectsListHashSet* positionedObjects = 0;
967 if (RenderView* root = m_frame->contentRenderer())
968 positionedObjects = root->positionedObjects();
970 if (!positionedObjects || positionedObjects->isEmpty()) {
971 hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
975 // Get the rects of the fixed objects visible in the rectToScroll
976 Vector<IntRect, fixedObjectThreshold> subRectToUpdate;
977 bool updateInvalidatedSubRect = true;
978 RenderBlock::PositionedObjectsListHashSet::const_iterator end = positionedObjects->end();
979 for (RenderBlock::PositionedObjectsListHashSet::const_iterator it = positionedObjects->begin(); it != end; ++it) {
980 RenderBox* renderBox = *it;
981 if (renderBox->style()->position() != FixedPosition)
983 IntRect updateRect = renderBox->layer()->repaintRectIncludingDescendants();
984 updateRect = contentsToWindow(updateRect);
986 updateRect.intersect(rectToScroll);
987 if (!updateRect.isEmpty()) {
988 if (subRectToUpdate.size() >= fixedObjectThreshold) {
989 updateInvalidatedSubRect = false;
992 subRectToUpdate.append(updateRect);
997 if (updateInvalidatedSubRect) {
999 hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
1001 // 2) update the area of fixed objects that has been invalidated
1002 size_t fixObjectsCount = subRectToUpdate.size();
1003 for (size_t i = 0; i < fixObjectsCount; ++i) {
1004 IntRect updateRect = subRectToUpdate[i];
1005 IntRect scrolledRect = updateRect;
1006 scrolledRect.move(scrollDelta);
1007 updateRect.unite(scrolledRect);
1008 updateRect.intersect(rectToScroll);
1009 hostWindow()->invalidateContentsAndWindow(updateRect, false);
1014 // the number of fixed objects exceed the threshold, we cannot use the fast path
1018 void FrameView::setIsOverlapped(bool isOverlapped)
1020 if (isOverlapped == m_isOverlapped)
1023 m_isOverlapped = isOverlapped;
1024 setCanBlitOnScroll(!useSlowRepaints());
1026 #if USE(ACCELERATED_COMPOSITING)
1027 // Overlap can affect compositing tests, so if it changes, we need to trigger
1028 // a recalcStyle in the parent document.
1029 if (hasCompositedContent()) {
1030 if (Element* ownerElement = m_frame->document()->ownerElement())
1031 ownerElement->setNeedsStyleRecalc(SyntheticStyleChange);
1036 void FrameView::setContentIsOpaque(bool contentIsOpaque)
1038 if (contentIsOpaque == m_contentIsOpaque)
1041 m_contentIsOpaque = contentIsOpaque;
1042 setCanBlitOnScroll(!useSlowRepaints());
1045 void FrameView::restoreScrollbar()
1047 setScrollbarsSuppressed(false);
1050 bool FrameView::scrollToFragment(const KURL& url)
1052 // If our URL has no ref, then we have no place we need to jump to.
1053 // OTOH If CSS target was set previously, we want to set it to 0, recalc
1054 // and possibly repaint because :target pseudo class may have been
1055 // set (see bug 11321).
1056 if (!url.hasFragmentIdentifier() && !m_frame->document()->cssTarget())
1059 String fragmentIdentifier = url.fragmentIdentifier();
1060 if (scrollToAnchor(fragmentIdentifier))
1063 // Try again after decoding the ref, based on the document's encoding.
1064 if (TextResourceDecoder* decoder = m_frame->document()->decoder())
1065 return scrollToAnchor(decodeURLEscapeSequences(fragmentIdentifier, decoder->encoding()));
1070 bool FrameView::scrollToAnchor(const String& name)
1072 ASSERT(m_frame->document());
1074 if (!m_frame->document()->haveStylesheetsLoaded()) {
1075 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(true);
1079 m_frame->document()->setGotoAnchorNeededAfterStylesheetsLoad(false);
1081 Element* anchorNode = m_frame->document()->findAnchor(name);
1084 if (m_frame->document()->isSVGDocument()) {
1085 if (name.startsWith("xpointer(")) {
1086 // We need to parse the xpointer reference here
1087 } else if (name.startsWith("svgView(")) {
1088 RefPtr<SVGSVGElement> svg = static_cast<SVGDocument*>(m_frame->document())->rootElement();
1089 if (!svg->currentView()->parseViewSpec(name))
1091 svg->setUseCurrentView(true);
1093 if (anchorNode && anchorNode->hasTagName(SVGNames::viewTag)) {
1094 RefPtr<SVGViewElement> viewElement = anchorNode->hasTagName(SVGNames::viewTag) ? static_cast<SVGViewElement*>(anchorNode) : 0;
1095 if (viewElement.get()) {
1096 RefPtr<SVGSVGElement> svg = static_cast<SVGSVGElement*>(SVGLocatable::nearestViewportElement(viewElement.get()));
1097 svg->inheritViewAttributes(viewElement.get());
1101 // FIXME: need to decide which <svg> to focus on, and zoom to that one
1102 // FIXME: need to actually "highlight" the viewTarget(s)
1106 m_frame->document()->setCSSTarget(anchorNode); // Setting to null will clear the current target.
1108 // Implement the rule that "" and "top" both mean top of page as in other browsers.
1109 if (!anchorNode && !(name.isEmpty() || equalIgnoringCase(name, "top")))
1112 #ifdef ANDROID_SCROLL_ON_GOTO_ANCHOR
1113 // TODO(andreip): check with Grace if this is correct.
1114 android::WebFrame::getWebFrame(m_frame.get())->setUserInitiatedClick(true);
1116 maintainScrollPositionAtAnchor(anchorNode ? static_cast<Node*>(anchorNode) : m_frame->document());
1117 #ifdef ANDROID_SCROLL_ON_GOTO_ANCHOR
1118 android::WebFrame::getWebFrame(m_frame.get())->setUserInitiatedClick(false);
1123 void FrameView::maintainScrollPositionAtAnchor(Node* anchorNode)
1125 m_maintainScrollPositionAnchor = anchorNode;
1126 if (!m_maintainScrollPositionAnchor)
1129 // We need to update the layout before scrolling, otherwise we could
1130 // really mess things up if an anchor scroll comes at a bad moment.
1131 m_frame->document()->updateStyleIfNeeded();
1132 // Only do a layout if changes have occurred that make it necessary.
1133 if (m_frame->contentRenderer() && m_frame->contentRenderer()->needsLayout())
1139 void FrameView::setScrollPosition(const IntPoint& scrollPoint)
1141 bool wasInProgrammaticScroll = m_inProgrammaticScroll;
1142 m_inProgrammaticScroll = true;
1143 m_maintainScrollPositionAnchor = 0;
1144 ScrollView::setScrollPosition(scrollPoint);
1145 m_inProgrammaticScroll = wasInProgrammaticScroll;
1148 void FrameView::scrollPositionChangedViaPlatformWidget()
1150 scrollPositionChanged();
1153 void FrameView::scrollPositionChanged()
1155 frame()->eventHandler()->sendScrollEvent();
1156 repaintFixedElementsAfterScrolling();
1158 #if USE(ACCELERATED_COMPOSITING)
1159 if (RenderView* root = m_frame->contentRenderer()) {
1160 if (root->usesCompositing())
1161 root->compositor()->frameViewDidScroll(scrollPosition());
1166 void FrameView::repaintFixedElementsAfterScrolling()
1168 // For fixed position elements, update widget positions and compositing layers after scrolling,
1169 // but only if we're not inside of layout.
1170 if (!m_nestedLayoutCount && hasFixedObjects()) {
1171 if (RenderView* root = m_frame->contentRenderer()) {
1172 root->updateWidgetPositions();
1173 root->layer()->updateRepaintRectsAfterScroll();
1174 #if USE(ACCELERATED_COMPOSITING)
1175 root->compositor()->updateCompositingLayers(CompositingUpdateOnScroll);
1181 HostWindow* FrameView::hostWindow() const
1183 Page* page = frame() ? frame()->page() : 0;
1186 return page->chrome();
1189 const unsigned cRepaintRectUnionThreshold = 25;
1191 void FrameView::repaintContentRectangle(const IntRect& r, bool immediate)
1193 ASSERT(!m_frame->document()->ownerElement());
1195 double delay = adjustedDeferredRepaintDelay();
1196 if ((m_deferringRepaints || m_deferredRepaintTimer.isActive() || delay) && !immediate) {
1197 IntRect paintRect = r;
1198 if (!paintsEntireContents())
1199 paintRect.intersect(visibleContentRect());
1200 #ifdef ANDROID_CAPTURE_OFFSCREEN_PAINTS
1202 ScrollView::platformOffscreenContentRectangle(visibleContentRect(), r);
1204 if (paintRect.isEmpty())
1206 if (m_repaintCount == cRepaintRectUnionThreshold) {
1207 IntRect unionedRect;
1208 for (unsigned i = 0; i < cRepaintRectUnionThreshold; ++i)
1209 unionedRect.unite(m_repaintRects[i]);
1210 m_repaintRects.clear();
1211 m_repaintRects.append(unionedRect);
1213 if (m_repaintCount < cRepaintRectUnionThreshold)
1214 m_repaintRects.append(paintRect);
1216 m_repaintRects[0].unite(paintRect);
1219 if (!m_deferringRepaints && !m_deferredRepaintTimer.isActive())
1220 m_deferredRepaintTimer.startOneShot(delay);
1224 if (!immediate && isOffscreen() && !shouldUpdateWhileOffscreen())
1227 #if ENABLE(TILED_BACKING_STORE)
1228 if (frame()->tiledBackingStore()) {
1229 frame()->tiledBackingStore()->invalidate(r);
1233 ScrollView::repaintContentRectangle(r, immediate);
1236 void FrameView::visibleContentsResized()
1238 // We check to make sure the view is attached to a frame() as this method can
1239 // be triggered before the view is attached by Frame::createView(...) setting
1240 // various values such as setScrollBarModes(...) for example. An ASSERT is
1241 // triggered when a view is layout before being attached to a frame().
1242 if (!frame()->view())
1249 void FrameView::beginDeferredRepaints()
1251 Page* page = m_frame->page();
1252 if (page->mainFrame() != m_frame)
1253 return page->mainFrame()->view()->beginDeferredRepaints();
1255 m_deferringRepaints++;
1259 void FrameView::endDeferredRepaints()
1261 Page* page = m_frame->page();
1262 if (page->mainFrame() != m_frame)
1263 return page->mainFrame()->view()->endDeferredRepaints();
1265 ASSERT(m_deferringRepaints > 0);
1267 if (--m_deferringRepaints)
1270 if (m_deferredRepaintTimer.isActive())
1273 if (double delay = adjustedDeferredRepaintDelay()) {
1274 m_deferredRepaintTimer.startOneShot(delay);
1278 doDeferredRepaints();
1281 void FrameView::checkStopDelayingDeferredRepaints()
1283 if (!m_deferredRepaintTimer.isActive())
1286 Document* document = m_frame->document();
1287 if (document && (document->parsing() || document->docLoader()->requestCount()))
1290 m_deferredRepaintTimer.stop();
1292 doDeferredRepaints();
1295 void FrameView::doDeferredRepaints()
1297 ASSERT(!m_deferringRepaints);
1298 if (isOffscreen() && !shouldUpdateWhileOffscreen()) {
1299 m_repaintRects.clear();
1303 unsigned size = m_repaintRects.size();
1304 for (unsigned i = 0; i < size; i++) {
1305 #if ENABLE(TILED_BACKING_STORE)
1306 if (frame()->tiledBackingStore()) {
1307 frame()->tiledBackingStore()->invalidate(m_repaintRects[i]);
1311 ScrollView::repaintContentRectangle(m_repaintRects[i], false);
1313 m_repaintRects.clear();
1316 updateDeferredRepaintDelay();
1319 void FrameView::updateDeferredRepaintDelay()
1321 Document* document = m_frame->document();
1322 if (!document || (!document->parsing() && !document->docLoader()->requestCount())) {
1323 m_deferredRepaintDelay = s_deferredRepaintDelay;
1326 if (m_deferredRepaintDelay < s_maxDeferredRepaintDelayDuringLoading) {
1327 m_deferredRepaintDelay += s_deferredRepaintDelayIncrementDuringLoading;
1328 if (m_deferredRepaintDelay > s_maxDeferredRepaintDelayDuringLoading)
1329 m_deferredRepaintDelay = s_maxDeferredRepaintDelayDuringLoading;
1333 void FrameView::resetDeferredRepaintDelay()
1335 m_deferredRepaintDelay = 0;
1336 if (m_deferredRepaintTimer.isActive()) {
1337 m_deferredRepaintTimer.stop();
1338 if (!m_deferringRepaints)
1339 doDeferredRepaints();
1343 double FrameView::adjustedDeferredRepaintDelay() const
1345 if (!m_deferredRepaintDelay)
1347 double timeSinceLastPaint = currentTime() - m_lastPaintTime;
1348 return max(0., m_deferredRepaintDelay - timeSinceLastPaint);
1351 void FrameView::deferredRepaintTimerFired(Timer<FrameView>*)
1353 doDeferredRepaints();
1356 void FrameView::layoutTimerFired(Timer<FrameView>*)
1358 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
1359 if (!m_frame->document()->ownerElement())
1360 printf("Layout timer fired at %d\n", m_frame->document()->elapsedTime());
1365 void FrameView::scheduleRelayout()
1367 // FIXME: We should assert the page is not in the page cache, but that is causing
1368 // too many false assertions. See <rdar://problem/7218118>.
1369 ASSERT(m_frame->view() == this);
1372 m_layoutRoot->markContainingBlocksForLayout(false);
1375 if (!m_layoutSchedulingEnabled)
1379 if (!m_frame->document()->shouldScheduleLayout())
1382 #if defined(ANDROID_FLATTEN_IFRAME) || defined(ANDROID_FLATTEN_FRAMESET)
1383 // This is the Android frame flattening code. The common code below is not
1384 // used as frameSetFlatteningEnabled() is false on Android.
1385 if (m_frame->ownerRenderer())
1386 m_frame->ownerRenderer()->setNeedsLayoutAndPrefWidthsRecalc();
1389 // When frame flattening is enabled, the contents of the frame affects layout of the parent frames.
1390 // Also invalidate parent frame starting from the owner element of this frame.
1391 if (m_frame->settings() && m_frame->settings()->frameFlatteningEnabled() && m_frame->ownerRenderer()) {
1392 if (m_frame->ownerElement()->hasTagName(iframeTag) || m_frame->ownerElement()->hasTagName(frameTag))
1393 m_frame->ownerRenderer()->setNeedsLayout(true, true);
1396 int delay = m_frame->document()->minimumLayoutDelay();
1397 if (m_layoutTimer.isActive() && m_delayedLayout && !delay)
1398 unscheduleRelayout();
1399 if (m_layoutTimer.isActive())
1402 m_delayedLayout = delay != 0;
1404 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
1405 if (!m_frame->document()->ownerElement())
1406 printf("Scheduling layout for %d\n", delay);
1409 m_layoutTimer.startOneShot(delay * 0.001);
1412 static bool isObjectAncestorContainerOf(RenderObject* ancestor, RenderObject* descendant)
1414 for (RenderObject* r = descendant; r; r = r->container()) {
1421 void FrameView::scheduleRelayoutOfSubtree(RenderObject* relayoutRoot)
1423 ASSERT(m_frame->view() == this);
1425 if (m_frame->contentRenderer() && m_frame->contentRenderer()->needsLayout()) {
1427 relayoutRoot->markContainingBlocksForLayout(false);
1431 if (layoutPending() || !m_layoutSchedulingEnabled) {
1432 if (m_layoutRoot != relayoutRoot) {
1433 if (isObjectAncestorContainerOf(m_layoutRoot, relayoutRoot)) {
1434 // Keep the current root
1435 relayoutRoot->markContainingBlocksForLayout(false, m_layoutRoot);
1436 } else if (m_layoutRoot && isObjectAncestorContainerOf(relayoutRoot, m_layoutRoot)) {
1437 // Re-root at relayoutRoot
1438 m_layoutRoot->markContainingBlocksForLayout(false, relayoutRoot);
1439 m_layoutRoot = relayoutRoot;
1441 // Just do a full relayout
1443 m_layoutRoot->markContainingBlocksForLayout(false);
1445 relayoutRoot->markContainingBlocksForLayout(false);
1448 } else if (m_layoutSchedulingEnabled) {
1449 int delay = m_frame->document()->minimumLayoutDelay();
1450 m_layoutRoot = relayoutRoot;
1451 m_delayedLayout = delay != 0;
1452 m_layoutTimer.startOneShot(delay * 0.001);
1456 bool FrameView::layoutPending() const
1458 return m_layoutTimer.isActive();
1461 bool FrameView::needsLayout() const
1463 // This can return true in cases where the document does not have a body yet.
1464 // Document::shouldScheduleLayout takes care of preventing us from scheduling
1465 // layout in that case.
1468 RenderView* root = m_frame->contentRenderer();
1469 Document* document = m_frame->document();
1470 return layoutPending()
1471 || (root && root->needsLayout())
1473 || (document && document->childNeedsStyleRecalc()) // can occur when using WebKit ObjC interface
1474 || m_frame->needsReapplyStyles()
1475 || (m_deferSetNeedsLayouts && m_setNeedsLayoutWasDeferred);
1478 void FrameView::setNeedsLayout()
1480 if (m_deferSetNeedsLayouts) {
1481 m_setNeedsLayoutWasDeferred = true;
1484 RenderView* root = m_frame->contentRenderer();
1486 root->setNeedsLayout(true);
1489 void FrameView::unscheduleRelayout()
1491 if (!m_layoutTimer.isActive())
1494 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
1495 if (!m_frame->document()->ownerElement())
1496 printf("Layout timer unscheduled at %d\n", m_frame->document()->elapsedTime());
1499 m_layoutTimer.stop();
1500 m_delayedLayout = false;
1503 bool FrameView::isTransparent() const
1505 return m_isTransparent;
1508 void FrameView::setTransparent(bool isTransparent)
1510 m_isTransparent = isTransparent;
1513 Color FrameView::baseBackgroundColor() const
1515 return m_baseBackgroundColor;
1518 void FrameView::setBaseBackgroundColor(Color bc)
1522 m_baseBackgroundColor = bc;
1525 void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool transparent)
1527 for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext(m_frame.get())) {
1528 FrameView* view = frame->view();
1532 view->setTransparent(transparent);
1533 view->setBaseBackgroundColor(backgroundColor);
1537 bool FrameView::shouldUpdateWhileOffscreen() const
1539 return m_shouldUpdateWhileOffscreen;
1542 void FrameView::setShouldUpdateWhileOffscreen(bool shouldUpdateWhileOffscreen)
1544 m_shouldUpdateWhileOffscreen = shouldUpdateWhileOffscreen;
1547 void FrameView::scheduleEvent(PassRefPtr<Event> event, PassRefPtr<Node> eventTarget)
1549 if (!m_enqueueEvents) {
1550 ExceptionCode ec = 0;
1551 eventTarget->dispatchEvent(event, ec);
1555 ScheduledEvent* scheduledEvent = new ScheduledEvent;
1556 scheduledEvent->m_event = event;
1557 scheduledEvent->m_eventTarget = eventTarget;
1558 m_scheduledEvents.append(scheduledEvent);
1561 void FrameView::pauseScheduledEvents()
1563 ASSERT(m_scheduledEvents.isEmpty() || m_enqueueEvents);
1567 void FrameView::resumeScheduledEvents()
1570 if (!m_enqueueEvents)
1571 dispatchScheduledEvents();
1572 ASSERT(m_scheduledEvents.isEmpty() || m_enqueueEvents);
1575 void FrameView::scrollToAnchor()
1577 RefPtr<Node> anchorNode = m_maintainScrollPositionAnchor;
1581 if (!anchorNode->renderer())
1585 if (anchorNode != m_frame->document())
1586 rect = anchorNode->getRect();
1588 // Scroll nested layers and frames to reveal the anchor.
1589 // Align to the top and to the closest side (this matches other browsers).
1590 anchorNode->renderer()->enclosingLayer()->scrollRectToVisible(rect, true, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
1592 if (AXObjectCache::accessibilityEnabled())
1593 m_frame->document()->axObjectCache()->handleScrolledToAnchor(anchorNode.get());
1595 // scrollRectToVisible can call into setScrollPosition(), which resets m_maintainScrollPositionAnchor.
1596 m_maintainScrollPositionAnchor = anchorNode;
1599 bool FrameView::updateWidgets()
1601 if (m_nestedLayoutCount > 1 || !m_widgetUpdateSet || m_widgetUpdateSet->isEmpty())
1604 size_t size = m_widgetUpdateSet->size();
1606 Vector<RenderEmbeddedObject*> objects;
1607 objects.reserveCapacity(size);
1609 RenderEmbeddedObjectSet::const_iterator end = m_widgetUpdateSet->end();
1610 for (RenderEmbeddedObjectSet::const_iterator it = m_widgetUpdateSet->begin(); it != end; ++it) {
1611 objects.uncheckedAppend(*it);
1615 for (size_t i = 0; i < size; ++i) {
1616 RenderEmbeddedObject* object = objects[i];
1618 // The object may have been destroyed, but our manual ref() keeps the object from being deleted.
1619 object->updateWidget(false);
1620 object->updateWidgetPosition();
1622 m_widgetUpdateSet->remove(object);
1625 RenderArena* arena = m_frame->document()->renderArena();
1626 for (size_t i = 0; i < size; ++i)
1627 objects[i]->deref(arena);
1629 return m_widgetUpdateSet->isEmpty();
1632 void FrameView::performPostLayoutTasks()
1634 if (m_firstLayoutCallbackPending) {
1635 m_firstLayoutCallbackPending = false;
1636 m_frame->loader()->didFirstLayout();
1639 if (m_isVisuallyNonEmpty && m_firstVisuallyNonEmptyLayoutCallbackPending) {
1640 m_firstVisuallyNonEmptyLayoutCallbackPending = false;
1641 m_frame->loader()->didFirstVisuallyNonEmptyLayout();
1644 RenderView* root = m_frame->contentRenderer();
1646 root->updateWidgetPositions();
1648 for (unsigned i = 0; i < maxUpdateWidgetsIterations; i++) {
1649 if (updateWidgets())
1655 resumeScheduledEvents();
1657 if (!root->printing()) {
1658 IntSize currentSize = IntSize(width(), height());
1659 float currentZoomFactor = root->style()->zoom();
1660 bool resized = !m_firstLayout && (currentSize != m_lastLayoutSize || currentZoomFactor != m_lastZoomFactor);
1661 m_lastLayoutSize = currentSize;
1662 m_lastZoomFactor = currentZoomFactor;
1664 m_frame->eventHandler()->sendResizeEvent();
1668 void FrameView::postLayoutTimerFired(Timer<FrameView>*)
1670 performPostLayoutTasks();
1673 void FrameView::updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow)
1675 if (!m_viewportRenderer)
1678 if (m_overflowStatusDirty) {
1679 m_horizontalOverflow = horizontalOverflow;
1680 m_verticalOverflow = verticalOverflow;
1681 m_overflowStatusDirty = false;
1685 bool horizontalOverflowChanged = (m_horizontalOverflow != horizontalOverflow);
1686 bool verticalOverflowChanged = (m_verticalOverflow != verticalOverflow);
1688 if (horizontalOverflowChanged || verticalOverflowChanged) {
1689 m_horizontalOverflow = horizontalOverflow;
1690 m_verticalOverflow = verticalOverflow;
1692 scheduleEvent(OverflowEvent::create(horizontalOverflowChanged, horizontalOverflow,
1693 verticalOverflowChanged, verticalOverflow),
1694 m_viewportRenderer->node());
1699 void FrameView::dispatchScheduledEvents()
1701 if (m_scheduledEvents.isEmpty())
1704 Vector<ScheduledEvent*> scheduledEventsCopy = m_scheduledEvents;
1705 m_scheduledEvents.clear();
1707 Vector<ScheduledEvent*>::iterator end = scheduledEventsCopy.end();
1708 for (Vector<ScheduledEvent*>::iterator it = scheduledEventsCopy.begin(); it != end; ++it) {
1709 ScheduledEvent* scheduledEvent = *it;
1711 ExceptionCode ec = 0;
1713 // Only dispatch events to nodes that are in the document
1714 if (scheduledEvent->m_eventTarget->inDocument())
1715 scheduledEvent->m_eventTarget->dispatchEvent(scheduledEvent->m_event, ec);
1717 delete scheduledEvent;
1721 IntRect FrameView::windowClipRect(bool clipToContents) const
1723 ASSERT(m_frame->view() == this);
1725 // Set our clip rect to be our contents.
1726 IntRect clipRect = contentsToWindow(visibleContentRect(!clipToContents));
1727 if (!m_frame || !m_frame->document() || !m_frame->document()->ownerElement())
1730 // Take our owner element and get the clip rect from the enclosing layer.
1731 Element* elt = m_frame->document()->ownerElement();
1732 RenderLayer* layer = elt->renderer()->enclosingLayer();
1733 // FIXME: layer should never be null, but sometimes seems to be anyway.
1736 FrameView* parentView = elt->document()->view();
1737 clipRect.intersect(parentView->windowClipRectForLayer(layer, true));
1741 IntRect FrameView::windowClipRectForLayer(const RenderLayer* layer, bool clipToLayerContents) const
1743 // If we have no layer, just return our window clip rect.
1745 return windowClipRect();
1747 // Apply the clip from the layer.
1749 if (clipToLayerContents)
1750 clipRect = layer->childrenClipRect();
1752 clipRect = layer->selfClipRect();
1753 clipRect = contentsToWindow(clipRect);
1754 return intersection(clipRect, windowClipRect());
1757 bool FrameView::isActive() const
1759 Page* page = frame()->page();
1760 return page && page->focusController()->isActive();
1763 void FrameView::valueChanged(Scrollbar* bar)
1765 // Figure out if we really moved.
1766 IntSize offset = scrollOffset();
1767 ScrollView::valueChanged(bar);
1768 if (offset != scrollOffset())
1769 scrollPositionChanged();
1770 frame()->loader()->client()->didChangeScrollOffset();
1773 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
1775 // Add in our offset within the FrameView.
1776 IntRect dirtyRect = rect;
1777 dirtyRect.move(scrollbar->x(), scrollbar->y());
1778 invalidateRect(dirtyRect);
1781 void FrameView::getTickmarks(Vector<IntRect>& tickmarks) const
1783 tickmarks = frame()->document()->renderedRectsForMarkers(DocumentMarker::TextMatch);
1786 IntRect FrameView::windowResizerRect() const
1788 Page* page = frame() ? frame()->page() : 0;
1791 return page->chrome()->windowResizerRect();
1794 #if ENABLE(DASHBOARD_SUPPORT)
1795 void FrameView::updateDashboardRegions()
1797 Document* document = m_frame->document();
1798 if (!document->hasDashboardRegions())
1800 Vector<DashboardRegionValue> newRegions;
1801 document->renderBox()->collectDashboardRegions(newRegions);
1802 if (newRegions == document->dashboardRegions())
1804 document->setDashboardRegions(newRegions);
1805 Page* page = m_frame->page();
1808 page->chrome()->client()->dashboardRegionsChanged();
1812 void FrameView::invalidateScrollCorner()
1814 invalidateRect(scrollCornerRect());
1817 void FrameView::updateScrollCorner()
1819 RenderObject* renderer = 0;
1820 RefPtr<RenderStyle> cornerStyle;
1822 if (!scrollCornerRect().isEmpty()) {
1823 // Try the <body> element first as a scroll corner source.
1824 Document* doc = m_frame->document();
1825 Element* body = doc ? doc->body() : 0;
1826 if (body && body->renderer()) {
1827 renderer = body->renderer();
1828 cornerStyle = renderer->getUncachedPseudoStyle(SCROLLBAR_CORNER, renderer->style());
1832 // If the <body> didn't have a custom style, then the root element might.
1833 Element* docElement = doc ? doc->documentElement() : 0;
1834 if (docElement && docElement->renderer()) {
1835 renderer = docElement->renderer();
1836 cornerStyle = renderer->getUncachedPseudoStyle(SCROLLBAR_CORNER, renderer->style());
1841 // If we have an owning iframe/frame element, then it can set the custom scrollbar also.
1842 if (RenderPart* renderer = m_frame->ownerRenderer())
1843 cornerStyle = renderer->getUncachedPseudoStyle(SCROLLBAR_CORNER, renderer->style());
1848 if (!m_scrollCorner)
1849 m_scrollCorner = new (renderer->renderArena()) RenderScrollbarPart(renderer->document());
1850 m_scrollCorner->setStyle(cornerStyle.release());
1851 invalidateRect(scrollCornerRect());
1852 } else if (m_scrollCorner) {
1853 m_scrollCorner->destroy();
1858 void FrameView::paintScrollCorner(GraphicsContext* context, const IntRect& cornerRect)
1860 if (context->updatingControlTints()) {
1861 updateScrollCorner();
1865 if (m_scrollCorner) {
1866 m_scrollCorner->paintIntoRect(context, cornerRect.x(), cornerRect.y(), cornerRect);
1870 ScrollView::paintScrollCorner(context, cornerRect);
1873 bool FrameView::hasCustomScrollbars() const
1875 const HashSet<RefPtr<Widget> >* viewChildren = children();
1876 HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end();
1877 for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin(); current != end; ++current) {
1878 Widget* widget = current->get();
1879 if (widget->isFrameView()) {
1880 if (static_cast<FrameView*>(widget)->hasCustomScrollbars())
1882 } else if (widget->isScrollbar()) {
1883 Scrollbar* scrollbar = static_cast<Scrollbar*>(widget);
1884 if (scrollbar->isCustomScrollbar())
1892 void FrameView::updateControlTints()
1894 // This is called when control tints are changed from aqua/graphite to clear and vice versa.
1895 // We do a "fake" paint, and when the theme gets a paint call, it can then do an invalidate.
1896 // This is only done if the theme supports control tinting. It's up to the theme and platform
1897 // to define when controls get the tint and to call this function when that changes.
1899 // Optimize the common case where we bring a window to the front while it's still empty.
1900 if (!m_frame || m_frame->loader()->url().isEmpty())
1903 if ((m_frame->contentRenderer() && m_frame->contentRenderer()->theme()->supportsControlTints()) || hasCustomScrollbars()) {
1906 PlatformGraphicsContext* const noContext = 0;
1907 GraphicsContext context(noContext);
1908 context.setUpdatingControlTints(true);
1909 if (platformWidget())
1910 paintContents(&context, visibleContentRect());
1912 paint(&context, frameRect());
1916 bool FrameView::wasScrolledByUser() const
1918 return m_wasScrolledByUser;
1921 void FrameView::setWasScrolledByUser(bool wasScrolledByUser)
1923 if (m_inProgrammaticScroll)
1925 m_maintainScrollPositionAnchor = 0;
1926 m_wasScrolledByUser = wasScrolledByUser;
1929 void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
1934 #if ENABLE(INSPECTOR)
1935 if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
1936 timelineAgent->willPaint(rect);
1939 Document* document = frame()->document();
1943 if (document->printing())
1944 fillWithRed = false; // Printing, don't fill with red (can't remember why).
1945 else if (document->ownerElement())
1946 fillWithRed = false; // Subframe, don't fill with red.
1947 else if (isTransparent())
1948 fillWithRed = false; // Transparent, don't fill with red.
1949 else if (m_paintBehavior & PaintBehaviorSelectionOnly)
1950 fillWithRed = false; // Selections are transparent, don't fill with red.
1951 else if (m_nodeToDraw)
1952 fillWithRed = false; // Element images are transparent, don't fill with red.
1957 p->fillRect(rect, Color(0xFF, 0, 0), DeviceColorSpace);
1960 bool isTopLevelPainter = !sCurrentPaintTimeStamp;
1961 if (isTopLevelPainter)
1962 sCurrentPaintTimeStamp = currentTime();
1964 RenderView* contentRenderer = frame()->contentRenderer();
1965 if (!contentRenderer) {
1966 LOG_ERROR("called Frame::paint with nil renderer");
1970 ASSERT(!needsLayout());
1974 #if USE(ACCELERATED_COMPOSITING)
1975 if (!p->paintingDisabled()) {
1976 if (GraphicsLayer* rootLayer = contentRenderer->compositor()->rootPlatformLayer())
1977 rootLayer->syncCompositingState();
1981 ASSERT(!m_isPainting);
1983 m_isPainting = true;
1985 // m_nodeToDraw is used to draw only one element (and its descendants)
1986 RenderObject* eltRenderer = m_nodeToDraw ? m_nodeToDraw->renderer() : 0;
1988 PaintBehavior oldPaintBehavior = m_paintBehavior;
1989 if (m_paintBehavior == PaintBehaviorNormal)
1990 document->invalidateRenderedRectsForMarkersInRect(rect);
1992 if (document->printing())
1993 m_paintBehavior |= PaintBehaviorFlattenCompositingLayers;
1995 contentRenderer->layer()->paint(p, rect, m_paintBehavior, eltRenderer);
1997 m_paintBehavior = oldPaintBehavior;
1999 m_isPainting = false;
2000 m_lastPaintTime = currentTime();
2002 #if ENABLE(DASHBOARD_SUPPORT)
2003 // Regions may have changed as a result of the visibility/z-index of element changing.
2004 if (document->dashboardRegionsDirty())
2005 updateDashboardRegions();
2008 if (isTopLevelPainter)
2009 sCurrentPaintTimeStamp = 0;
2011 #if ENABLE(INSPECTOR)
2012 if (InspectorTimelineAgent* timelineAgent = inspectorTimelineAgent())
2013 timelineAgent->didPaint();
2017 void FrameView::setPaintBehavior(PaintBehavior behavior)
2019 m_paintBehavior = behavior;
2022 PaintBehavior FrameView::paintBehavior() const
2024 return m_paintBehavior;
2027 bool FrameView::isPainting() const
2029 return m_isPainting;
2032 void FrameView::setNodeToDraw(Node* node)
2034 m_nodeToDraw = node;
2037 void FrameView::layoutIfNeededRecursive()
2039 // We have to crawl our entire tree looking for any FrameViews that need
2040 // layout and make sure they are up to date.
2041 // Mac actually tests for intersection with the dirty region and tries not to
2042 // update layout for frames that are outside the dirty region. Not only does this seem
2043 // pointless (since those frames will have set a zero timer to layout anyway), but
2044 // it is also incorrect, since if two frames overlap, the first could be excluded from the dirty
2045 // region but then become included later by the second frame adding rects to the dirty region
2046 // when it lays out.
2051 const HashSet<RefPtr<Widget> >* viewChildren = children();
2052 HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end();
2053 for (HashSet<RefPtr<Widget> >::const_iterator current = viewChildren->begin(); current != end; ++current) {
2054 Widget* widget = (*current).get();
2055 if (widget->isFrameView())
2056 static_cast<FrameView*>(widget)->layoutIfNeededRecursive();
2059 // layoutIfNeededRecursive is called when we need to make sure layout is up-to-date before
2060 // painting, so we need to flush out any deferred repaints too.
2061 flushDeferredRepaints();
2064 void FrameView::flushDeferredRepaints()
2066 if (!m_deferredRepaintTimer.isActive())
2068 m_deferredRepaintTimer.stop();
2069 doDeferredRepaints();
2072 void FrameView::forceLayout(bool allowSubtree)
2074 layout(allowSubtree);
2075 // We cannot unschedule a pending relayout, since the force can be called with
2076 // a tiny rectangle from a drawRect update. By unscheduling we in effect
2077 // "validate" and stop the necessary full repaint from occurring. Basically any basic
2078 // append/remove DHTML is broken by this call. For now, I have removed the optimization
2079 // until we have a better invalidation stategy. -dwh
2080 //unscheduleRelayout();
2083 void FrameView::forceLayoutWithPageWidthRange(float minPageWidth, float maxPageWidth, bool _adjustViewSize)
2085 // Dumping externalRepresentation(m_frame->renderer()).ascii() is a good trick to see
2086 // the state of things before and after the layout
2087 RenderView *root = toRenderView(m_frame->document()->renderer());
2089 // This magic is basically copied from khtmlview::print
2090 int pageW = (int)ceilf(minPageWidth);
2091 root->setWidth(pageW);
2092 root->setNeedsLayoutAndPrefWidthsRecalc();
2095 // If we don't fit in the minimum page width, we'll lay out again. If we don't fit in the
2096 // maximum page width, we will lay out to the maximum page width and clip extra content.
2097 // FIXME: We are assuming a shrink-to-fit printing implementation. A cropping
2098 // implementation should not do this!
2099 int rightmostPos = root->rightmostPosition();
2100 if (rightmostPos > minPageWidth) {
2101 pageW = std::min(rightmostPos, (int)ceilf(maxPageWidth));
2102 root->setWidth(pageW);
2103 root->setNeedsLayoutAndPrefWidthsRecalc();
2108 if (_adjustViewSize)
2112 void FrameView::adjustPageHeight(float *newBottom, float oldTop, float oldBottom, float /*bottomLimit*/)
2114 RenderView* root = m_frame->contentRenderer();
2116 // Use a context with painting disabled.
2117 GraphicsContext context((PlatformGraphicsContext*)0);
2118 root->setTruncatedAt((int)floorf(oldBottom));
2119 IntRect dirtyRect(0, (int)floorf(oldTop), root->rightLayoutOverflow(), (int)ceilf(oldBottom - oldTop));
2120 root->layer()->paint(&context, dirtyRect);
2121 *newBottom = root->bestTruncatedAt();
2122 if (*newBottom == 0)
2123 *newBottom = oldBottom;
2125 *newBottom = oldBottom;
2128 IntRect FrameView::convertFromRenderer(const RenderObject* renderer, const IntRect& rendererRect) const
2130 IntRect rect = renderer->localToAbsoluteQuad(FloatRect(rendererRect)).enclosingBoundingBox();
2132 // Convert from page ("absolute") to FrameView coordinates.
2133 rect.move(-scrollX(), -scrollY());
2138 IntRect FrameView::convertToRenderer(const RenderObject* renderer, const IntRect& viewRect) const
2140 IntRect rect = viewRect;
2142 // Convert from FrameView coords into page ("absolute") coordinates.
2143 rect.move(scrollX(), scrollY());
2145 // FIXME: we don't have a way to map an absolute rect down to a local quad, so just
2146 // move the rect for now.
2147 rect.setLocation(roundedIntPoint(renderer->absoluteToLocal(rect.location(), false, true /* use transforms */)));
2151 IntPoint FrameView::convertFromRenderer(const RenderObject* renderer, const IntPoint& rendererPoint) const
2153 IntPoint point = roundedIntPoint(renderer->localToAbsolute(rendererPoint, false, true /* use transforms */));
2155 // Convert from page ("absolute") to FrameView coordinates.
2156 point.move(-scrollX(), -scrollY());
2160 IntPoint FrameView::convertToRenderer(const RenderObject* renderer, const IntPoint& viewPoint) const
2162 IntPoint point = viewPoint;
2164 // Convert from FrameView coords into page ("absolute") coordinates.
2165 point += IntSize(scrollX(), scrollY());
2167 return roundedIntPoint(renderer->absoluteToLocal(point, false, true /* use transforms */));
2170 IntRect FrameView::convertToContainingView(const IntRect& localRect) const
2172 if (const ScrollView* parentScrollView = parent()) {
2173 if (parentScrollView->isFrameView()) {
2174 const FrameView* parentView = static_cast<const FrameView*>(parentScrollView);
2175 // Get our renderer in the parent view
2176 RenderPart* renderer = m_frame->ownerRenderer();
2180 IntRect rect(localRect);
2181 // Add borders and padding??
2182 rect.move(renderer->borderLeft() + renderer->paddingLeft(),
2183 renderer->borderTop() + renderer->paddingTop());
2184 return parentView->convertFromRenderer(renderer, rect);
2187 return Widget::convertToContainingView(localRect);
2193 IntRect FrameView::convertFromContainingView(const IntRect& parentRect) const
2195 if (const ScrollView* parentScrollView = parent()) {
2196 if (parentScrollView->isFrameView()) {
2197 const FrameView* parentView = static_cast<const FrameView*>(parentScrollView);
2199 // Get our renderer in the parent view
2200 RenderPart* renderer = m_frame->ownerRenderer();
2204 IntRect rect = parentView->convertToRenderer(renderer, parentRect);
2205 // Subtract borders and padding
2206 rect.move(-renderer->borderLeft() - renderer->paddingLeft(),
2207 -renderer->borderTop() - renderer->paddingTop());
2211 return Widget::convertFromContainingView(parentRect);
2217 IntPoint FrameView::convertToContainingView(const IntPoint& localPoint) const
2219 if (const ScrollView* parentScrollView = parent()) {
2220 if (parentScrollView->isFrameView()) {
2221 const FrameView* parentView = static_cast<const FrameView*>(parentScrollView);
2223 // Get our renderer in the parent view
2224 RenderPart* renderer = m_frame->ownerRenderer();
2228 IntPoint point(localPoint);
2230 // Add borders and padding
2231 point.move(renderer->borderLeft() + renderer->paddingLeft(),
2232 renderer->borderTop() + renderer->paddingTop());
2233 return parentView->convertFromRenderer(renderer, point);
2236 return Widget::convertToContainingView(localPoint);
2242 IntPoint FrameView::convertFromContainingView(const IntPoint& parentPoint) const
2244 if (const ScrollView* parentScrollView = parent()) {
2245 if (parentScrollView->isFrameView()) {
2246 const FrameView* parentView = static_cast<const FrameView*>(parentScrollView);
2248 // Get our renderer in the parent view
2249 RenderPart* renderer = m_frame->ownerRenderer();
2253 IntPoint point = parentView->convertToRenderer(renderer, parentPoint);
2254 // Subtract borders and padding
2255 point.move(-renderer->borderLeft() - renderer->paddingLeft(),
2256 -renderer->borderTop() - renderer->paddingTop());
2260 return Widget::convertFromContainingView(parentPoint);
2266 bool FrameView::shouldApplyTextZoom() const
2268 if (m_zoomFactor == 1)
2272 Page* page = m_frame->page();
2273 return page && page->settings()->zoomMode() == ZoomTextOnly;
2276 bool FrameView::shouldApplyPageZoom() const
2278 if (m_zoomFactor == 1)
2282 Page* page = m_frame->page();
2283 return page && page->settings()->zoomMode() == ZoomPage;
2286 void FrameView::setZoomFactor(float percent, ZoomMode mode)
2291 Page* page = m_frame->page();
2295 if (m_zoomFactor == percent && page->settings()->zoomMode() == mode)
2298 Document* document = m_frame->document();
2303 // Respect SVGs zoomAndPan="disabled" property in standalone SVG documents.
2304 // FIXME: How to handle compound documents + zoomAndPan="disabled"? Needs SVG WG clarification.
2305 if (document->isSVGDocument()) {
2306 if (!static_cast<SVGDocument*>(document)->zoomAndPanEnabled())
2308 if (document->renderer())
2309 document->renderer()->setNeedsLayout(true);
2313 if (mode == ZoomPage) {
2314 // Update the scroll position when doing a full page zoom, so the content stays in relatively the same position.
2315 IntPoint scrollPosition = this->scrollPosition();
2316 float percentDifference = (percent / m_zoomFactor);
2317 setScrollPosition(IntPoint(scrollPosition.x() * percentDifference, scrollPosition.y() * percentDifference));
2320 m_zoomFactor = percent;
2321 page->settings()->setZoomMode(mode);
2323 document->recalcStyle(Node::Force);
2325 for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
2326 if (FrameView* childView = child->view())
2327 childView->setZoomFactor(m_zoomFactor, mode);
2330 if (document->renderer() && document->renderer()->needsLayout() && didFirstLayout())
2336 void FrameView::setRepaintThrottlingDeferredRepaintDelay(double p)
2338 s_deferredRepaintDelay = p;
2341 // Negative value would mean that first few repaints happen without a delay
2342 void FrameView::setRepaintThrottlingnInitialDeferredRepaintDelayDuringLoading(double p)
2344 s_initialDeferredRepaintDelayDuringLoading = p;
2347 // The delay grows on each repaint to this maximum value
2348 void FrameView::setRepaintThrottlingMaxDeferredRepaintDelayDuringLoading(double p)
2350 s_maxDeferredRepaintDelayDuringLoading = p;
2353 // On each repaint the delay increases by this amount
2354 void FrameView::setRepaintThrottlingDeferredRepaintDelayIncrementDuringLoading(double p)
2356 s_deferredRepaintDelayIncrementDuringLoading = p;
2359 } // namespace WebCore