| OLD | NEW | 
|     1 /* |     1 /* | 
|     2  * Copyright (C) 2013 Google Inc. All rights reserved. |     2  * Copyright (C) 2013 Google Inc. All rights reserved. | 
|     3  * |     3  * | 
|     4  * Redistribution and use in source and binary forms, with or without |     4  * Redistribution and use in source and binary forms, with or without | 
|     5  * modification, are permitted provided that the following conditions are |     5  * modification, are permitted provided that the following conditions are | 
|     6  * met: |     6  * met: | 
|     7  * |     7  * | 
|     8  *     * Redistributions of source code must retain the above copyright |     8  *     * Redistributions of source code must retain the above copyright | 
|     9  * notice, this list of conditions and the following disclaimer. |     9  * notice, this list of conditions and the following disclaimer. | 
|    10  *     * Redistributions in binary form must reproduce the above |    10  *     * Redistributions in binary form must reproduce the above | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    51 #include "core/paint/PaintLayer.h" |    51 #include "core/paint/PaintLayer.h" | 
|    52 #include "wtf/PtrUtil.h" |    52 #include "wtf/PtrUtil.h" | 
|    53 #include <memory> |    53 #include <memory> | 
|    54  |    54  | 
|    55 namespace blink { |    55 namespace blink { | 
|    56  |    56  | 
|    57 bool LayoutBlockFlow::s_canPropagateFloatIntoSibling = false; |    57 bool LayoutBlockFlow::s_canPropagateFloatIntoSibling = false; | 
|    58  |    58  | 
|    59 struct SameSizeAsLayoutBlockFlow : public LayoutBlock { |    59 struct SameSizeAsLayoutBlockFlow : public LayoutBlock { | 
|    60     LineBoxList lineBoxes; |    60     LineBoxList lineBoxes; | 
|    61     LayoutUnit m_paintInvalidationLogicalTopAndBottom[2]; |  | 
|    62     void* pointers[2]; |    61     void* pointers[2]; | 
|    63 }; |    62 }; | 
|    64  |    63  | 
|    65 static_assert(sizeof(LayoutBlockFlow) == sizeof(SameSizeAsLayoutBlockFlow), "Lay
      outBlockFlow should stay small"); |    64 static_assert(sizeof(LayoutBlockFlow) == sizeof(SameSizeAsLayoutBlockFlow), "Lay
      outBlockFlow should stay small"); | 
|    66  |    65  | 
|    67 struct SameSizeAsMarginInfo { |    66 struct SameSizeAsMarginInfo { | 
|    68     uint16_t bitfields; |    67     uint16_t bitfields; | 
|    69     LayoutUnit margins[2]; |    68     LayoutUnit margins[2]; | 
|    70 }; |    69 }; | 
|    71  |    70  | 
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   390         done = layoutBlockFlow(relayoutChildren, pageLogicalHeight, layoutScope)
      ; |   389         done = layoutBlockFlow(relayoutChildren, pageLogicalHeight, layoutScope)
      ; | 
|   391  |   390  | 
|   392     LayoutView* layoutView = view(); |   391     LayoutView* layoutView = view(); | 
|   393     if (layoutView->layoutState()->pageLogicalHeight()) |   392     if (layoutView->layoutState()->pageLogicalHeight()) | 
|   394         setPageLogicalOffset(layoutView->layoutState()->pageLogicalOffset(*this,
       logicalTop())); |   393         setPageLogicalOffset(layoutView->layoutState()->pageLogicalOffset(*this,
       logicalTop())); | 
|   395  |   394  | 
|   396     updateLayerTransformAfterLayout(); |   395     updateLayerTransformAfterLayout(); | 
|   397  |   396  | 
|   398     updateAfterLayout(); |   397     updateAfterLayout(); | 
|   399  |   398  | 
|   400     if (m_paintInvalidationLogicalTop != m_paintInvalidationLogicalBottom) { |  | 
|   401         bool hasVisibleContent = style()->visibility() == VISIBLE; |  | 
|   402         if (!hasVisibleContent) { |  | 
|   403             PaintLayer* layer = enclosingLayer(); |  | 
|   404             layer->updateDescendantDependentFlags(); |  | 
|   405             hasVisibleContent = layer->hasVisibleContent(); |  | 
|   406         } |  | 
|   407         if (hasVisibleContent) |  | 
|   408             setShouldInvalidateOverflowForPaint(); |  | 
|   409     } |  | 
|   410  |  | 
|   411     if (isHTMLDialogElement(node()) && isOutOfFlowPositioned()) |   399     if (isHTMLDialogElement(node()) && isOutOfFlowPositioned()) | 
|   412         positionDialog(); |   400         positionDialog(); | 
|   413  |   401  | 
|   414     clearNeedsLayout(); |   402     clearNeedsLayout(); | 
|   415     m_isSelfCollapsing = checkIfIsSelfCollapsingBlock(); |   403     m_isSelfCollapsing = checkIfIsSelfCollapsingBlock(); | 
|   416 } |   404 } | 
|   417  |   405  | 
|   418 inline bool LayoutBlockFlow::layoutBlockFlow(bool relayoutChildren, LayoutUnit &
      pageLogicalHeight, SubtreeLayoutScope& layoutScope) |   406 inline bool LayoutBlockFlow::layoutBlockFlow(bool relayoutChildren, LayoutUnit &
      pageLogicalHeight, SubtreeLayoutScope& layoutScope) | 
|   419 { |   407 { | 
|   420     LayoutUnit oldLeft = logicalLeft(); |   408     LayoutUnit oldLeft = logicalLeft(); | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   460         // [1] https://drafts.csswg.org/css-break/#possible-breaks |   448         // [1] https://drafts.csswg.org/css-break/#possible-breaks | 
|   461         setBreakBefore(LayoutBlock::breakBefore()); |   449         setBreakBefore(LayoutBlock::breakBefore()); | 
|   462         setBreakAfter(LayoutBlock::breakAfter()); |   450         setBreakAfter(LayoutBlock::breakAfter()); | 
|   463     } |   451     } | 
|   464  |   452  | 
|   465     LayoutUnit beforeEdge = borderBefore() + paddingBefore(); |   453     LayoutUnit beforeEdge = borderBefore() + paddingBefore(); | 
|   466     LayoutUnit afterEdge = borderAfter() + paddingAfter() + scrollbarLogicalHeig
      ht(); |   454     LayoutUnit afterEdge = borderAfter() + paddingAfter() + scrollbarLogicalHeig
      ht(); | 
|   467     LayoutUnit previousHeight = logicalHeight(); |   455     LayoutUnit previousHeight = logicalHeight(); | 
|   468     setLogicalHeight(beforeEdge); |   456     setLogicalHeight(beforeEdge); | 
|   469  |   457  | 
|   470     m_paintInvalidationLogicalTop = LayoutUnit(); |  | 
|   471     m_paintInvalidationLogicalBottom = LayoutUnit(); |  | 
|   472     if (!firstChild() && !isAnonymousBlock()) |   458     if (!firstChild() && !isAnonymousBlock()) | 
|   473         setChildrenInline(true); |   459         setChildrenInline(true); | 
|   474  |   460  | 
|   475     TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); |   461     TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); | 
|   476  |   462  | 
|   477     bool preferredLogicalWidthsWereDirty = preferredLogicalWidthsDirty(); |   463     bool preferredLogicalWidthsWereDirty = preferredLogicalWidthsDirty(); | 
|   478  |   464  | 
|   479     // Reset the flag here instead of in layoutInlineChildren() in case that |   465     // Reset the flag here instead of in layoutInlineChildren() in case that | 
|   480     // all inline children are removed from this block. |   466     // all inline children are removed from this block. | 
|   481     setContainsInlineWithOutlineAndContinuation(false); |   467     setContainsInlineWithOutlineAndContinuation(false); | 
|   482     if (childrenInline()) |   468     if (childrenInline()) | 
|   483         layoutInlineChildren(relayoutChildren, m_paintInvalidationLogicalTop, m_
      paintInvalidationLogicalBottom, afterEdge); |   469         layoutInlineChildren(relayoutChildren, afterEdge); | 
|   484     else |   470     else | 
|   485         layoutBlockChildren(relayoutChildren, layoutScope, beforeEdge, afterEdge
      ); |   471         layoutBlockChildren(relayoutChildren, layoutScope, beforeEdge, afterEdge
      ); | 
|   486  |   472  | 
|   487     bool preferredLogicalWidthsBecameDirty = !preferredLogicalWidthsWereDirty &&
       preferredLogicalWidthsDirty(); |   473     bool preferredLogicalWidthsBecameDirty = !preferredLogicalWidthsWereDirty &&
       preferredLogicalWidthsDirty(); | 
|   488     if (preferredLogicalWidthsBecameDirty) |   474     if (preferredLogicalWidthsBecameDirty) | 
|   489         return false; |   475         return false; | 
|   490  |   476  | 
|   491     // Expand our intrinsic height to encompass floats. |   477     // Expand our intrinsic height to encompass floats. | 
|   492     if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsNew
      FormattingContext()) |   478     if (lowestFloatLogicalBottom() > (logicalHeight() - afterEdge) && createsNew
      FormattingContext()) | 
|   493         setLogicalHeight(lowestFloatLogicalBottom() + afterEdge); |   479         setLogicalHeight(lowestFloatLogicalBottom() + afterEdge); | 
| (...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2782             && !floatingObject.layoutObject()->hasSelfPaintingLayer() |  2768             && !floatingObject.layoutObject()->hasSelfPaintingLayer() | 
|  2783             && (floatingObject.shouldPaint() || (paintAllDescendants && floating
      Object.layoutObject()->isDescendantOf(this)))) { |  2769             && (floatingObject.shouldPaint() || (paintAllDescendants && floating
      Object.layoutObject()->isDescendantOf(this)))) { | 
|  2784  |  2770  | 
|  2785             LayoutBox* floatingLayoutBox = floatingObject.layoutObject(); |  2771             LayoutBox* floatingLayoutBox = floatingObject.layoutObject(); | 
|  2786             floatingLayoutBox->setShouldDoFullPaintInvalidation(); |  2772             floatingLayoutBox->setShouldDoFullPaintInvalidation(); | 
|  2787             floatingLayoutBox->invalidatePaintForOverhangingFloats(false); |  2773             floatingLayoutBox->invalidatePaintForOverhangingFloats(false); | 
|  2788         } |  2774         } | 
|  2789     } |  2775     } | 
|  2790 } |  2776 } | 
|  2791  |  2777  | 
|  2792 void LayoutBlockFlow::invalidatePaintForOverflow() |  | 
|  2793 { |  | 
|  2794     // FIXME: We could tighten up the left and right invalidation points if we l
      et layoutInlineChildren fill them in based off the particular lines |  | 
|  2795     // it had to lay out. We wouldn't need the hasOverflowClip() hack in that ca
      se either. |  | 
|  2796     LayoutUnit paintInvalidationLogicalLeft = logicalLeftVisualOverflow(); |  | 
|  2797     LayoutUnit paintInvalidationLogicalRight = logicalRightVisualOverflow(); |  | 
|  2798     if (hasOverflowClip()) { |  | 
|  2799         // If we have clipped overflow, we should use layout overflow as well, s
      ince visual overflow from lines didn't propagate to our block's overflow. |  | 
|  2800         // Note the old code did this as well but even for overflow:visible. The
       addition of hasOverflowClip() at least tightens up the hack a bit. |  | 
|  2801         // layoutInlineChildren should be patched to compute the entire paint in
      validation rect. |  | 
|  2802         paintInvalidationLogicalLeft = std::min(paintInvalidationLogicalLeft, lo
      gicalLeftLayoutOverflow()); |  | 
|  2803         paintInvalidationLogicalRight = std::max(paintInvalidationLogicalRight, 
      logicalRightLayoutOverflow()); |  | 
|  2804     } |  | 
|  2805  |  | 
|  2806     LayoutRect paintInvalidationRect; |  | 
|  2807     if (isHorizontalWritingMode()) |  | 
|  2808         paintInvalidationRect = LayoutRect(paintInvalidationLogicalLeft, m_paint
      InvalidationLogicalTop, paintInvalidationLogicalRight - paintInvalidationLogical
      Left, m_paintInvalidationLogicalBottom - m_paintInvalidationLogicalTop); |  | 
|  2809     else |  | 
|  2810         paintInvalidationRect = LayoutRect(m_paintInvalidationLogicalTop, paintI
      nvalidationLogicalLeft, m_paintInvalidationLogicalBottom - m_paintInvalidationLo
      gicalTop, paintInvalidationLogicalRight - paintInvalidationLogicalLeft); |  | 
|  2811  |  | 
|  2812     if (hasOverflowClip()) { |  | 
|  2813         // Adjust the paint invalidation rect for scroll offset |  | 
|  2814         paintInvalidationRect.move(-scrolledContentOffset()); |  | 
|  2815  |  | 
|  2816         // Don't allow this rect to spill out of our overflow box. |  | 
|  2817         paintInvalidationRect.intersect(LayoutRect(LayoutPoint(), size())); |  | 
|  2818     } |  | 
|  2819  |  | 
|  2820     // Make sure the rect is still non-empty after intersecting for overflow abo
      ve |  | 
|  2821     if (!paintInvalidationRect.isEmpty()) { |  | 
|  2822         // Hits in media/event-attributes.html |  | 
|  2823         DisableCompositingQueryAsserts disabler; |  | 
|  2824  |  | 
|  2825         invalidatePaintRectangle(paintInvalidationRect); // We need to do a part
      ial paint invalidation of our content. |  | 
|  2826         if (hasReflection()) |  | 
|  2827             invalidatePaintRectangle(reflectedRect(paintInvalidationRect)); |  | 
|  2828     } |  | 
|  2829  |  | 
|  2830     m_paintInvalidationLogicalTop = LayoutUnit(); |  | 
|  2831     m_paintInvalidationLogicalBottom = LayoutUnit(); |  | 
|  2832 } |  | 
|  2833  |  | 
|  2834 void LayoutBlockFlow::invalidateDisplayItemClients(PaintInvalidationReason inval
      idationReason) const |  2778 void LayoutBlockFlow::invalidateDisplayItemClients(PaintInvalidationReason inval
      idationReason) const | 
|  2835 { |  2779 { | 
|  2836     LayoutBlock::invalidateDisplayItemClients(invalidationReason); |  2780     LayoutBlock::invalidateDisplayItemClients(invalidationReason); | 
|  2837  |  2781  | 
|  2838     // If the block is a continuation or containing block of an inline continuat
      ion, invalidate the |  2782     // If the block is a continuation or containing block of an inline continuat
      ion, invalidate the | 
|  2839     // start object of the continuations if it has focus ring because change of 
      continuation may change |  2783     // start object of the continuations if it has focus ring because change of 
      continuation may change | 
|  2840     // the shape of the focus ring. |  2784     // the shape of the focus ring. | 
|  2841     if (!isAnonymous()) |  2785     if (!isAnonymous()) | 
|  2842         return; |  2786         return; | 
|  2843  |  2787  | 
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3831             if (!rect.isEmpty()) |  3775             if (!rect.isEmpty()) | 
|  3832                 rects.append(rect); |  3776                 rects.append(rect); | 
|  3833         } |  3777         } | 
|  3834     } |  3778     } | 
|  3835  |  3779  | 
|  3836     if (inlineElementContinuation) |  3780     if (inlineElementContinuation) | 
|  3837         inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
      lineElementContinuation->containingBlock()->location() - location()), includeBlo
      ckOverflows); |  3781         inlineElementContinuation->addOutlineRects(rects, additionalOffset + (in
      lineElementContinuation->containingBlock()->location() - location()), includeBlo
      ckOverflows); | 
|  3838 } |  3782 } | 
|  3839  |  3783  | 
|  3840 } // namespace blink |  3784 } // namespace blink | 
| OLD | NEW |