OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2009 Google Inc. All rights reserved. | 7 * Copyright (C) 2009 Google Inc. All rights reserved. |
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 if (LayoutFlowThread* flowThread = layoutState->flowThread()) | 668 if (LayoutFlowThread* flowThread = layoutState->flowThread()) |
669 return flowThread; | 669 return flowThread; |
670 } | 670 } |
671 | 671 |
672 // Not in the middle of layout so have to find the thread the slow way. | 672 // Not in the middle of layout so have to find the thread the slow way. |
673 return LayoutFlowThread::locateFlowThreadContainingBlockOf(*this); | 673 return LayoutFlowThread::locateFlowThreadContainingBlockOf(*this); |
674 } | 674 } |
675 | 675 |
676 bool LayoutObject::skipInvalidationWhenLaidOutChildren() const | 676 bool LayoutObject::skipInvalidationWhenLaidOutChildren() const |
677 { | 677 { |
678 if (!neededLayoutBecauseOfChildren()) | 678 if (!m_bitfields.neededLayoutBecauseOfChildren()) |
679 return false; | 679 return false; |
680 | 680 |
681 // SVG layoutObjects need to be invalidated when their children are laid out
. | 681 // SVG layoutObjects need to be invalidated when their children are laid out
. |
682 // LayoutBlocks with line boxes are responsible to invalidate them so we can
't ignore them. | 682 // LayoutBlocks with line boxes are responsible to invalidate them so we can
't ignore them. |
683 if (isSVG() || (isLayoutBlockFlow() && toLayoutBlockFlow(this)->firstLineBox
())) | 683 if (isSVG() || (isLayoutBlockFlow() && toLayoutBlockFlow(this)->firstLineBox
())) |
684 return false; | 684 return false; |
685 | 685 |
686 // In case scrollbars got repositioned (which will typically happen if the l
ayout object got | 686 // In case scrollbars got repositioned (which will typically happen if the l
ayout object got |
687 // resized), we cannot skip invalidation. | 687 // resized), we cannot skip invalidation. |
688 if (hasNonCompositedScrollbars()) | 688 if (hasNonCompositedScrollbars()) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 return; | 749 return; |
750 if (!last->isTextOrSVGChild() && last->style()->hasOutOfFlowPosition())
{ | 750 if (!last->isTextOrSVGChild() && last->style()->hasOutOfFlowPosition())
{ |
751 bool willSkipRelativelyPositionedInlines = !object->isLayoutBlock()
|| object->isAnonymousBlock(); | 751 bool willSkipRelativelyPositionedInlines = !object->isLayoutBlock()
|| object->isAnonymousBlock(); |
752 // Skip relatively positioned inlines and anonymous blocks to get to
the enclosing LayoutBlock. | 752 // Skip relatively positioned inlines and anonymous blocks to get to
the enclosing LayoutBlock. |
753 while (object && (!object->isLayoutBlock() || object->isAnonymousBlo
ck())) | 753 while (object && (!object->isLayoutBlock() || object->isAnonymousBlo
ck())) |
754 object = object->container(); | 754 object = object->container(); |
755 if (!object || object->posChildNeedsLayout()) | 755 if (!object || object->posChildNeedsLayout()) |
756 return; | 756 return; |
757 if (willSkipRelativelyPositionedInlines) | 757 if (willSkipRelativelyPositionedInlines) |
758 container = object->container(); | 758 container = object->container(); |
759 object->setPosChildNeedsLayout(true); | 759 object->m_bitfields.setPosChildNeedsLayout(true); |
760 simplifiedNormalFlowLayout = true; | 760 simplifiedNormalFlowLayout = true; |
761 ASSERT(!object->isSetNeedsLayoutForbidden()); | 761 ASSERT(!object->isSetNeedsLayoutForbidden()); |
762 } else if (simplifiedNormalFlowLayout) { | 762 } else if (simplifiedNormalFlowLayout) { |
763 if (object->needsSimplifiedNormalFlowLayout()) | 763 if (object->needsSimplifiedNormalFlowLayout()) |
764 return; | 764 return; |
765 object->setNeedsSimplifiedNormalFlowLayout(true); | 765 object->m_bitfields.setNeedsSimplifiedNormalFlowLayout(true); |
766 ASSERT(!object->isSetNeedsLayoutForbidden()); | 766 ASSERT(!object->isSetNeedsLayoutForbidden()); |
767 } else { | 767 } else { |
768 if (object->normalChildNeedsLayout()) | 768 if (object->normalChildNeedsLayout()) |
769 return; | 769 return; |
770 object->setNormalChildNeedsLayout(true); | 770 object->m_bitfields.setNormalChildNeedsLayout(true); |
771 ASSERT(!object->isSetNeedsLayoutForbidden()); | 771 ASSERT(!object->isSetNeedsLayoutForbidden()); |
772 } | 772 } |
773 | 773 |
774 if (layouter) { | 774 if (layouter) { |
775 layouter->recordObjectMarkedForLayout(object); | 775 layouter->recordObjectMarkedForLayout(object); |
776 if (object == layouter->root()) | 776 if (object == layouter->root()) |
777 return; | 777 return; |
778 } | 778 } |
779 | 779 |
780 last = object; | 780 last = object; |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 return; | 1341 return; |
1342 selectionPaintInvalidationMap = new SelectionPaintInvalidationMap(); | 1342 selectionPaintInvalidationMap = new SelectionPaintInvalidationMap(); |
1343 } | 1343 } |
1344 | 1344 |
1345 if (selectionRect.isEmpty()) | 1345 if (selectionRect.isEmpty()) |
1346 selectionPaintInvalidationMap->remove(this); | 1346 selectionPaintInvalidationMap->remove(this); |
1347 else | 1347 else |
1348 selectionPaintInvalidationMap->set(this, selectionRect); | 1348 selectionPaintInvalidationMap->set(this, selectionRect); |
1349 } | 1349 } |
1350 | 1350 |
| 1351 // TODO: Remove this for slimming paint v2 because we don't care about paint inv
alidation rects. |
1351 inline void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject
& paintInvalidationContainer, PaintInvalidationReason invalidationReason) | 1352 inline void LayoutObject::invalidateSelectionIfNeeded(const LayoutBoxModelObject
& paintInvalidationContainer, PaintInvalidationReason invalidationReason) |
1352 { | 1353 { |
1353 // Update selection rect when we are doing full invalidation (in case that t
he object is moved, composite status changed, etc.) | 1354 // Update selection rect when we are doing full invalidation (in case that t
he object is moved, composite status changed, etc.) |
1354 // or shouldInvalidationSelection is set (in case that the selection itself
changed). | 1355 // or shouldInvalidationSelection is set (in case that the selection itself
changed). |
1355 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI
nvalidationReason(invalidationReason); | 1356 bool fullInvalidation = view()->doingFullPaintInvalidation() || isFullPaintI
nvalidationReason(invalidationReason); |
1356 if (!fullInvalidation && !shouldInvalidateSelection()) | 1357 if (!fullInvalidation && !shouldInvalidateSelection()) |
1357 return; | 1358 return; |
1358 | 1359 |
1359 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); | 1360 LayoutRect oldSelectionRect = previousSelectionRectForPaintInvalidation(); |
1360 LayoutRect newSelectionRect = selectionRectForPaintInvalidation(&paintInvali
dationContainer); | 1361 LayoutRect newSelectionRect = selectionRectForPaintInvalidation(&paintInvali
dationContainer); |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 // TODO(rune@opera.com): We should use the diff to determine whether a r
epaint vs. layout | 1822 // TODO(rune@opera.com): We should use the diff to determine whether a r
epaint vs. layout |
1822 // is needed, but for now just assume a layout will be required. The dif
f code | 1823 // is needed, but for now just assume a layout will be required. The dif
f code |
1823 // in LayoutObject::setStyle would need to be factored out so that it co
uld be reused. | 1824 // in LayoutObject::setStyle would need to be factored out so that it co
uld be reused. |
1824 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalida
tionReason::StyleChange); | 1825 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalida
tionReason::StyleChange); |
1825 } | 1826 } |
1826 } | 1827 } |
1827 | 1828 |
1828 void LayoutObject::markContainingBlocksForOverflowRecalc() | 1829 void LayoutObject::markContainingBlocksForOverflowRecalc() |
1829 { | 1830 { |
1830 for (LayoutBlock* container = containingBlock(); container && !container->ch
ildNeedsOverflowRecalcAfterStyleChange(); container = container->containingBlock
()) | 1831 for (LayoutBlock* container = containingBlock(); container && !container->ch
ildNeedsOverflowRecalcAfterStyleChange(); container = container->containingBlock
()) |
1831 container->setChildNeedsOverflowRecalcAfterStyleChange(true); | 1832 container->m_bitfields.setChildNeedsOverflowRecalcAfterStyleChange(true)
; |
1832 } | 1833 } |
1833 | 1834 |
1834 void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() | 1835 void LayoutObject::setNeedsOverflowRecalcAfterStyleChange() |
1835 { | 1836 { |
1836 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); | 1837 bool neededRecalc = needsOverflowRecalcAfterStyleChange(); |
1837 setSelfNeedsOverflowRecalcAfterStyleChange(true); | 1838 m_bitfields.setSelfNeedsOverflowRecalcAfterStyleChange(true); |
1838 if (!neededRecalc) | 1839 if (!neededRecalc) |
1839 markContainingBlocksForOverflowRecalc(); | 1840 markContainingBlocksForOverflowRecalc(); |
1840 } | 1841 } |
1841 | 1842 |
1842 void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) | 1843 void LayoutObject::setStyle(PassRefPtr<ComputedStyle> style) |
1843 { | 1844 { |
1844 ASSERT(style); | 1845 ASSERT(style); |
1845 | 1846 |
1846 if (m_style == style) { | 1847 if (m_style == style) { |
1847 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so | 1848 // We need to run through adjustStyleDifference() for iframes, plugins,
and canvas so |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2661 } | 2662 } |
2662 | 2663 |
2663 PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&) | 2664 PositionWithAffinity LayoutObject::positionForPoint(const LayoutPoint&) |
2664 { | 2665 { |
2665 return createPositionWithAffinity(caretMinOffset()); | 2666 return createPositionWithAffinity(caretMinOffset()); |
2666 } | 2667 } |
2667 | 2668 |
2668 void LayoutObject::updateDragState(bool dragOn) | 2669 void LayoutObject::updateDragState(bool dragOn) |
2669 { | 2670 { |
2670 bool valueChanged = (dragOn != isDragging()); | 2671 bool valueChanged = (dragOn != isDragging()); |
2671 setIsDragging(dragOn); | 2672 m_bitfields.setIsDragging(dragOn); |
2672 if (valueChanged && node()) { | 2673 if (valueChanged && node()) { |
2673 if (node()->isElementNode() && toElement(node())->childrenOrSiblingsAffe
ctedByDrag()) | 2674 if (node()->isElementNode() && toElement(node())->childrenOrSiblingsAffe
ctedByDrag()) |
2674 node()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor
Tracing::create(StyleChangeReason::Drag)); | 2675 node()->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFor
Tracing::create(StyleChangeReason::Drag)); |
2675 else if (style()->affectedByDrag()) | 2676 else if (style()->affectedByDrag()) |
2676 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr
acing::create(StyleChangeReason::Drag)); | 2677 node()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTr
acing::create(StyleChangeReason::Drag)); |
2677 } | 2678 } |
2678 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) | 2679 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextSibling()
) |
2679 curr->updateDragState(dragOn); | 2680 curr->updateDragState(dragOn); |
2680 } | 2681 } |
2681 | 2682 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 if (LayoutView* layoutView = view()) { | 2747 if (LayoutView* layoutView = view()) { |
2747 if (FrameView* frameView = layoutView->frameView()) | 2748 if (FrameView* frameView = layoutView->frameView()) |
2748 frameView->scheduleRelayoutOfSubtree(this); | 2749 frameView->scheduleRelayoutOfSubtree(this); |
2749 } | 2750 } |
2750 } | 2751 } |
2751 } | 2752 } |
2752 } | 2753 } |
2753 | 2754 |
2754 void LayoutObject::forceLayout() | 2755 void LayoutObject::forceLayout() |
2755 { | 2756 { |
2756 setSelfNeedsLayout(true); | 2757 m_bitfields.setSelfNeedsLayout(true); |
2757 setShouldDoFullPaintInvalidation(); | 2758 setShouldDoFullPaintInvalidation(); |
2758 layout(); | 2759 layout(); |
2759 } | 2760 } |
2760 | 2761 |
2761 // FIXME: Does this do anything different than forceLayout given that we don't w
alk | 2762 // FIXME: Does this do anything different than forceLayout given that we don't w
alk |
2762 // the containing block chain. If not, we should change all callers to use force
Layout. | 2763 // the containing block chain. If not, we should change all callers to use force
Layout. |
2763 void LayoutObject::forceChildLayout() | 2764 void LayoutObject::forceChildLayout() |
2764 { | 2765 { |
2765 setNormalChildNeedsLayout(true); | 2766 m_bitfields.setNormalChildNeedsLayout(true); |
2766 layout(); | 2767 layout(); |
2767 } | 2768 } |
2768 | 2769 |
2769 enum StyleCacheState { | 2770 enum StyleCacheState { |
2770 Cached, | 2771 Cached, |
2771 Uncached | 2772 Uncached |
2772 }; | 2773 }; |
2773 | 2774 |
2774 static PassRefPtr<ComputedStyle> firstLineStyleForCachedUncachedType(StyleCacheS
tate type, const LayoutObject* layoutObject, ComputedStyle* style) | 2775 static PassRefPtr<ComputedStyle> firstLineStyleForCachedUncachedType(StyleCacheS
tate type, const LayoutObject* layoutObject, ComputedStyle* style) |
2775 { | 2776 { |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3193 case DocumentLifecycle::InCompositingUpdate: | 3194 case DocumentLifecycle::InCompositingUpdate: |
3194 return PaintInvalidationCompositingUpdate; | 3195 return PaintInvalidationCompositingUpdate; |
3195 default: | 3196 default: |
3196 return PaintInvalidationFull; | 3197 return PaintInvalidationFull; |
3197 } | 3198 } |
3198 } | 3199 } |
3199 | 3200 |
3200 inline void LayoutObject::markContainerChainForPaintInvalidation() | 3201 inline void LayoutObject::markContainerChainForPaintInvalidation() |
3201 { | 3202 { |
3202 for (LayoutObject* container = this->containerCrossingFrameBoundaries(); con
tainer && !container->shouldCheckForPaintInvalidationRegardlessOfPaintInvalidati
onState(); container = container->containerCrossingFrameBoundaries()) | 3203 for (LayoutObject* container = this->containerCrossingFrameBoundaries(); con
tainer && !container->shouldCheckForPaintInvalidationRegardlessOfPaintInvalidati
onState(); container = container->containerCrossingFrameBoundaries()) |
3203 container->setSelfMayNeedPaintInvalidation(); | 3204 container->m_bitfields.setChildShouldCheckForPaintInvalidation(true); |
3204 } | |
3205 | |
3206 void LayoutObject::setLayoutDidGetCalledSinceLastFrame() | |
3207 { | |
3208 m_bitfields.setLayoutDidGetCalledSinceLastFrame(true); | |
3209 | |
3210 // Make sure our parent is marked as needing invalidation. | |
3211 // This would be unneeded if we allowed sub-tree invalidation (akin to sub-t
ree layouts). | |
3212 markContainerChainForPaintInvalidation(); | |
3213 } | 3205 } |
3214 | 3206 |
3215 void LayoutObject::setShouldInvalidateSelection() | 3207 void LayoutObject::setShouldInvalidateSelection() |
3216 { | 3208 { |
3217 if (!canUpdateSelectionOnRootLineBoxes()) | 3209 if (!canUpdateSelectionOnRootLineBoxes()) |
3218 return; | 3210 return; |
3219 | 3211 |
3220 m_bitfields.setShouldInvalidateSelection(true); | 3212 m_bitfields.setShouldInvalidateSelection(true); |
3221 markContainerChainForPaintInvalidation(); | 3213 markContainerChainForPaintInvalidation(); |
3222 } | 3214 } |
(...skipping 16 matching lines...) Expand all Loading... |
3239 frame()->page()->animator().scheduleVisualUpdate(); // In case that this
is called outside of FrameView::updateLayoutAndStyleForPainting(). | 3231 frame()->page()->animator().scheduleVisualUpdate(); // In case that this
is called outside of FrameView::updateLayoutAndStyleForPainting(). |
3240 markContainerChainForPaintInvalidation(); | 3232 markContainerChainForPaintInvalidation(); |
3241 } | 3233 } |
3242 } | 3234 } |
3243 | 3235 |
3244 void LayoutObject::setMayNeedPaintInvalidation() | 3236 void LayoutObject::setMayNeedPaintInvalidation() |
3245 { | 3237 { |
3246 if (mayNeedPaintInvalidation()) | 3238 if (mayNeedPaintInvalidation()) |
3247 return; | 3239 return; |
3248 m_bitfields.setMayNeedPaintInvalidation(true); | 3240 m_bitfields.setMayNeedPaintInvalidation(true); |
3249 // Make sure our parent is marked as needing invalidation. | |
3250 markContainerChainForPaintInvalidation(); | 3241 markContainerChainForPaintInvalidation(); |
3251 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is
called outside of FrameView::updateLayoutAndStyleForPainting(). | 3242 frame()->page()->animator().scheduleVisualUpdate(); // In case that this is
called outside of FrameView::updateLayoutAndStyleForPainting(). |
3252 } | 3243 } |
3253 | 3244 |
3254 void LayoutObject::clearMayNeedPaintInvalidation() | |
3255 { | |
3256 m_bitfields.setMayNeedPaintInvalidation(false); | |
3257 } | |
3258 | |
3259 void LayoutObject::setSelfMayNeedPaintInvalidation() | |
3260 { | |
3261 m_bitfields.setMayNeedPaintInvalidation(true); | |
3262 } | |
3263 | |
3264 void LayoutObject::clearPaintInvalidationState(const PaintInvalidationState& pai
ntInvalidationState) | 3245 void LayoutObject::clearPaintInvalidationState(const PaintInvalidationState& pai
ntInvalidationState) |
3265 { | 3246 { |
3266 // paintInvalidationStateIsDirty should be kept in sync with the | 3247 // paintInvalidationStateIsDirty should be kept in sync with the |
3267 // booleans that are cleared below. | 3248 // booleans that are cleared below. |
3268 ASSERT(paintInvalidationState.ancestorHadPaintInvalidationForLocationChange(
) || paintInvalidationStateIsDirty()); | 3249 ASSERT(paintInvalidationState.ancestorHadPaintInvalidationForLocationChange(
) || paintInvalidationStateIsDirty()); |
3269 clearShouldDoFullPaintInvalidation(); | 3250 clearShouldDoFullPaintInvalidation(); |
3270 setNeededLayoutBecauseOfChildren(false); | 3251 m_bitfields.setChildShouldCheckForPaintInvalidation(false); |
3271 setShouldInvalidateOverflowForPaint(false); | 3252 m_bitfields.setNeededLayoutBecauseOfChildren(false); |
3272 clearLayoutDidGetCalledSinceLastFrame(); | 3253 m_bitfields.setShouldInvalidateOverflowForPaint(false); |
3273 clearMayNeedPaintInvalidation(); | 3254 m_bitfields.setMayNeedPaintInvalidation(false); |
3274 clearShouldInvalidateSelection(); | 3255 m_bitfields.setShouldInvalidateSelection(false); |
3275 } | 3256 } |
3276 | 3257 |
3277 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) | 3258 bool LayoutObject::isAllowedToModifyLayoutTreeStructure(Document& document) |
3278 { | 3259 { |
3279 return DeprecatedDisableModifyLayoutTreeStructureAsserts::canModifyLayoutTre
eStateInAnyState() | 3260 return DeprecatedDisableModifyLayoutTreeStructureAsserts::canModifyLayoutTre
eStateInAnyState() |
3280 || document.lifecycle().stateAllowsLayoutTreeMutations(); | 3261 || document.lifecycle().stateAllowsLayoutTreeMutations(); |
3281 } | 3262 } |
3282 | 3263 |
3283 DeprecatedDisableModifyLayoutTreeStructureAsserts::DeprecatedDisableModifyLayout
TreeStructureAsserts() | 3264 DeprecatedDisableModifyLayoutTreeStructureAsserts::DeprecatedDisableModifyLayout
TreeStructureAsserts() |
3284 : m_disabler(gModifyLayoutTreeStructureAnyState, true) | 3265 : m_disabler(gModifyLayoutTreeStructureAnyState, true) |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3470 const blink::LayoutObject* root = object1; | 3451 const blink::LayoutObject* root = object1; |
3471 while (root->parent()) | 3452 while (root->parent()) |
3472 root = root->parent(); | 3453 root = root->parent(); |
3473 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); | 3454 root->showLayoutTreeAndMark(object1, "*", object2, "-", 0); |
3474 } else { | 3455 } else { |
3475 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); | 3456 fprintf(stderr, "Cannot showLayoutTree. Root is (nil)\n"); |
3476 } | 3457 } |
3477 } | 3458 } |
3478 | 3459 |
3479 #endif | 3460 #endif |
OLD | NEW |