diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/layout_object.h')
-rw-r--r-- | chromium/third_party/blink/renderer/core/layout/layout_object.h | 207 |
1 files changed, 125 insertions, 82 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/layout_object.h b/chromium/third_party/blink/renderer/core/layout/layout_object.h index 23a1003cb3c..ab615ff0c03 100644 --- a/chromium/third_party/blink/renderer/core/layout/layout_object.h +++ b/chromium/third_party/blink/renderer/core/layout/layout_object.h @@ -87,8 +87,6 @@ class LayoutNGTableSectionInterface; class LayoutNGTableCellInterface; class LayoutView; class LocalFrameView; -class NGPaintFragment; -class NGPhysicalBoxFragment; class PaintLayer; class PseudoElementStyleRequest; struct PaintInfo; @@ -151,7 +149,7 @@ const int kShowTreeCharacterOffset = 39; // exclude certain functions like ~SVGImage() from this rule. This is allowed // when a Persistent is guaranteeing to keep the LayoutObject alive for that GC // cycle. -class AllowDestroyingLayoutObjectInFinalizerScope { +class CORE_EXPORT AllowDestroyingLayoutObjectInFinalizerScope { STACK_ALLOCATED(); public: @@ -304,11 +302,11 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // Should be added at the beginning of every method to ensure we are not // accessing a LayoutObject after the Desroy() call. #if DCHECK_IS_ON() -// TODO(keishi): Implement once LayoutObject is made GarbageCollected. -#define NOT_DESTROYED() ((void)0) + ALWAYS_INLINE void CheckIsNotDestroyed() const { DCHECK(!is_destroyed_); } #else -#define NOT_DESTROYED() ((void)0) + ALWAYS_INLINE void CheckIsNotDestroyed() const {} #endif +#define NOT_DESTROYED() CheckIsNotDestroyed() // Returns the name of the layout object. virtual const char* GetName() const = 0; @@ -336,9 +334,9 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // Hide DisplayItemClient's methods whose names are too generic for // LayoutObjects. Should use LayoutObject's methods instead. + using DisplayItemClient::GetPaintInvalidationReason; using DisplayItemClient::Invalidate; using DisplayItemClient::IsValid; - using DisplayItemClient::GetPaintInvalidationReason; DOMNodeId OwnerNodeId() const final; @@ -454,13 +452,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // LayoutNG context. LayoutBlockFlow* ContainingNGBlockFlow() const; - // Returns |NGPhysicalBoxFragment| for |ContainingNGBlockFlow()| or nullptr - // otherwise. - // - // TODO(crbug.com/1061423): Remove this method. We shouldn't assume - // that there's only one fragment. - const NGPhysicalBoxFragment* ContainingBlockFlowFragment() const; - // Function to return our enclosing flow thread if we are contained inside // one. This function follows the containing block chain. LayoutFlowThread* FlowThreadContainingBlock() const { @@ -607,12 +598,25 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, return ShouldApplyLayoutContainment(StyleRef()); } - inline bool ShouldApplySizeContainment() const { + inline bool IsEligibleForSizeContainment() const { NOT_DESTROYED(); - return StyleRef().ContainsSize() && - (!IsInline() || IsAtomicInlineLevel()) && !IsRubyText() && + return (!IsInline() || IsAtomicInlineLevel()) && !IsRubyText() && (!IsTablePart() || IsTableCaption()) && !IsTable(); } + inline bool ShouldApplySizeContainment() const { + NOT_DESTROYED(); + return StyleRef().ContainsSize() && IsEligibleForSizeContainment(); + } + inline bool ShouldApplyInlineSizeContainment() const { + NOT_DESTROYED(); + return (StyleRef().ContainsInlineSize() || StyleRef().ContainsSize()) && + IsEligibleForSizeContainment(); + } + inline bool ShouldApplyBlockSizeContainment() const { + NOT_DESTROYED(); + return (StyleRef().ContainsBlockSize() || StyleRef().ContainsSize()) && + IsEligibleForSizeContainment(); + } inline bool ShouldApplyStyleContainment() const { NOT_DESTROYED(); return StyleRef().ContainsStyle(); @@ -626,6 +630,12 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, return ShouldApplyPaintContainment() && ShouldApplyLayoutContainment() && ShouldApplySizeContainment(); } + inline bool IsContainerForContainerQueries() const { + NOT_DESTROYED(); + return ShouldApplyLayoutContainment() && + (ShouldApplyInlineSizeContainment() || + ShouldApplyBlockSizeContainment()); + } inline bool IsStackingContext() const { NOT_DESTROYED(); @@ -842,10 +852,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, NOT_DESTROYED(); return IsOfType(kLayoutObjectTableCol); } - bool IsLayoutNGTableCol() const { - NOT_DESTROYED(); - return IsOfType(kLayoutObjectNGTableCol); - } bool IsListItem() const { NOT_DESTROYED(); return IsOfType(kLayoutObjectListItem); @@ -898,6 +904,10 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, NOT_DESTROYED(); return IsOfType(kLayoutObjectGrid); } + bool IsLayoutGridIncludingNG() const { + NOT_DESTROYED(); + return IsOfType(kLayoutObjectGrid) || IsOfType(kLayoutObjectNGGrid); + } bool IsLayoutIFrame() const { NOT_DESTROYED(); return IsOfType(kLayoutObjectIFrame); @@ -1259,10 +1269,10 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // SVGGraphicsElement::getBBox(). // NOTE: Markers are not specifically ignored here by SVG 1.1 spec, but we // ignore them since stroke-width is ignored (and marker size can depend on - // stroke-width). objectBoundingBox is returned local coordinates. + // stroke-width). objectBoundingBox is returned in local coordinates and + // always unzoomed. // The name objectBoundingBox is taken from the SVG 1.1 spec. virtual FloatRect ObjectBoundingBox() const; - virtual FloatRect StrokeBoundingBox() const; // Returns the smallest rectangle enclosing all of the painted content // respecting clipping, masking, filters, opacity, stroke-width and markers. @@ -1272,6 +1282,11 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // coordinate space is the viewport space. virtual FloatRect VisualRectInLocalSVGCoordinates() const; + // Like VisualRectInLocalSVGCoordinates() but does not include visual overflow + // (name is misleading). May be zoomed (currently only for <foreignObject>, + // which represents this via its LocalToSVGParentTransform()). + virtual FloatRect StrokeBoundingBox() const; + // This returns the transform applying to the local SVG coordinate space, // which combines the CSS transform properties and animation motion transform. // See SVGElement::calculateTransform(). @@ -1325,6 +1340,15 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, NOT_DESTROYED(); return nullptr; } + // Returns the |ComputedStyle| to use for painting outlines. When |this| is + // a block in a continuation-chain, it may need to paint outlines if its + // ancestor inline boxes in the DOM tree has outlines. + const ComputedStyle* StyleForContinuationOutline() const { + NOT_DESTROYED(); + if (UNLIKELY(IsAnonymous() && !IsInline())) + return SlowStyleForContinuationOutline(); + return nullptr; + } bool IsFloating() const { NOT_DESTROYED(); @@ -1611,7 +1635,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, } // Not returning StyleRef().HasTransformRelatedProperty() because some objects - // ignore the transform-related styles (e.g. LayoutInline, LayoutSVGBlock). + // ignore the transform-related styles (e.g., LayoutInline). bool HasTransformRelatedProperty() const { NOT_DESTROYED(); return bitfields_.HasTransformRelatedProperty(); @@ -1626,7 +1650,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, } bool HasClipPath() const { NOT_DESTROYED(); - return StyleRef().ClipPath(); + return StyleRef().HasClipPath(); } bool HasHiddenBackface() const { NOT_DESTROYED(); @@ -1700,6 +1724,10 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, bool IsRenderedLegendInternal() const; + // Returns true if this object represents ::marker for the first SUMMARY + // child of a DETAILS, and list-style-type is disclosure-*. + bool IsListMarkerForSummary() const; + // The pseudo element style can be cached or uncached. Use the cached method // if the pseudo element doesn't respect any pseudo classes (and therefore // has no concept of changing state). The cached pseudo style always inherits @@ -1798,12 +1826,12 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, filter_skipped_ = true; } - // TODO(mstensho): Get rid of this. It's just a temporary thing to retain - // old behavior in LayoutObject::container(). - void ResetOutput() { - ancestor_skipped_ = false; - filter_skipped_ = false; +#if DCHECK_IS_ON() + void AssertClean() { + DCHECK(!ancestor_skipped_); + DCHECK(!filter_skipped_); } +#endif bool AncestorSkipped() const { return ancestor_skipped_; } bool FilterSkipped() const { @@ -1964,13 +1992,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // LayoutInline that's contained by a legacy LayoutBlockFlow). inline bool CanTraversePhysicalFragments() const; - // Returns the associated |NGPaintFragment|. When this is not a |nullptr|, - // this is the root of an inline formatting context, laid out by LayoutNG. - virtual const NGPaintFragment* PaintFragment() const { - NOT_DESTROYED(); - return nullptr; - } - // Return true if |this| produces one or more inline fragments, including // whitespace-only text fragments. virtual bool HasInlineFragments() const { @@ -1983,11 +2004,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // layout-clean. crbug.com/963103 bool IsFirstInlineFragmentSafe() const; void SetIsInLayoutNGInlineFormattingContext(bool); - virtual NGPaintFragment* FirstInlineFragment() const { - NOT_DESTROYED(); - return nullptr; - } - virtual void SetFirstInlineFragment(NGPaintFragment*) { NOT_DESTROYED(); } virtual wtf_size_t FirstInlineFragmentItemIndex() const { NOT_DESTROYED(); return 0u; @@ -2168,7 +2184,11 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, PositionWithAffinity CreatePositionWithAffinity(int offset, TextAffinity) const; PositionWithAffinity CreatePositionWithAffinity(int offset) const; - PositionWithAffinity CreatePositionWithAffinity(const Position&) const; + PositionWithAffinity FindPosition() const; + PositionWithAffinity FirstPositionInOrBeforeThis() const; + PositionWithAffinity LastPositionInOrAfterThis() const; + PositionWithAffinity PositionAfterThis() const; + PositionWithAffinity PositionBeforeThis() const; virtual void DirtyLinesFromChangedChild( LayoutObject*, @@ -2232,6 +2252,8 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, const LayoutBlock* InclusiveContainingBlock() const; + const LayoutBlock* EnclosingScrollportBox() const; + bool CanContainAbsolutePositionObjects() const { NOT_DESTROYED(); return style_->CanContainAbsolutePositionObjects() || @@ -2614,13 +2636,13 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, bool IsSelectable() const; /** - * Returns the local coordinates of the caret within this layout object. - * @param caretOffset zero-based offset determining position within the + * Returns the local coordinates of the caret within this layout object. + * @param caretOffset zero-based offset determining position within the * layout object. - * @param extraWidthToEndOfLine optional out arg to give extra width to end + * @param extraWidthToEndOfLine optional out arg to give extra width to end * of line - - * useful for character range rect computations - */ + * useful for character range rect computations + */ virtual LayoutRect LocalCaretRect( const InlineBox*, int caret_offset, @@ -2717,9 +2739,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, return false; } - virtual int CaretMinOffset() const; - virtual int CaretMaxOffset() const; - // ImageResourceObserver override. void ImageChanged(ImageResourceContent*, CanDeferInvalidation) final; void ImageChanged(WrappedImagePtr, CanDeferInvalidation) override { @@ -2799,17 +2818,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, NOT_DESTROYED(); } - // For history and compatibility reasons, we draw outline:auto (for focus - // rings) and normal style outline differently. - // Focus rings enclose block visual overflows (of line boxes and descendants), - // while normal outlines don't. - NGOutlineType OutlineRectsShouldIncludeBlockVisualOverflow() const { - NOT_DESTROYED(); - return StyleRef().OutlineStyleIsAuto() - ? NGOutlineType::kIncludeBlockVisualOverflow - : NGOutlineType::kDontIncludeBlockVisualOverflow; - } - // Only public for LayoutNG. void SetContainsInlineWithOutlineAndContinuation(bool b) { NOT_DESTROYED(); @@ -2868,7 +2876,13 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, NOT_DESTROYED(); return bitfields_.ShouldCheckForPaintInvalidation(); } + // Sets both ShouldCheckForPaintInvalidation() and + // ShouldCheckGeometryForPaintInvalidation(). Though the setter and the getter + // are asymmetric, this prevents callers from accidentally missing the + // geometry checking flag. void SetShouldCheckForPaintInvalidation(); + // Sets ShouldCheckForPaintInvalidation() only. PaintInvalidator won't require + // paint property tree update or other geometry related updates. void SetShouldCheckForPaintInvalidationWithoutGeometryChange(); bool SubtreeShouldCheckForPaintInvalidation() const { @@ -2995,6 +3009,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // mark all ancestors as having a descendant that changed. This will cause a // PrePaint tree walk to update effective allowed touch action. void MarkEffectiveAllowedTouchActionChanged(); + void MarkDescendantEffectiveAllowedTouchActionChanged(); bool EffectiveAllowedTouchActionChanged() const { NOT_DESTROYED(); return bitfields_.EffectiveAllowedTouchActionChanged(); @@ -3017,6 +3032,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // mark all ancestors as having a descendant that changed. This will cause a // PrePaint tree walk to update blocking wheel event handler state. void MarkBlockingWheelEventHandlerChanged(); + void MarkDescendantBlockingWheelEventHandlerChanged(); bool BlockingWheelEventHandlerChanged() const { // TODO(https://crbug.com/841364): This block is optimized to avoid costly // checks for kWheelEventRegions. It will be simplified once @@ -3121,6 +3137,11 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, layout_object_.SetShouldSkipNextLayoutShiftTracking(b); } + void SetShouldAssumePaintOffsetTranslationForLayoutShiftTracking(bool b) { + layout_object_ + .SetShouldAssumePaintOffsetTranslationForLayoutShiftTracking(b); + } + FragmentData& FirstFragment() { return layout_object_.fragment_; } void EnsureId() { layout_object_.fragment_.EnsureId(); } @@ -3161,6 +3182,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // descendant needing a paint property update too. void SetNeedsPaintPropertyUpdate(); void SetNeedsPaintPropertyUpdatePreservingCachedRects(); + void SetDescendantNeedsPaintPropertyUpdate(); bool NeedsPaintPropertyUpdate() const { NOT_DESTROYED(); return bitfields_.NeedsPaintPropertyUpdate(); @@ -3180,9 +3202,9 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, NOT_DESTROYED(); return bitfields_.DescendantNeedsPaintPropertyUpdate(); } - // Main thread scrolling reasons require fully updating paint propeties of all - // ancestors (see: ScrollPaintPropertyNode.h). - void SetAncestorsNeedPaintPropertyUpdateForMainThreadScrolling(); + // Called when some change needs paint property update of all ancestors (not + // crossing frame boundaries). + void ForceAllAncestorsNeedPaintPropertyUpdate(); void SetIsScrollAnchorObject() { NOT_DESTROYED(); @@ -3316,6 +3338,13 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, bitfields_.SetIsLayoutNGObjectForListMarkerImage(b); } + bool IsLayoutNGObjectForCanvasFormattedText() const { + return bitfields_.IsLayoutNGObjectForCanvasFormattedText(); + } + void SetIsLayoutNGObjectForCanvasFormattedText(bool b) { + bitfields_.SetIsLayoutNGObjectForCanvasFormattedText(b); + } + bool PreviousVisibilityVisible() const { NOT_DESTROYED(); return bitfields_.PreviousVisibilityVisible(); @@ -3339,6 +3368,14 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, bitfields_.SetShouldSkipNextLayoutShiftTracking(b); } + bool ShouldAssumePaintOffsetTranslationForLayoutShiftTracking() const { + return bitfields_ + .ShouldAssumePaintOffsetTranslationForLayoutShiftTracking(); + } + void SetShouldAssumePaintOffsetTranslationForLayoutShiftTracking(bool b) { + bitfields_.SetShouldAssumePaintOffsetTranslationForLayoutShiftTracking(b); + } + protected: // Identifiers for each of LayoutObject subclasses. // The identifier name for blink::LayoutFoo should be kLayoutObjectFoo. @@ -3377,7 +3414,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, kLayoutObjectNGMixin, kLayoutObjectNGOutsideListMarker, kLayoutObjectNGProgress, - kLayoutObjectNGTableCol, kLayoutObjectNGText, kLayoutObjectNGTextControlMultiLine, kLayoutObjectNGTextControlSingleLine, @@ -3605,8 +3641,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, inline void MarkContainerChainForOverflowRecalcIfNeeded( bool mark_container_chain_layout_overflow_recalc); - inline void SetShouldCheckGeometryForPaintInvalidation(); - inline void InvalidateContainerIntrinsicLogicalWidths(); const LayoutBoxModelObject* EnclosingDirectlyCompositableContainer() const; @@ -3614,6 +3648,8 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, LayoutFlowThread* LocateFlowThreadContainingBlock() const; void RemoveFromLayoutFlowThreadRecursive(LayoutFlowThread*); + const ComputedStyle* SlowStyleForContinuationOutline() const; + StyleDifference AdjustStyleDifference(StyleDifference) const; #if DCHECK_IS_ON() @@ -3627,10 +3663,6 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, static bool IsAllowedToModifyLayoutTreeStructure(Document&); - // Returns the parent LayoutObject, or nullptr. This has a special case for - // LayoutView to return the owning LayoutObject in the containing frame. - inline LayoutObject* ParentCrossingFrames() const; - void UpdateImageObservers(const ComputedStyle* old_style, const ComputedStyle* new_style); void UpdateFirstLineImageObservers(const ComputedStyle* new_style); @@ -3773,7 +3805,10 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, is_layout_ng_object_for_list_marker_image_(false), is_table_column_constraints_dirty_(false), transform_affects_vector_effect_(false), + is_layout_ng_object_for_canvas_formatted_text(false), should_skip_next_layout_shift_tracking_(true), + should_assume_paint_offset_translation_for_layout_shift_tracking_( + false), positioned_state_(kIsStaticallyPositioned), selection_state_(static_cast<unsigned>(SelectionState::kNone)), subtree_paint_property_update_reasons_( @@ -4087,12 +4122,23 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, // included). ADD_BOOLEAN_BITFIELD(transform_affects_vector_effect_, TransformAffectsVectorEffect); + ADD_BOOLEAN_BITFIELD(is_layout_ng_object_for_canvas_formatted_text, + IsLayoutNGObjectForCanvasFormattedText); // Whether to skip layout shift tracking in the next paint invalidation. // See PaintInvalidator::UpdateLayoutShiftTracking(). ADD_BOOLEAN_BITFIELD(should_skip_next_layout_shift_tracking_, ShouldSkipNextLayoutShiftTracking); + // Whether, on the next time PaintPropertyTreeBuilder builds for this + // object, it should be assumed it had the same paint offset transform last + // time as it has this time. This is used when layout reattach loses the + // information from the previous frame; this bit stores that information + // to inform the next frame for layout shift tracking. + ADD_BOOLEAN_BITFIELD( + should_assume_paint_offset_translation_for_layout_shift_tracking_, + ShouldAssumePaintOffsetTranslationForLayoutShiftTracking); + private: // This is the cached 'position' value of this object // (see ComputedStyle::position). @@ -4149,9 +4195,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver, break; } } - void ClearPositionedState() { - positioned_state_ = kIsStaticallyPositioned; - } + void ClearPositionedState() { positioned_state_ = kIsStaticallyPositioned; } ALWAYS_INLINE SelectionState GetSelectionState() const { return static_cast<SelectionState>(selection_state_); @@ -4292,13 +4336,16 @@ inline bool LayoutObject::CanTraversePhysicalFragments() const { if (!IsInLayoutNGInlineFormattingContext()) return false; } - // Bail if we have an NGPaintFragment. NGPaintFragment will be removed, and we - // will not attempt to add support for them here. - if (PaintFragment()) + // The NG paint system currently doesn't support replaced content. + if (IsLayoutReplaced()) return false; // The NG paint system currently doesn't support table-cells. if (IsTableCellLegacy()) return false; + // Text controls have some logic in the layout objects that will be missed if + // we traverse the fragment tree when hit-testing. + if (IsTextControlIncludingNG()) + return false; return true; } @@ -4441,10 +4488,6 @@ CORE_EXPORT const LayoutObject* AssociatedLayoutObjectOf( CORE_EXPORT std::ostream& operator<<(std::ostream&, const LayoutObject*); CORE_EXPORT std::ostream& operator<<(std::ostream&, const LayoutObject&); -#define DEFINE_LAYOUT_OBJECT_TYPE_CASTS(thisType, predicate) \ - DEFINE_TYPE_CASTS(thisType, LayoutObject, object, object->predicate, \ - object.predicate) - bool IsMenuList(const LayoutObject* object); CORE_EXPORT bool IsListBox(const LayoutObject* object); |