Enhance placeholder measurement with opt-in sizing policies #1110
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Description
This PR extends the
ComposePlaceholderAdapterinterface with new optional methods that provide enhanced control over placeholder sizing and measurement, while maintaining full backwards compatibility with existing implementations.Problem
Previously, placeholder sizing was limited to basic width/height calculations, which could lead to:
Solution
New optional methods in
ComposePlaceholderAdapter. All methods have defaults that preserve existing behavior.sizingPolicy()- Returns sizing hints to optimize measurement (Unknown- Uses legacy behavior)MatchWidthWrapContentHeight- pre-measures content for accurate heightAspectRatio- calculates height from width * ratioFixedHeightPx- sets explicit height in pixelspreComposeMeasureHeight()- allows adapters to pre-measure their content offscreen before first paint, eliminating flickerbottomSpacingPx()- adds visual spacing after placeholders without requiring redrawsoverlayPaddingPx()- customizes padding around the overlay view (defaults to 10px matching the current padding)contentHeightAdjustmentPx()- fine-tunes height to prevent clipping from rounding differencesImplementation Details
The
ComposePlaceholderManagernow checks thesizingPolicy()and branches accordingly:sizingPolicy()==Unknown(default), it uses the exacttrunklogic, including theEDITOR_INNER_PADDINGsubtractionBackwards Compatibility
Existing clients require no changes:
sizingPolicy()returns Unknown, triggering legacy code pathMigration Guide
Existing implementations continue to work unchanged. To opt into new features:
Test
Either check out this branch and the client's one to test locally, or just review the code; the testing will be done in the client's PR.