[webkit-changes] [WebKit/WebKit] 687a6e: [WebVTT] Modernize VTTCue

Jer Noble noreply at github.com
Wed Jun 28 13:19:04 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 687a6e6a1e60b9f64c6892feee42156e959508d8
      https://github.com/WebKit/WebKit/commit/687a6e6a1e60b9f64c6892feee42156e959508d8
  Author: Jer Noble <jer.noble at apple.com>
  Date:   2023-06-28 (Wed, 28 Jun 2023)

  Changed paths:
    M Source/WTF/wtf/EnumTraits.h
    M Source/WebCore/Modules/modern-media-controls/controls/text-tracks.css
    M Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp
    M Source/WebCore/html/track/InbandGenericTextTrack.cpp
    M Source/WebCore/html/track/TextTrackCue.cpp
    M Source/WebCore/html/track/TextTrackCue.h
    M Source/WebCore/html/track/TextTrackCueGeneric.cpp
    M Source/WebCore/html/track/TextTrackCueGeneric.h
    M Source/WebCore/html/track/VTTCue.cpp
    M Source/WebCore/html/track/VTTCue.h
    M Source/WebCore/html/track/VTTCue.idl
    M Source/WebCore/rendering/RenderVTTCue.cpp
    M Tools/TestWebKitAPI/Tests/WTF/EnumTraits.cpp

  Log Message:
  -----------
  [WebVTT] Modernize VTTCue
https://bugs.webkit.org/show_bug.cgi?id=258578
rdar://111393504

Reviewed by Eric Carlson.

VTTCue has a number of stylistic and functional implementation details that
are held over from its original implementation in 2014, and could benefit from
being brought up to a more modern set of practices and language features used
in other parts of WebKit.

The bindings generator now supports IDL-defined enumerations, and automatically
converts between them and C++ defined enumerations, so there is no need to
have string checks exist in VTTCue for properties that take those enumerations.

C++ enumerations should have the same type name as IDL enumerations, and values
for those enumerations should be equivalent as well (after converting to
CamelCase from snake-case). Those enumerations should therefore be `enum class`.

The existing enumerations included sentinel values for static checks of the
enumerations' sizes. Add support in EnumTraits for calculating the minimum,
maximum, and count of values at compile time, making sentinal values unnecessary.

The WebVTT specification now defines heights and font sizes in terms of 'vh' and
'vw', which are percentages of the video viewport height and width, respectively.
Now that WebKit supports these CSS units (as well as 'cqh' and 'cqw', which are
the equivalent units for percentage of container height and width), it is no
longer necessary to pass the layout size of the video element into the VTTCue
(and its subclasses) to calculate the CSS values of cue properties.

The WebVTT specification added more default CSS properties which need to be set
on the resulting elements, so those are added here too.

Add support for lineAlign and positionAlign properties in layout, where those
properties were already parsed and exposed though DOM APIs.

* Source/WTF/wtf/EnumTraits.h:
(WTF::EnumValues::std::max):
(WTF::EnumValues::std::min):
(WTF::EnumValues::forEach):
* Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp:
(WebCore::MediaControlTextTrackContainerElement::updateDisplay):
(WebCore::MediaControlTextTrackContainerElement::processActiveVTTCue):
(WebCore::MediaControlTextTrackContainerElement::updateActiveCuesFontSize):
* Source/WebCore/html/track/InbandGenericTextTrack.cpp:
(WebCore::InbandGenericTextTrack::updateCueFromCueData):
* Source/WebCore/html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::getDisplayTree):
(WebCore::TextTrackCue::setFontSize):
* Source/WebCore/html/track/TextTrackCue.h:
(WebCore::TextTrackCueBox::applyCSSProperties):
* Source/WebCore/html/track/TextTrackCueGeneric.cpp:
(WebCore::TextTrackCueGenericBoxElement::applyCSSProperties):
(WebCore::TextTrackCueGeneric::setFontSize):
(WebCore::TextTrackCueGeneric::setLine): Deleted.
* Source/WebCore/html/track/TextTrackCueGeneric.h:
* Source/WebCore/html/track/VTTCue.cpp:
(WebCore::VTTCueBox::applyCSSProperties):
(WebCore::VTTCue::VTTCue):
(WebCore::VTTCue::setVertical):
(WebCore::VTTCue::setLine):
(WebCore::VTTCue::setLineAlign):
(WebCore::VTTCue::position const):
(WebCore::VTTCue::setPositionAlign):
(WebCore::VTTCue::setAlign):
(WebCore::VTTCue::calculateComputedLinePosition const):
(WebCore::VTTCue::calculateComputedTextPosition const):
(WebCore::VTTCue::calculateComputedPositionAlignment const):
(WebCore::VTTCue::calculateMaximumSize const):
(WebCore::VTTCue::calculateDisplayParameters):
(WebCore::VTTCue::obtainCSSBoxes):
(WebCore::VTTCue::updateDisplayTree):
(WebCore::VTTCue::getDisplayTree):
(WebCore::VTTCue::getPositionCoordinates const):
(WebCore::VTTCue::setCueSettings):
(WebCore::VTTCue::getCSSAlignment const):
(WebCore::VTTCue::getCSSWritingMode const):
(WebCore::VTTCue::setFontSize):
(WebCore::VTTCue::toJSON const):
(WebCore::horizontalKeyword): Deleted.
(WebCore::VTTCue::initialize): Deleted.
(WebCore::VTTCue::vertical const): Deleted.
(WebCore::VTTCue::lineAlign const): Deleted.
(WebCore::VTTCue::positionAlign const): Deleted.
(WebCore::VTTCue::align const): Deleted.
* Source/WebCore/html/track/VTTCue.h:
(WebCore::VTTCue::vertical const):
(WebCore::VTTCue::lineAlign const):
(WebCore::VTTCue::positionAlign const):
(WebCore::VTTCue::align const):
(WebCore::VTTCue::element const):
(WebCore::VTTCue::backdrop const):
(WebCore::VTTCue::fontSize const):
(WebCore::VTTCue::fontSizeIsImportant const):
(WebCore::VTTCue::left const):
(WebCore::VTTCue::top const):
(WebCore::VTTCue::width const):
(WebCore::VTTCue::height const):
(WebCore::VTTCue::getWritingDirection const): Deleted.
(WebCore::VTTCue::getAlignment const): Deleted.
* Source/WebCore/html/track/VTTCue.idl:
* Source/WebCore/rendering/RenderVTTCue.cpp:
(WebCore::RenderVTTCue::initializeLayoutParameters):
(WebCore::RenderVTTCue::placeBoxInDefaultPosition):
(WebCore::RenderVTTCue::overlappingObjectForRect const):
(WebCore::RenderVTTCue::shouldSwitchDirection const):
(WebCore::RenderVTTCue::moveBoxesByStep):
(WebCore::RenderVTTCue::findNonOverlappingPosition const):
(WebCore::RenderVTTCue::repositionCueSnapToLinesSet):
(WebCore::RenderVTTCue::repositionGenericCue):
(WebCore::RenderVTTCue::repositionCueSnapToLinesNotSet):
* Tools/TestWebKitAPI/Tests/WTF/EnumTraits.cpp:
(TestWebKitAPI::TEST):

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




More information about the webkit-changes mailing list