[webkit-changes] [WebKit/WebKit] 3acbb6: Borders, backgrounds, and other table cell propert...

Wenson Hsieh noreply at github.com
Mon Dec 4 09:13:20 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3acbb664bd93438447218221d223c3466cdfa63c
      https://github.com/WebKit/WebKit/commit/3acbb664bd93438447218221d223c3466cdfa63c
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-12-04 (Mon, 04 Dec 2023)

  Changed paths:
    M Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
    M Source/WebCore/PAL/pal/PlatformMac.cmake
    M Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h
    A Source/WebCore/PAL/pal/spi/mac/NSTextTableSPI.h
    M Source/WebCore/editing/cocoa/AttributedString.mm
    M Tools/TestRunnerShared/spi/UIKitSPIForTesting.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm

  Log Message:
  -----------
  Borders, backgrounds, and other table cell properties are lost when pasting tables into TextEdit
https://bugs.webkit.org/show_bug.cgi?id=265712
rdar://119035264

Reviewed by Richard Robinson.

Even after the fixes in 266700 at main and 269265 at main, attributed string serialization is still lossy.
In the process of preserving table structure in `reconstructStyle` by recreating any
`NSTextTableBlock` instances that point to separate tables but (originally) belonged to the same
`NSTextTable` upon encoding, we end up discarding the decoded `NSTextTableBlock`, and only carry
over some aspects of the block (i.e., row and column information).

This causes us to lose information about the style and layout of these tables, on various bits of
state on `NSTextTableBlock` that are populated in `HTMLConverter::_fillInBlock`.

To fix this, we adopt a UIFoundation SPI, `-_takeValuesFromTextBlock:`, that allows us to copy
across the entire state of the `NSTextTableBlock` in a way that preserves style and layout
information, without changing the containing `NSTextTable`, or any of the row/column values.

* Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj:
* Source/WebCore/PAL/pal/PlatformMac.cmake:
* Source/WebCore/PAL/pal/spi/ios/UIKitSPI.h:
* Source/WebCore/PAL/pal/spi/mac/NSTextTableSPI.h: Added.
* Source/WebCore/editing/cocoa/AttributedString.mm:
(WebCore::reconstructStyle):

Implement the main fix here, by using `-_takeValuesFromTextBlock:` to copy all layout and
presentational attributes from the original, decoded text block over to the new one that points to
the correct text table.

* Tools/TestRunnerShared/spi/UIKitSPIForTesting.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewGetContents.mm:

Canonical link: https://commits.webkit.org/271485@main




More information about the webkit-changes mailing list