Index: third_party/WebKit/Source/core/layout/LayoutView.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutView.cpp b/third_party/WebKit/Source/core/layout/LayoutView.cpp |
index 85cd4f445d7abd9da650f2e4040ee14b8b7f9bd4..f7e4dbfcb46e5e025a097139331250fe6cbfb470 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutView.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutView.cpp |
@@ -1,6 +1,7 @@ |
/* |
* Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
+ * All rights reserved. |
* |
* This library is free software; you can redistribute it and/or |
* modify it under the terms of the GNU Library General Public |
@@ -110,12 +111,14 @@ LayoutView::LayoutView(Document* document) |
LayoutView::~LayoutView() {} |
bool LayoutView::hitTest(HitTestResult& result) { |
- // We have to recursively update layout/style here because otherwise, when the hit test recurses |
- // into a child document, it could trigger a layout on the parent document, which can destroy PaintLayer |
- // that are higher up in the call stack, leading to crashes. |
+ // We have to recursively update layout/style here because otherwise, when the |
+ // hit test recurses into a child document, it could trigger a layout on the |
+ // parent document, which can destroy PaintLayer that are higher up in the |
+ // call stack, leading to crashes. |
// Note that Document::updateLayout calls its parent's updateLayout. |
- // Note that if an iframe has its render pipeline throttled, it will not update layout here, |
- // and it will also not propagate the hit test into the iframe's inner document. |
+ // Note that if an iframe has its render pipeline throttled, it will not |
+ // update layout here, and it will also not propagate the hit test into the |
+ // iframe's inner document. |
frameView()->updateLifecycleToCompositingCleanPlusScrolling(); |
HitTestLatencyRecorder hitTestLatencyRecorder( |
result.hitTestRequest().allowsChildFrameContent()); |
@@ -141,9 +144,11 @@ bool LayoutView::hitTestNoLifecycleUpdate(HitTestResult& result) { |
} else { |
hitLayer = layer()->hitTest(result); |
- // FrameView scrollbars are not the same as Layer scrollbars tested by Layer::hitTestOverflowControls, |
- // so we need to test FrameView scrollbars separately here. Note that it's important we do this after |
- // the hit test above, because that may overwrite the entire HitTestResult when it finds a hit. |
+ // FrameView scrollbars are not the same as Layer scrollbars tested by |
+ // Layer::hitTestOverflowControls, so we need to test FrameView scrollbars |
+ // separately here. Note that it's important we do this after the hit test |
+ // above, because that may overwrite the entire HitTestResult when it finds |
+ // a hit. |
IntPoint framePoint = |
frameView()->contentsToFrame(result.hitTestLocation().roundedPoint()); |
if (Scrollbar* frameScrollbar = |
@@ -201,10 +206,11 @@ void LayoutView::checkLayoutState() { |
#endif |
void LayoutView::setShouldDoFullPaintInvalidationOnResizeIfNeeded() { |
- // When background-attachment is 'fixed', we treat the viewport (instead of the 'root' |
- // i.e. html or body) as the background positioning area, and we should fully invalidate |
- // on viewport resize if the background image is not composited and needs full paint |
- // invalidation on background positioning area resize. |
+ // When background-attachment is 'fixed', we treat the viewport (instead of |
+ // the 'root' i.e. html or body) as the background positioning area, and we |
+ // should fully invalidate on viewport resize if the background image is not |
+ // composited and needs full paint invalidation on background positioning area |
+ // resize. |
if (style()->hasFixedBackgroundImage() && |
(!m_compositor || |
!m_compositor->needsFixedRootBackgroundLayer(layer()))) { |
@@ -239,7 +245,8 @@ void LayoutView::layout() { |
LayoutRect oldLayoutOverflowRect = layoutOverflowRect(); |
- // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account. |
+ // Use calcWidth/Height to get the new width/height, since this will take the |
+ // full page zoom factor into account. |
bool relayoutChildren = |
!shouldUsePrintingLayout() && |
(!m_frameView || logicalWidth() != viewLogicalWidthForBoxSizing() || |
@@ -276,9 +283,10 @@ void LayoutView::layout() { |
layoutContent(); |
if (layoutOverflowRect() != oldLayoutOverflowRect) { |
- // The document element paints the viewport background, so we need to invalidate it when |
- // layout overflow changes. |
- // FIXME: Improve viewport background styling/invalidation/painting. crbug.com/475115 |
+ // The document element paints the viewport background, so we need to |
+ // invalidate it when layout overflow changes. |
+ // FIXME: Improve viewport background styling/invalidation/painting. |
+ // crbug.com/475115 |
if (Element* documentElement = document().documentElement()) { |
if (LayoutObject* rootObject = documentElement->layoutObject()) |
rootObject->setShouldDoFullPaintInvalidation(); |
@@ -308,8 +316,9 @@ LayoutRect LayoutView::visualOverflowRect() const { |
} |
LayoutRect LayoutView::localOverflowRectForPaintInvalidation() const { |
- // TODO(wangxianzhu): This is only required without rootLayerScrolls (though it is also correct |
- // but unnecessary with rootLayerScrolls) because of the special LayoutView overflow model. |
+ // TODO(wangxianzhu): This is only required without rootLayerScrolls (though |
+ // it is also correct but unnecessary with rootLayerScrolls) because of the |
+ // special LayoutView overflow model. |
return visualOverflowRect(); |
} |
@@ -397,7 +406,8 @@ void LayoutView::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, |
if (mode & TraverseDocumentBoundaries) { |
if (LayoutPart* parentDocLayoutObject = toLayoutPart( |
LayoutAPIShim::layoutObjectFrom(frame()->ownerLayoutItem()))) { |
- // A LayoutView is a containing block for fixed-position elements, so don't carry this state across frames. |
+ // A LayoutView is a containing block for fixed-position elements, so |
+ // don't carry this state across frames. |
parentDocLayoutObject->mapAncestorToLocal(ancestor, transformState, |
mode & ~IsFixed); |
@@ -414,9 +424,10 @@ void LayoutView::mapAncestorToLocal(const LayoutBoxModelObject* ancestor, |
void LayoutView::computeSelfHitTestRects(Vector<LayoutRect>& rects, |
const LayoutPoint&) const { |
- // Record the entire size of the contents of the frame. Note that we don't just |
- // use the viewport size (containing block) here because we want to ensure this includes |
- // all children (so we can avoid walking them explicitly). |
+ // Record the entire size of the contents of the frame. Note that we don't |
+ // just use the viewport size (containing block) here because we want to |
+ // ensure this includes all children (so we can avoid walking them |
+ // explicitly). |
rects.append( |
LayoutRect(LayoutPoint::zero(), LayoutSize(frameView()->contentsSize()))); |
} |
@@ -447,7 +458,8 @@ void LayoutView::setShouldDoFullPaintInvalidationForViewAndAllDescendants() { |
void LayoutView::invalidatePaintForViewAndCompositedLayers() { |
setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); |
- // The only way we know how to hit these ASSERTS below this point is via the Chromium OS login screen. |
+ // The only way we know how to hit these ASSERTS below this point is via the |
+ // Chromium OS login screen. |
DisableCompositingQueryAsserts disabler; |
if (compositor()->inCompositingMode()) |
@@ -495,9 +507,10 @@ bool LayoutView::mapToVisualRectInAncestorSpace( |
// Adjust for scroll offset of the view. |
rect.moveBy(-viewRectangle.location()); |
} |
- // Frames are painted at rounded-int position. Since we cannot efficiently compute the subpixel offset |
- // of painting at this point in a a bottom-up walk, round to the enclosing int rect, which will enclose |
- // the actual visible rect. |
+ // Frames are painted at rounded-int position. Since we cannot efficiently |
+ // compute the subpixel offset of painting at this point in a a bottom-up |
+ // walk, round to the enclosing int rect, which will enclose the actual |
+ // visible rect. |
rect = LayoutRect(enclosingIntRect(rect)); |
// Adjust for frame border. |
@@ -516,8 +529,10 @@ void LayoutView::adjustOffsetForFixedPosition(LayoutRect& rect) const { |
if (hasOverflowClip()) |
rect.move(scrolledContentOffset()); |
- // FIXME: Paint invalidation should happen after scroll updates, so there should be no pending scroll delta. |
- // However, we still have paint invalidation during layout, so we can't ASSERT for now. crbug.com/434950. |
+ // FIXME: Paint invalidation should happen after scroll updates, so there |
+ // should be no pending scroll delta. |
+ // However, we still have paint invalidation during layout, so we can't |
+ // ASSERT for now. crbug.com/434950. |
// ASSERT(m_frameView->pendingScrollDelta().isZero()); |
// If we have a pending scroll, invalidate the previous scroll position. |
if (!m_frameView->pendingScrollDelta().isZero()) |
@@ -569,7 +584,8 @@ IntRect LayoutView::selectionBounds() { |
if ((os->canBeSelectionLeaf() || os == m_selectionStart || |
os == m_selectionEnd) && |
os->getSelectionState() != SelectionNone) { |
- // Blocks are responsible for painting line gaps and margin gaps. They must be examined as well. |
+ // Blocks are responsible for painting line gaps and margin gaps. They |
+ // must be examined as well. |
selRect.unite(selectionRectForLayoutObject(os)); |
const LayoutBlock* cb = os->containingBlock(); |
while (cb && !cb->isLayoutView()) { |
@@ -605,8 +621,9 @@ void LayoutView::invalidatePaintForSelection() { |
} |
} |
-// When exploring the LayoutTree looking for the nodes involved in the Selection, sometimes it's |
-// required to change the traversing direction because the "start" position is below the "end" one. |
+// When exploring the LayoutTree looking for the nodes involved in the |
+// Selection, sometimes it's required to change the traversing direction because |
+// the "start" position is below the "end" one. |
static inline LayoutObject* getNextOrPrevLayoutObjectBasedOnDirection( |
const LayoutObject* o, |
const LayoutObject* stop, |
@@ -635,13 +652,14 @@ void LayoutView::setSelection( |
LayoutObject* end, |
int endPos, |
SelectionPaintInvalidationMode blockPaintInvalidationMode) { |
- // This code makes no assumptions as to if the layout tree is up to date or not |
- // and will not try to update it. Currently clearSelection calls this |
+ // This code makes no assumptions as to if the layout tree is up to date or |
+ // not and will not try to update it. Currently clearSelection calls this |
// (intentionally) without updating the layout tree as it doesn't care. |
// Other callers may want to force recalc style before calling this. |
// Make sure both our start and end objects are defined. |
- // Check www.msnbc.com and try clicking around to find the case where this happened. |
+ // Check www.msnbc.com and try clicking around to find the case where this |
+ // happened. |
if ((start && !end) || (end && !start)) |
return; |
@@ -650,25 +668,29 @@ void LayoutView::setSelection( |
m_selectionEnd == end && m_selectionEndPos == endPos) |
return; |
- // Record the old selected objects. These will be used later |
- // when we compare against the new selected objects. |
+ // Record the old selected objects. These will be used later when we compare |
+ // against the new selected objects. |
int oldStartPos = m_selectionStartPos; |
int oldEndPos = m_selectionEndPos; |
// Objects each have a single selection rect to examine. |
typedef HashMap<LayoutObject*, SelectionState> SelectedObjectMap; |
SelectedObjectMap oldSelectedObjects; |
- // FIXME: |newSelectedObjects| doesn't really need to store the SelectionState, it's just more convenient |
- // to have it use the same data structure as |oldSelectedObjects|. |
+ // FIXME: |newSelectedObjects| doesn't really need to store the |
+ // SelectionState, it's just more convenient to have it use the same data |
+ // structure as |oldSelectedObjects|. |
SelectedObjectMap newSelectedObjects; |
- // Blocks contain selected objects and fill gaps between them, either on the left, right, or in between lines and blocks. |
- // In order to get the paint invalidation rect right, we have to examine left, middle, and right rects individually, since otherwise |
- // the union of those rects might remain the same even when changes have occurred. |
+ // Blocks contain selected objects and fill gaps between them, either on the |
+ // left, right, or in between lines and blocks. |
+ // In order to get the paint invalidation rect right, we have to examine left, |
+ // middle, and right rects individually, since otherwise the union of those |
+ // rects might remain the same even when changes have occurred. |
typedef HashMap<LayoutBlock*, SelectionState> SelectedBlockMap; |
SelectedBlockMap oldSelectedBlocks; |
- // FIXME: |newSelectedBlocks| doesn't really need to store the SelectionState, it's just more convenient |
- // to have it use the same data structure as |oldSelectedBlocks|. |
+ // FIXME: |newSelectedBlocks| doesn't really need to store the SelectionState, |
+ // it's just more convenient to have it use the same data structure as |
+ // |oldSelectedBlocks|. |
SelectedBlockMap newSelectedBlocks; |
LayoutObject* os = m_selectionStart; |
@@ -680,7 +702,8 @@ void LayoutView::setSelection( |
if ((os->canBeSelectionLeaf() || os == m_selectionStart || |
os == m_selectionEnd) && |
os->getSelectionState() != SelectionNone) { |
- // Blocks are responsible for painting line gaps and margin gaps. They must be examined as well. |
+ // Blocks are responsible for painting line gaps and margin gaps. They |
+ // must be examined as well. |
oldSelectedObjects.set(os, os->getSelectionState()); |
if (blockPaintInvalidationMode == PaintInvalidationNewXOROld) { |
LayoutBlock* cb = os->containingBlock(); |
@@ -710,7 +733,8 @@ void LayoutView::setSelection( |
m_selectionEnd = end; |
m_selectionEndPos = endPos; |
- // Update the selection status of all objects between m_selectionStart and m_selectionEnd |
+ // Update the selection status of all objects between m_selectionStart and |
+ // m_selectionEnd |
if (start && start == end) { |
start->setSelectionStateIfNeeded(SelectionBoth); |
} else { |
@@ -729,8 +753,8 @@ void LayoutView::setSelection( |
o = o->nextInPreOrder(); |
} |
- // Now that the selection state has been updated for the new objects, walk them again and |
- // put them in the new objects list. |
+ // Now that the selection state has been updated for the new objects, walk |
+ // them again and put them in the new objects list. |
o = start; |
exploringBackwards = false; |
continueExploring = o && (o != stop); |
@@ -769,7 +793,8 @@ void LayoutView::setSelection( |
} |
} |
- // Any new objects that remain were not found in the old objects dict, and so they need to be updated. |
+ // Any new objects that remain were not found in the old objects dict, and so |
+ // they need to be updated. |
SelectedObjectMap::iterator newObjectsEnd = newSelectedObjects.end(); |
for (SelectedObjectMap::iterator i = newSelectedObjects.begin(); |
i != newObjectsEnd; ++i) |
@@ -788,7 +813,8 @@ void LayoutView::setSelection( |
} |
} |
- // Any new blocks that remain were not found in the old blocks dict, and so they need to be updated. |
+ // Any new blocks that remain were not found in the old blocks dict, and so |
+ // they need to be updated. |
SelectedBlockMap::iterator newBlocksEnd = newSelectedBlocks.end(); |
for (SelectedBlockMap::iterator i = newSelectedBlocks.begin(); |
i != newBlocksEnd; ++i) |
@@ -797,7 +823,8 @@ void LayoutView::setSelection( |
void LayoutView::clearSelection() { |
// For querying Layer::compositingState() |
- // This is correct, since destroying layout objects needs to cause eager paint invalidations. |
+ // This is correct, since destroying layout objects needs to cause eager paint |
+ // invalidations. |
DisableCompositingQueryAsserts disabler; |
setSelection(0, -1, 0, -1, PaintInvalidationNewMinusOld); |
@@ -947,8 +974,9 @@ void LayoutView::setIsInWindow(bool isInWindow) { |
if (m_compositor) |
m_compositor->setIsInWindow(isInWindow); |
#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
- // We don't invalidate layers during Document::detachLayoutTree(), so must clear the should-keep-alive |
- // DisplayItemClients which may be deleted before the layers being subsequence owners. |
+ // We don't invalidate layers during Document::detachLayoutTree(), so must |
+ // clear the should-keep-alive DisplayItemClients which may be deleted before |
+ // the layers being subsequence owners. |
if (!isInWindow && layer()) |
layer()->endShouldKeepAliveAllClientsRecursive(); |
#endif |