summaryrefslogtreecommitdiff
path: root/Source/WebCore/page/FrameView.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebCore/page/FrameView.cpp
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebCore/page/FrameView.cpp')
-rw-r--r--Source/WebCore/page/FrameView.cpp100
1 files changed, 44 insertions, 56 deletions
diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp
index 56f6c60c2..9fc1cc605 100644
--- a/Source/WebCore/page/FrameView.cpp
+++ b/Source/WebCore/page/FrameView.cpp
@@ -131,10 +131,6 @@ FrameView::FrameView(Frame* frame)
, m_fixedObjectCount(0)
, m_layoutTimer(this, &FrameView::layoutTimerFired)
, m_layoutRoot(0)
-#if ENABLE(SVG)
- , m_inLayoutParentView(false)
-#endif
- , m_hasPendingPostLayoutTasks(false)
, m_inSynchronousPostLayout(false)
, m_postLayoutTasksTimer(this, &FrameView::postLayoutTimerFired)
, m_isTransparent(false)
@@ -186,7 +182,7 @@ PassRefPtr<FrameView> FrameView::create(Frame* frame, const IntSize& initialSize
FrameView::~FrameView()
{
- if (m_hasPendingPostLayoutTasks) {
+ if (m_postLayoutTasksTimer.isActive()) {
m_postLayoutTasksTimer.stop();
m_actionScheduler->clear();
}
@@ -222,7 +218,6 @@ void FrameView::reset()
m_cannotBlitToWindow = false;
m_isOverlapped = false;
m_contentIsOpaque = false;
- m_shouldLayoutFixedElementsRelativeToFrame = false;
m_borderX = 30;
m_borderY = 30;
m_layoutTimer.stop();
@@ -232,7 +227,6 @@ void FrameView::reset()
m_layoutSchedulingEnabled = true;
m_inLayout = false;
m_inSynchronousPostLayout = false;
- m_hasPendingPostLayoutTasks = false;
m_layoutCount = 0;
m_nestedLayoutCount = 0;
m_postLayoutTasksTimer.stop();
@@ -648,14 +642,15 @@ void FrameView::calculateScrollbarModesForLayout(ScrollbarMode& hMode, Scrollbar
}
}
-#if ENABLE(FULLSCREEN_API) && USE(ACCELERATED_COMPOSITING)
+#if USE(ACCELERATED_COMPOSITING)
+
+#if ENABLE(FULLSCREEN_API)
static bool isDocumentRunningFullScreenAnimation(Document* document)
{
return document->webkitIsFullScreen() && document->fullScreenRenderer() && document->isAnimatingFullScreen();
}
#endif
-
-#if USE(ACCELERATED_COMPOSITING)
+
void FrameView::updateCompositingLayers()
{
RenderView* root = rootRenderer(this);
@@ -720,7 +715,7 @@ GraphicsLayer* FrameView::layerForScrollCorner() const
return root->compositor()->layerForScrollCorner();
}
-#if PLATFORM(CHROMIUM) && ENABLE(RUBBER_BANDING)
+#if ENABLE(RUBBER_BANDING)
GraphicsLayer* FrameView::layerForOverhangAreas() const
{
RenderView* root = rootRenderer(this);
@@ -746,7 +741,7 @@ bool FrameView::syncCompositingStateForThisFrame(Frame* rootFrameForSync)
root->compositor()->flushPendingLayerChanges(rootFrameForSync == m_frame);
#if ENABLE(FULLSCREEN_API)
- // The fullScreenRenderer's graphicsLayer has been re-parented, and the above recursive syncCompositingState
+ // The fullScreenRenderer's graphicsLayer has been re-parented, and the above recursive syncCompositingState
// call will not cause the subtree under it to repaint. Explicitly call the syncCompositingState on
// the fullScreenRenderer's graphicsLayer here:
Document* document = m_frame->document();
@@ -901,9 +896,6 @@ static inline void collectFrameViewChildren(FrameView* frameView, Vector<RefPtr<
inline void FrameView::forceLayoutParentViewIfNeeded()
{
#if ENABLE(SVG)
- if (m_inLayoutParentView)
- return;
-
RenderPart* ownerRenderer = m_frame->ownerRenderer();
if (!ownerRenderer || !ownerRenderer->frame())
return;
@@ -913,28 +905,22 @@ inline void FrameView::forceLayoutParentViewIfNeeded()
return;
RenderSVGRoot* svgRoot = toRenderSVGRoot(contentBox);
- if (!svgRoot->needsSizeNegotiationWithHostDocument())
+ if (svgRoot->everHadLayout() && !svgRoot->needsLayout())
return;
- ASSERT(!m_inLayoutParentView);
- TemporaryChange<bool> resetInLayoutParentView(m_inLayoutParentView, true);
-
- // Clear needs-size-negotiation flag in RenderSVGRoot, so the next call to our
- // layout() method won't fire the size negotiation logic again.
- svgRoot->scheduledSizeNegotiationWithHostDocument();
- ASSERT(!svgRoot->needsSizeNegotiationWithHostDocument());
+ // If the embedded SVG document appears the first time, the ownerRenderer has already finished
+ // layout without knowing about the existence of the embedded SVG document, because RenderReplaced
+ // embeddedContentBox() returns 0, as long as the embedded document isn't loaded yet. Before
+ // bothering to lay out the SVG document, mark the ownerRenderer needing layout and ask its
+ // FrameView for a layout. After that the RenderEmbeddedObject (ownerRenderer) carries the
+ // correct size, which RenderSVGRoot::computeReplacedLogicalWidth/Height rely on, when laying
+ // out for the first time, or when the RenderSVGRoot size has changed dynamically (eg. via <script>).
+ RefPtr<FrameView> frameView = ownerRenderer->frame()->view();
// Mark the owner renderer as needing layout.
ownerRenderer->setNeedsLayoutAndPrefWidthsRecalc();
- // Immediately relayout the child widgets, which can now calculate the SVG documents
- // intrinsic size, negotiating with the parent object/embed/iframe.
- RenderView* rootView = ownerRenderer->frame()->contentRenderer();
- ASSERT(rootView);
- rootView->updateWidgetPositions();
-
// Synchronously enter layout, to layout the view containing the host object/embed/iframe.
- FrameView* frameView = ownerRenderer->frame()->view();
ASSERT(frameView);
frameView->layout();
#endif
@@ -994,11 +980,10 @@ void FrameView::layout(bool allowSubtree)
{
TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);
- if (!m_nestedLayoutCount && !m_inSynchronousPostLayout && m_hasPendingPostLayoutTasks && !inSubframeLayoutWithFrameFlattening) {
+ if (!m_nestedLayoutCount && !m_inSynchronousPostLayout && m_postLayoutTasksTimer.isActive() && !inSubframeLayoutWithFrameFlattening) {
// This is a new top-level layout. If there are any remaining tasks from the previous
// layout, finish them now.
m_inSynchronousPostLayout = true;
- m_postLayoutTasksTimer.stop();
performPostLayoutTasks();
m_inSynchronousPostLayout = false;
}
@@ -1074,7 +1059,7 @@ void FrameView::layout(bool allowSubtree)
m_firstLayout = false;
m_firstLayoutCallbackPending = true;
- m_lastLayoutSize = LayoutSize(width(), height());
+ m_lastLayoutSize = LayoutSize(layoutWidth(), layoutHeight());
m_lastZoomFactor = root->style()->zoom();
// Set the initial vMode to AlwaysOn if we're auto.
@@ -1122,6 +1107,7 @@ void FrameView::layout(bool allowSubtree)
m_inLayout = true;
beginDeferredRepaints();
+ forceLayoutParentViewIfNeeded();
root->layout();
endDeferredRepaints();
m_inLayout = false;
@@ -1170,7 +1156,7 @@ void FrameView::layout(bool allowSubtree)
updateOverflowStatus(layoutWidth() < contentsWidth(),
layoutHeight() < contentsHeight());
- if (!m_hasPendingPostLayoutTasks) {
+ if (!m_postLayoutTasksTimer.isActive()) {
if (!m_inSynchronousPostLayout) {
if (inSubframeLayoutWithFrameFlattening) {
if (RenderView* root = rootRenderer(this))
@@ -1183,12 +1169,11 @@ void FrameView::layout(bool allowSubtree)
}
}
- if (!m_hasPendingPostLayoutTasks && (needsLayout() || m_inSynchronousPostLayout || inSubframeLayoutWithFrameFlattening)) {
+ if (!m_postLayoutTasksTimer.isActive() && (needsLayout() || m_inSynchronousPostLayout || inSubframeLayoutWithFrameFlattening)) {
// If we need layout or are already in a synchronous call to postLayoutTasks(),
// defer widget updates and event dispatch until after we return. postLayoutTasks()
// can make us need to update again, and we can get stuck in a nasty cycle unless
// we call it through the timer here.
- m_hasPendingPostLayoutTasks = true;
m_postLayoutTasksTimer.startOneShot(0);
if (needsLayout()) {
m_actionScheduler->pause();
@@ -1210,7 +1195,6 @@ void FrameView::layout(bool allowSubtree)
return;
page->chrome()->client()->layoutUpdated(frame());
- forceLayoutParentViewIfNeeded();
}
RenderBox* FrameView::embeddedContentBox() const
@@ -1419,7 +1403,7 @@ int FrameView::scrollXForFixedPosition() const
// When the page is scaled, the scaled "viewport" with respect to which fixed object are positioned
// doesn't move as fast as the content view, so that when the content is scrolled all the way to the
// end, the bottom of the scaled "viewport" touches the bottom of the real viewport.
- float dragFactor = shouldLayoutFixedElementsRelativeToFrame() ? 1 : (contentsWidth() - visibleContentWidth * frameScaleFactor) / maxX;
+ float dragFactor = fixedElementsLayoutRelativeToFrame() ? 1 : (contentsWidth() - visibleContentWidth * frameScaleFactor) / maxX;
return x * dragFactor / frameScaleFactor;
}
@@ -1450,7 +1434,7 @@ int FrameView::scrollYForFixedPosition() const
return y;
float frameScaleFactor = m_frame->frameScaleFactor();
- float dragFactor = shouldLayoutFixedElementsRelativeToFrame() ? 1 : (contentsHeight() - visibleContentHeight * frameScaleFactor) / maxY;
+ float dragFactor = fixedElementsLayoutRelativeToFrame() ? 1 : (contentsHeight() - visibleContentHeight * frameScaleFactor) / maxY;
return y * dragFactor / frameScaleFactor;
}
@@ -1459,18 +1443,15 @@ IntSize FrameView::scrollOffsetForFixedPosition() const
return IntSize(scrollXForFixedPosition(), scrollYForFixedPosition());
}
-void FrameView::setShouldLayoutFixedElementsRelativeToFrame(bool shouldLayoutFixedElementsRelativeToFrame)
+bool FrameView::fixedElementsLayoutRelativeToFrame() const
{
- if (shouldLayoutFixedElementsRelativeToFrame == m_shouldLayoutFixedElementsRelativeToFrame)
- return;
-
- m_shouldLayoutFixedElementsRelativeToFrame = shouldLayoutFixedElementsRelativeToFrame;
-
- if (!hasFixedObjects())
- return;
+ ASSERT(m_frame);
+ if (!m_frame->settings())
+ return false;
- setNeedsLayout();
+ return m_frame->settings()->fixedElementsLayoutRelativeToFrame();
}
+
IntPoint FrameView::currentMousePosition() const
{
return m_frame ? m_frame->eventHandler()->currentMousePosition() : IntPoint();
@@ -1717,6 +1698,14 @@ void FrameView::setScrollPosition(const IntPoint& scrollPoint)
ScrollView::setScrollPosition(scrollPoint);
}
+void FrameView::delegatesScrollingDidChange()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ // When we switch to delgatesScrolling mode, we should destroy the scrolling/clipping layers in RenderLayerCompositor.
+ clearBackingStores();
+#endif
+}
+
void FrameView::setFixedVisibleContentRect(const IntRect& visibleContentRect)
{
IntSize offset = scrollOffset();
@@ -1740,7 +1729,7 @@ void FrameView::scrollPositionChanged()
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* root = rootRenderer(this)) {
if (root->usesCompositing())
- root->compositor()->frameViewDidScroll(scrollPosition());
+ root->compositor()->frameViewDidScroll();
}
#endif
}
@@ -2093,8 +2082,6 @@ void FrameView::setNeedsLayout()
void FrameView::unscheduleRelayout()
{
- m_postLayoutTasksTimer.stop();
-
if (!m_layoutTimer.isActive())
return;
@@ -2276,16 +2263,15 @@ bool FrameView::updateWidgets()
void FrameView::flushAnyPendingPostLayoutTasks()
{
- if (!m_hasPendingPostLayoutTasks)
+ if (!m_postLayoutTasksTimer.isActive())
return;
- m_postLayoutTasksTimer.stop();
performPostLayoutTasks();
}
void FrameView::performPostLayoutTasks()
{
- m_hasPendingPostLayoutTasks = false;
+ m_postLayoutTasksTimer.stop();
m_frame->selection()->setCaretRectNeedsUpdate();
m_frame->selection()->updateAppearance();
@@ -2294,6 +2280,8 @@ void FrameView::performPostLayoutTasks()
if (m_firstLayoutCallbackPending) {
m_firstLayoutCallbackPending = false;
m_frame->loader()->didFirstLayout();
+ if (Page* page = m_frame->page())
+ page->startCountingRelevantRepaintedObjects();
}
// Ensure that we always send this eventually.
@@ -2322,7 +2310,7 @@ void FrameView::performPostLayoutTasks()
m_actionScheduler->resume();
if (!root->printing()) {
- LayoutSize currentSize = LayoutSize(width(), height());
+ LayoutSize currentSize = LayoutSize(layoutWidth(), layoutHeight());
float currentZoomFactor = root->style()->zoom();
bool resized = !m_firstLayout && (currentSize != m_lastLayoutSize || currentZoomFactor != m_lastZoomFactor);
m_lastLayoutSize = currentSize;
@@ -2866,7 +2854,7 @@ void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
FontCachePurgePreventer fontCachePurgePreventer;
#if USE(ACCELERATED_COMPOSITING)
- if (!p->paintingDisabled())
+ if (!p->paintingDisabled() && !document->printing())
syncCompositingStateForThisFrame(m_frame.get());
#endif