@tiqian/engine 0.0.1 → 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/org/tiqian/clreq/AdjustmentStylePolicy.d.ts +11 -0
- package/dist/org/tiqian/clreq/AdjustmentStylePolicy.js +21 -0
- package/dist/org/tiqian/clreq/AutoSpaceMode.d.ts +16 -0
- package/dist/org/tiqian/clreq/AutoSpaceMode.js +17 -0
- package/dist/org/tiqian/clreq/AutoSpacePolicy.d.ts +13 -0
- package/dist/org/tiqian/clreq/AutoSpacePolicy.js +23 -0
- package/dist/org/tiqian/clreq/BopomofoParser.d.ts +10 -0
- package/dist/org/tiqian/clreq/BopomofoParser.js +46 -0
- package/dist/org/tiqian/clreq/BopomofoReading.d.ts +12 -0
- package/dist/org/tiqian/clreq/BopomofoReading.js +86 -0
- package/dist/org/tiqian/clreq/BopomofoTone.d.ts +28 -0
- package/dist/org/tiqian/clreq/BopomofoTone.js +26 -0
- package/dist/org/tiqian/clreq/CjkPunctuationGlyphPolicy.d.ts +16 -0
- package/dist/org/tiqian/clreq/CjkPunctuationGlyphPolicy.js +17 -0
- package/dist/org/tiqian/clreq/CjkPunctuationGlyphSubstitution.d.ts +8 -0
- package/dist/org/tiqian/clreq/CjkPunctuationGlyphSubstitution.js +25 -0
- package/dist/org/tiqian/clreq/ClreqProfile.d.ts +27 -0
- package/dist/org/tiqian/clreq/ClreqProfile.js +58 -0
- package/dist/org/tiqian/clreq/ClreqProfileResolver.d.ts +10 -0
- package/dist/org/tiqian/clreq/ClreqProfileResolver.js +13 -0
- package/dist/org/tiqian/clreq/ClreqPunctuationAdvancePolicy.d.ts +7 -0
- package/dist/org/tiqian/clreq/ClreqPunctuationAdvancePolicy.js +40 -0
- package/dist/org/tiqian/clreq/ClreqPunctuationGlyphSubstitutor.d.ts +19 -0
- package/dist/org/tiqian/clreq/ClreqPunctuationGlyphSubstitutor.js +93 -0
- package/dist/org/tiqian/clreq/ClreqPunctuationPolicies.d.ts +26 -0
- package/dist/org/tiqian/clreq/ClreqPunctuationPolicies.js +137 -0
- package/dist/org/tiqian/clreq/ClreqRegion.d.ts +20 -0
- package/dist/org/tiqian/clreq/ClreqRegion.js +20 -0
- package/dist/org/tiqian/clreq/ClreqStrictness.d.ts +16 -0
- package/dist/org/tiqian/clreq/ClreqStrictness.js +17 -0
- package/dist/org/tiqian/clreq/GlueSide.d.ts +16 -0
- package/dist/org/tiqian/clreq/GlueSide.js +17 -0
- package/dist/org/tiqian/clreq/HangingPunctuationStyle.d.ts +12 -0
- package/dist/org/tiqian/clreq/HangingPunctuationStyle.js +14 -0
- package/dist/org/tiqian/clreq/InteriorPunctuationStyle.d.ts +12 -0
- package/dist/org/tiqian/clreq/InteriorPunctuationStyle.js +14 -0
- package/dist/org/tiqian/clreq/KinsokuLevel.d.ts +20 -0
- package/dist/org/tiqian/clreq/KinsokuLevel.js +20 -0
- package/dist/org/tiqian/clreq/KinsokuMode.d.ts +14 -0
- package/dist/org/tiqian/clreq/KinsokuMode.js +2 -0
- package/dist/org/tiqian/clreq/KinsokuModes.d.ts +11 -0
- package/dist/org/tiqian/clreq/KinsokuModes.js +71 -0
- package/dist/org/tiqian/clreq/LineAdjustmentStrategy.d.ts +16 -0
- package/dist/org/tiqian/clreq/LineAdjustmentStrategy.js +17 -0
- package/dist/org/tiqian/clreq/LineEndPunctuationStyle.d.ts +12 -0
- package/dist/org/tiqian/clreq/LineEndPunctuationStyle.js +14 -0
- package/dist/org/tiqian/clreq/NumberSymbolCohesion.d.ts +8 -0
- package/dist/org/tiqian/clreq/NumberSymbolCohesion.js +56 -0
- package/dist/org/tiqian/clreq/PunctuationClass.d.ts +44 -0
- package/dist/org/tiqian/clreq/PunctuationClass.js +38 -0
- package/dist/org/tiqian/clreq/PunctuationGluePlacement.d.ts +12 -0
- package/dist/org/tiqian/clreq/PunctuationGluePlacement.js +14 -0
- package/dist/org/tiqian/clreq/PunctuationGluePlacements.d.ts +9 -0
- package/dist/org/tiqian/clreq/PunctuationGluePlacements.js +49 -0
- package/dist/org/tiqian/clreq/PunctuationPolicy.d.ts +10 -0
- package/dist/org/tiqian/clreq/PunctuationPolicy.js +18 -0
- package/dist/org/tiqian/clreq/PunctuationWidthPolicy.d.ts +8 -0
- package/dist/org/tiqian/clreq/PunctuationWidthPolicy.js +16 -0
- package/dist/org/tiqian/clreq/ResolvedKinsoku.d.ts +12 -0
- package/dist/org/tiqian/clreq/ResolvedKinsoku.js +43 -0
- package/dist/org/tiqian/core/AccurateSum.d.ts +3 -0
- package/dist/org/tiqian/core/AccurateSum.js +9 -0
- package/dist/org/tiqian/core/AutoSpaceDecisionInfo.d.ts +13 -0
- package/dist/org/tiqian/core/AutoSpaceDecisionInfo.js +24 -0
- package/dist/org/tiqian/core/BopomofoDecisionInfo.d.ts +13 -0
- package/dist/org/tiqian/core/BopomofoDecisionInfo.js +32 -0
- package/dist/org/tiqian/core/BopomofoGlyphPlacement.d.ts +16 -0
- package/dist/org/tiqian/core/BopomofoGlyphPlacement.js +33 -0
- package/dist/org/tiqian/core/BopomofoGlyphRole.d.ts +16 -0
- package/dist/org/tiqian/core/BopomofoGlyphRole.js +17 -0
- package/dist/org/tiqian/core/BreakOpportunityDecisionInfo.d.ts +11 -0
- package/dist/org/tiqian/core/BreakOpportunityDecisionInfo.js +52 -0
- package/dist/org/tiqian/core/BuiltInLayoutProfiles.d.ts +4 -0
- package/dist/org/tiqian/core/BuiltInLayoutProfiles.js +5 -0
- package/dist/org/tiqian/core/Cluster.d.ts +13 -0
- package/dist/org/tiqian/core/Cluster.js +24 -0
- package/dist/org/tiqian/core/ClusterGeometryDecisionInfo.d.ts +21 -0
- package/dist/org/tiqian/core/ClusterGeometryDecisionInfo.js +40 -0
- package/dist/org/tiqian/core/ColorSpan.d.ts +8 -0
- package/dist/org/tiqian/core/ColorSpan.js +25 -0
- package/dist/org/tiqian/core/ContextualKinsokuDecisionInfo.d.ts +12 -0
- package/dist/org/tiqian/core/ContextualKinsokuDecisionInfo.js +47 -0
- package/dist/org/tiqian/core/DecorationDecisionInfo.d.ts +13 -0
- package/dist/org/tiqian/core/DecorationDecisionInfo.js +24 -0
- package/dist/org/tiqian/core/DecorationKind.d.ts +20 -0
- package/dist/org/tiqian/core/DecorationKind.js +20 -0
- package/dist/org/tiqian/core/DecorationSegmentInfo.d.ts +15 -0
- package/dist/org/tiqian/core/DecorationSegmentInfo.js +28 -0
- package/dist/org/tiqian/core/DecorationSpan.d.ts +10 -0
- package/dist/org/tiqian/core/DecorationSpan.js +36 -0
- package/dist/org/tiqian/core/EastAsianSpacingData.d.ts +4 -0
- package/dist/org/tiqian/core/EastAsianSpacingData.js +399 -0
- package/dist/org/tiqian/core/EastAsianSpacingEdges.d.ts +8 -0
- package/dist/org/tiqian/core/EastAsianSpacingEdges.js +14 -0
- package/dist/org/tiqian/core/EastAsianSpacingValue.d.ts +20 -0
- package/dist/org/tiqian/core/EastAsianSpacingValue.js +20 -0
- package/dist/org/tiqian/core/EmergencyTrackingEligibilityDecisionInfo.d.ts +9 -0
- package/dist/org/tiqian/core/EmergencyTrackingEligibilityDecisionInfo.js +29 -0
- package/dist/org/tiqian/core/FirstLineIndentDecisionInfo.d.ts +8 -0
- package/dist/org/tiqian/core/FirstLineIndentDecisionInfo.js +16 -0
- package/dist/org/tiqian/core/FittedLinePatternGeometry.d.ts +2 -0
- package/dist/org/tiqian/core/FittedLinePatternGeometry.js +84 -0
- package/dist/org/tiqian/core/FontDecisionInfo.d.ts +13 -0
- package/dist/org/tiqian/core/FontDecisionInfo.js +45 -0
- package/dist/org/tiqian/core/Glyph.d.ts +15 -0
- package/dist/org/tiqian/core/Glyph.js +30 -0
- package/dist/org/tiqian/core/GlyphRun.d.ts +11 -0
- package/dist/org/tiqian/core/GlyphRun.js +28 -0
- package/dist/org/tiqian/core/Ic.d.ts +7 -0
- package/dist/org/tiqian/core/Ic.js +17 -0
- package/dist/org/tiqian/core/IllegalStateException.d.ts +4 -0
- package/dist/org/tiqian/core/IllegalStateException.js +8 -0
- package/dist/org/tiqian/core/InlineAttachment.d.ts +12 -0
- package/dist/org/tiqian/core/InlineAttachment.js +14 -0
- package/dist/org/tiqian/core/InlineBoxDecisionInfo.d.ts +12 -0
- package/dist/org/tiqian/core/InlineBoxDecisionInfo.js +22 -0
- package/dist/org/tiqian/core/InlineBoxOuterSpacing.d.ts +12 -0
- package/dist/org/tiqian/core/InlineBoxOuterSpacing.js +14 -0
- package/dist/org/tiqian/core/InlineBoxSpan.d.ts +10 -0
- package/dist/org/tiqian/core/InlineBoxSpan.js +17 -0
- package/dist/org/tiqian/core/InlineObjectBoundaryAdjustment.d.ts +12 -0
- package/dist/org/tiqian/core/InlineObjectBoundaryAdjustment.js +31 -0
- package/dist/org/tiqian/core/InlineObjectDecisionInfo.d.ts +28 -0
- package/dist/org/tiqian/core/InlineObjectDecisionInfo.js +54 -0
- package/dist/org/tiqian/core/InlineObjectLineHeightDecisionInfo.d.ts +16 -0
- package/dist/org/tiqian/core/InlineObjectLineHeightDecisionInfo.js +57 -0
- package/dist/org/tiqian/core/InlineObjectPreferredStretch.d.ts +11 -0
- package/dist/org/tiqian/core/InlineObjectPreferredStretch.js +30 -0
- package/dist/org/tiqian/core/InlineObjectPreferredStretchKind.d.ts +16 -0
- package/dist/org/tiqian/core/InlineObjectPreferredStretchKind.js +17 -0
- package/dist/org/tiqian/core/InlineObjectPunctuationAttachmentDecisionInfo.d.ts +12 -0
- package/dist/org/tiqian/core/InlineObjectPunctuationAttachmentDecisionInfo.js +22 -0
- package/dist/org/tiqian/core/InlineObjectSpan.d.ts +13 -0
- package/dist/org/tiqian/core/InlineObjectSpan.js +22 -0
- package/dist/org/tiqian/core/IntRange.d.ts +12 -0
- package/dist/org/tiqian/core/IntRange.js +30 -0
- package/dist/org/tiqian/core/IntRangeFns.d.ts +2 -0
- package/dist/org/tiqian/core/IntRangeFns.js +4 -0
- package/dist/org/tiqian/core/JustificationAllocationInfo.d.ts +10 -0
- package/dist/org/tiqian/core/JustificationAllocationInfo.js +18 -0
- package/dist/org/tiqian/core/JustificationDecisionInfo.d.ts +10 -0
- package/dist/org/tiqian/core/JustificationDecisionInfo.js +21 -0
- package/dist/org/tiqian/core/KinsokuDecisionInfo.d.ts +8 -0
- package/dist/org/tiqian/core/KinsokuDecisionInfo.js +16 -0
- package/dist/org/tiqian/core/LastLineAlignment.d.ts +16 -0
- package/dist/org/tiqian/core/LastLineAlignment.js +17 -0
- package/dist/org/tiqian/core/LayoutConstraints.d.ts +7 -0
- package/dist/org/tiqian/core/LayoutConstraints.js +24 -0
- package/dist/org/tiqian/core/LayoutDebugInfo.d.ts +70 -0
- package/dist/org/tiqian/core/LayoutDebugInfo.js +205 -0
- package/dist/org/tiqian/core/LayoutInput.d.ts +22 -0
- package/dist/org/tiqian/core/LayoutInput.js +56 -0
- package/dist/org/tiqian/core/LayoutPaintBounds.d.ts +18 -0
- package/dist/org/tiqian/core/LayoutPaintBounds.js +131 -0
- package/dist/org/tiqian/core/LayoutProfileId.d.ts +6 -0
- package/dist/org/tiqian/core/LayoutProfileId.js +17 -0
- package/dist/org/tiqian/core/LayoutQueries.d.ts +121 -0
- package/dist/org/tiqian/core/LayoutQueries.js +1297 -0
- package/dist/org/tiqian/core/LayoutQueryFns.d.ts +27 -0
- package/dist/org/tiqian/core/LayoutQueryFns.js +65 -0
- package/dist/org/tiqian/core/LayoutResult.d.ts +16 -0
- package/dist/org/tiqian/core/LayoutResult.js +36 -0
- package/dist/org/tiqian/core/LayoutResultFns.d.ts +3 -0
- package/dist/org/tiqian/core/LayoutResultFns.js +5 -0
- package/dist/org/tiqian/core/LayoutResultLineFns.d.ts +4 -0
- package/dist/org/tiqian/core/LayoutResultLineFns.js +5 -0
- package/dist/org/tiqian/core/LayoutResultReplayIndex.d.ts +37 -0
- package/dist/org/tiqian/core/LayoutResultReplayIndex.js +379 -0
- package/dist/org/tiqian/core/LineBox.d.ts +23 -0
- package/dist/org/tiqian/core/LineBox.js +43 -0
- package/dist/org/tiqian/core/LineBreakPolicy.d.ts +8 -0
- package/dist/org/tiqian/core/LineBreakPolicy.js +11 -0
- package/dist/org/tiqian/core/LineBreakSpan.d.ts +10 -0
- package/dist/org/tiqian/core/LineBreakSpan.js +30 -0
- package/dist/org/tiqian/core/LineDebugInfo.d.ts +7 -0
- package/dist/org/tiqian/core/LineDebugInfo.js +18 -0
- package/dist/org/tiqian/core/LineDecisionInfo.d.ts +14 -0
- package/dist/org/tiqian/core/LineDecisionInfo.js +32 -0
- package/dist/org/tiqian/core/LineEdgeTrimDecisionInfo.d.ts +12 -0
- package/dist/org/tiqian/core/LineEdgeTrimDecisionInfo.js +22 -0
- package/dist/org/tiqian/core/LineEndReason.d.ts +16 -0
- package/dist/org/tiqian/core/LineEndReason.js +17 -0
- package/dist/org/tiqian/core/LineLengthGrid.d.ts +7 -0
- package/dist/org/tiqian/core/LineLengthGrid.js +12 -0
- package/dist/org/tiqian/core/LineLengthGridDecisionInfo.d.ts +13 -0
- package/dist/org/tiqian/core/LineLengthGridDecisionInfo.js +26 -0
- package/dist/org/tiqian/core/LineRepairAllocationInfo.d.ts +8 -0
- package/dist/org/tiqian/core/LineRepairAllocationInfo.js +14 -0
- package/dist/org/tiqian/core/LineRepairCandidateInfo.d.ts +16 -0
- package/dist/org/tiqian/core/LineRepairCandidateInfo.js +30 -0
- package/dist/org/tiqian/core/LineRepairDecisionInfo.d.ts +15 -0
- package/dist/org/tiqian/core/LineRepairDecisionInfo.js +31 -0
- package/dist/org/tiqian/core/LineSpacingDecisionInfo.d.ts +10 -0
- package/dist/org/tiqian/core/LineSpacingDecisionInfo.js +20 -0
- package/dist/org/tiqian/core/LinkAddressDisplay.d.ts +3 -0
- package/dist/org/tiqian/core/LinkAddressDisplay.js +12 -0
- package/dist/org/tiqian/core/MandatoryBreakDecisionInfo.d.ts +10 -0
- package/dist/org/tiqian/core/MandatoryBreakDecisionInfo.js +33 -0
- package/dist/org/tiqian/core/MaxLinesDecisionInfo.d.ts +8 -0
- package/dist/org/tiqian/core/MaxLinesDecisionInfo.js +25 -0
- package/dist/org/tiqian/core/MeasureAdaptiveFirstLineIndent.d.ts +8 -0
- package/dist/org/tiqian/core/MeasureAdaptiveFirstLineIndent.js +17 -0
- package/dist/org/tiqian/core/MetricDecisionInfo.d.ts +19 -0
- package/dist/org/tiqian/core/MetricDecisionInfo.js +36 -0
- package/dist/org/tiqian/core/ParagraphStyle.d.ts +22 -0
- package/dist/org/tiqian/core/ParagraphStyle.js +36 -0
- package/dist/org/tiqian/core/PositionedCluster.d.ts +22 -0
- package/dist/org/tiqian/core/PositionedCluster.js +52 -0
- package/dist/org/tiqian/core/PunctuationDecisionInfo.d.ts +29 -0
- package/dist/org/tiqian/core/PunctuationDecisionInfo.js +54 -0
- package/dist/org/tiqian/core/Rect.d.ts +12 -0
- package/dist/org/tiqian/core/Rect.js +28 -0
- package/dist/org/tiqian/core/RichTextBackgroundDrawStyle.d.ts +15 -0
- package/dist/org/tiqian/core/RichTextBackgroundDrawStyle.js +25 -0
- package/dist/org/tiqian/core/RichTextBackgroundMetricPolicy.d.ts +16 -0
- package/dist/org/tiqian/core/RichTextBackgroundMetricPolicy.js +17 -0
- package/dist/org/tiqian/core/RichTextBackgroundPaint.d.ts +19 -0
- package/dist/org/tiqian/core/RichTextBackgroundPaint.js +51 -0
- package/dist/org/tiqian/core/RichTextCornerRadii.d.ts +12 -0
- package/dist/org/tiqian/core/RichTextCornerRadii.js +28 -0
- package/dist/org/tiqian/core/RichTextLayoutProjection.d.ts +6 -0
- package/dist/org/tiqian/core/RichTextLayoutProjection.js +62 -0
- package/dist/org/tiqian/core/RichTextLinePattern.d.ts +24 -0
- package/dist/org/tiqian/core/RichTextLinePattern.js +46 -0
- package/dist/org/tiqian/core/RichTextLineSegment.d.ts +25 -0
- package/dist/org/tiqian/core/RichTextLineSegment.js +55 -0
- package/dist/org/tiqian/core/RichTextPaint.d.ts +17 -0
- package/dist/org/tiqian/core/RichTextPaint.js +64 -0
- package/dist/org/tiqian/core/RichTextProjectionFns.d.ts +7 -0
- package/dist/org/tiqian/core/RichTextProjectionFns.js +102 -0
- package/dist/org/tiqian/core/RichTextRole.d.ts +35 -0
- package/dist/org/tiqian/core/RichTextRole.js +57 -0
- package/dist/org/tiqian/core/RichTextSpan.d.ts +11 -0
- package/dist/org/tiqian/core/RichTextSpan.js +34 -0
- package/dist/org/tiqian/core/RoleOverrideInfo.d.ts +12 -0
- package/dist/org/tiqian/core/RoleOverrideInfo.js +41 -0
- package/dist/org/tiqian/core/RubyDecisionInfo.d.ts +20 -0
- package/dist/org/tiqian/core/RubyDecisionInfo.js +46 -0
- package/dist/org/tiqian/core/RubyKind.d.ts +12 -0
- package/dist/org/tiqian/core/RubyKind.js +14 -0
- package/dist/org/tiqian/core/RubyLineHeightDecisionInfo.d.ts +13 -0
- package/dist/org/tiqian/core/RubyLineHeightDecisionInfo.js +36 -0
- package/dist/org/tiqian/core/RubyLineHeightMode.d.ts +12 -0
- package/dist/org/tiqian/core/RubyLineHeightMode.js +14 -0
- package/dist/org/tiqian/core/RubySpan.d.ts +13 -0
- package/dist/org/tiqian/core/RubySpan.js +60 -0
- package/dist/org/tiqian/core/ShapingDecisionInfo.d.ts +21 -0
- package/dist/org/tiqian/core/ShapingDecisionInfo.js +40 -0
- package/dist/org/tiqian/core/Size.d.ts +6 -0
- package/dist/org/tiqian/core/Size.js +12 -0
- package/dist/org/tiqian/core/SourceBoundaryBias.d.ts +16 -0
- package/dist/org/tiqian/core/SourceBoundaryBias.js +17 -0
- package/dist/org/tiqian/core/SourceInteractionBoundaries.d.ts +29 -0
- package/dist/org/tiqian/core/SourceInteractionBoundaries.js +193 -0
- package/dist/org/tiqian/core/SpacingDecisionInfo.d.ts +13 -0
- package/dist/org/tiqian/core/SpacingDecisionInfo.js +24 -0
- package/dist/org/tiqian/core/TextRange.d.ts +11 -0
- package/dist/org/tiqian/core/TextRange.js +40 -0
- package/dist/org/tiqian/core/TextRangeError.d.ts +11 -0
- package/dist/org/tiqian/core/TextRangeError.js +2 -0
- package/dist/org/tiqian/core/TextSpan.d.ts +8 -0
- package/dist/org/tiqian/core/TextSpan.js +12 -0
- package/dist/org/tiqian/core/TextStyle.d.ts +12 -0
- package/dist/org/tiqian/core/TextStyle.js +28 -0
- package/dist/org/tiqian/core/TiqianIllegalArgumentException.d.ts +6 -0
- package/dist/org/tiqian/core/TiqianIllegalArgumentException.js +21 -0
- package/dist/org/tiqian/core/TiqianNoSuchElementException.d.ts +10 -0
- package/dist/org/tiqian/core/TiqianNoSuchElementException.js +16 -0
- package/dist/org/tiqian/core/TiqianTextContent.d.ts +12 -0
- package/dist/org/tiqian/core/TiqianTextContent.js +38 -0
- package/dist/org/tiqian/core/UnicodeCombiningMarkData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeCombiningMarkData.js +109 -0
- package/dist/org/tiqian/core/UnicodeEastAsianSpacing.d.ts +16 -0
- package/dist/org/tiqian/core/UnicodeEastAsianSpacing.js +88 -0
- package/dist/org/tiqian/core/UnicodeEmojiModifierBaseData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeEmojiModifierBaseData.js +35 -0
- package/dist/org/tiqian/core/UnicodeExtendedPictographicData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeExtendedPictographicData.js +64 -0
- package/dist/org/tiqian/core/UnicodeNumber.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeNumber.js +14 -0
- package/dist/org/tiqian/core/UnicodeNumberData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeNumberData.js +64 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidence.d.ts +16 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidence.js +17 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidenceClassifier.d.ts +7 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidenceClassifier.js +17 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidenceData.d.ts +4 -0
- package/dist/org/tiqian/core/UnicodeScriptEvidenceData.js +295 -0
- package/dist/org/tiqian/core/UnicodeWordCharacter.d.ts +6 -0
- package/dist/org/tiqian/core/UnicodeWordCharacter.js +17 -0
- package/dist/org/tiqian/core/UnicodeWordCharacterData.d.ts +3 -0
- package/dist/org/tiqian/core/UnicodeWordCharacterData.js +234 -0
- package/dist/org/tiqian/core/Units.d.ts +7 -0
- package/dist/org/tiqian/core/Units.js +11 -0
- package/dist/org/tiqian/core/WritingMode.d.ts +12 -0
- package/dist/org/tiqian/core/WritingMode.js +14 -0
- package/dist/org/tiqian/core/ZeroWidthBreakDecisionInfo.d.ts +10 -0
- package/dist/org/tiqian/core/ZeroWidthBreakDecisionInfo.js +33 -0
- package/dist/org/tiqian/font/BaselineClass.d.ts +24 -0
- package/dist/org/tiqian/font/BaselineClass.js +23 -0
- package/dist/org/tiqian/font/BaselinePolicy.d.ts +17 -0
- package/dist/org/tiqian/font/BaselinePolicy.js +18 -0
- package/dist/org/tiqian/font/CjkDashCapabilityPolicy.d.ts +4 -0
- package/dist/org/tiqian/font/CjkDashCapabilityPolicy.js +9 -0
- package/dist/org/tiqian/font/CjkFontRoleClassifier.d.ts +8 -0
- package/dist/org/tiqian/font/CjkFontRoleClassifier.js +43 -0
- package/dist/org/tiqian/font/FontMetricSource.d.ts +24 -0
- package/dist/org/tiqian/font/FontMetricSource.js +23 -0
- package/dist/org/tiqian/font/FontMetrics.d.ts +39 -0
- package/dist/org/tiqian/font/FontMetrics.js +106 -0
- package/dist/org/tiqian/font/FontMetricsPolicy.d.ts +21 -0
- package/dist/org/tiqian/font/FontMetricsPolicy.js +21 -0
- package/dist/org/tiqian/font/FontPolicy.d.ts +36 -0
- package/dist/org/tiqian/font/FontPolicy.js +157 -0
- package/dist/org/tiqian/font/FontRole.d.ts +29 -0
- package/dist/org/tiqian/font/FontRole.js +27 -0
- package/dist/org/tiqian/font/FontRoleContext.d.ts +13 -0
- package/dist/org/tiqian/font/FontRoleContext.js +28 -0
- package/dist/org/tiqian/font/InlineShapingStylePolicy.d.ts +4 -0
- package/dist/org/tiqian/font/InlineShapingStylePolicy.js +18 -0
- package/dist/org/tiqian/font/LayoutFontMetrics.d.ts +18 -0
- package/dist/org/tiqian/font/LayoutFontMetrics.js +29 -0
- package/dist/org/tiqian/font/MetricBox.d.ts +20 -0
- package/dist/org/tiqian/font/MetricBox.js +20 -0
- package/dist/org/tiqian/font/PreferCjkForAmbiguousPunctuationResolver.d.ts +10 -0
- package/dist/org/tiqian/font/PreferCjkForAmbiguousPunctuationResolver.js +30 -0
- package/dist/org/tiqian/font/PunctuationFontPolicy.d.ts +21 -0
- package/dist/org/tiqian/font/PunctuationFontPolicy.js +21 -0
- package/dist/org/tiqian/font/RawFontMetrics.d.ts +11 -0
- package/dist/org/tiqian/font/RawFontMetrics.js +23 -0
- package/dist/org/tiqian/font/UnicodeEmojiData.d.ts +3 -0
- package/dist/org/tiqian/font/UnicodeEmojiData.js +63 -0
- package/dist/org/tiqian/font/UnicodeEmojiPresentationData.d.ts +3 -0
- package/dist/org/tiqian/font/UnicodeEmojiPresentationData.js +46 -0
- package/dist/org/tiqian/font/UnicodeEmojiStyleVariationData.d.ts +3 -0
- package/dist/org/tiqian/font/UnicodeEmojiStyleVariationData.js +71 -0
- package/dist/org/tiqian/font/UnicodeSymbolData.d.ts +3 -0
- package/dist/org/tiqian/font/UnicodeSymbolData.js +88 -0
- package/dist/org/tiqian/layout/AnnotationGeometryStage.d.ts +57 -0
- package/dist/org/tiqian/layout/AnnotationGeometryStage.js +622 -0
- package/dist/org/tiqian/layout/AsciiPointMarkKinsokuTestSupport.d.ts +52 -0
- package/dist/org/tiqian/layout/AsciiPointMarkKinsokuTestSupport.js +209 -0
- package/dist/org/tiqian/layout/ClusterRoleResolution.d.ts +30 -0
- package/dist/org/tiqian/layout/ClusterRoleResolution.js +215 -0
- package/dist/org/tiqian/layout/ContextualDashEllipsisRoleResolver.d.ts +54 -0
- package/dist/org/tiqian/layout/ContextualDashEllipsisRoleResolver.js +326 -0
- package/dist/org/tiqian/layout/ContextualPunctuationDisplaySubstitution.d.ts +6 -0
- package/dist/org/tiqian/layout/ContextualPunctuationDisplaySubstitution.js +8 -0
- package/dist/org/tiqian/layout/ContextualQuoteRoleResolver.d.ts +51 -0
- package/dist/org/tiqian/layout/ContextualQuoteRoleResolver.js +305 -0
- package/dist/org/tiqian/layout/DefaultHyphenator.d.ts +4 -0
- package/dist/org/tiqian/layout/DefaultHyphenator.js +7 -0
- package/dist/org/tiqian/layout/Justifier.d.ts +64 -0
- package/dist/org/tiqian/layout/Justifier.js +474 -0
- package/dist/org/tiqian/layout/KinsokuRule.d.ts +15 -0
- package/dist/org/tiqian/layout/KinsokuRule.js +24 -0
- package/dist/org/tiqian/layout/LayoutDebugAssembly.d.ts +87 -0
- package/dist/org/tiqian/layout/LayoutDebugAssembly.js +371 -0
- package/dist/org/tiqian/layout/LineAdjustmentStage.d.ts +29 -0
- package/dist/org/tiqian/layout/LineAdjustmentStage.js +797 -0
- package/dist/org/tiqian/layout/LineBreakPlanningStage.d.ts +149 -0
- package/dist/org/tiqian/layout/LineBreakPlanningStage.js +769 -0
- package/dist/org/tiqian/layout/LineBreaker.d.ts +54 -0
- package/dist/org/tiqian/layout/LineBreaker.js +457 -0
- package/dist/org/tiqian/layout/LineGeometryStage.d.ts +63 -0
- package/dist/org/tiqian/layout/LineGeometryStage.js +344 -0
- package/dist/org/tiqian/layout/LineOptimization.d.ts +125 -0
- package/dist/org/tiqian/layout/LineOptimization.js +299 -0
- package/dist/org/tiqian/layout/LineRepair.d.ts +30 -0
- package/dist/org/tiqian/layout/LineRepair.js +471 -0
- package/dist/org/tiqian/layout/ParagraphDpLineBreaker.d.ts +80 -0
- package/dist/org/tiqian/layout/ParagraphDpLineBreaker.js +556 -0
- package/dist/org/tiqian/layout/ParagraphDpLineBreakerTestSupport.d.ts +23 -0
- package/dist/org/tiqian/layout/ParagraphDpLineBreakerTestSupport.js +135 -0
- package/dist/org/tiqian/layout/ParagraphLayoutEngine.d.ts +48 -0
- package/dist/org/tiqian/layout/ParagraphLayoutEngine.js +199 -0
- package/dist/org/tiqian/layout/ParagraphShapingStage.d.ts +63 -0
- package/dist/org/tiqian/layout/ParagraphShapingStage.js +1471 -0
- package/dist/org/tiqian/layout/PlanLowering.d.ts +10 -0
- package/dist/org/tiqian/layout/PlanLowering.js +329 -0
- package/dist/org/tiqian/layout/PreparedParagraph.d.ts +32 -0
- package/dist/org/tiqian/layout/PreparedParagraph.js +114 -0
- package/dist/org/tiqian/layout/ProgressiveBreakDecisions.d.ts +86 -0
- package/dist/org/tiqian/layout/ProgressiveBreakDecisions.js +415 -0
- package/dist/org/tiqian/layout/ProgressiveBreakTierPriority.d.ts +5 -0
- package/dist/org/tiqian/layout/ProgressiveBreakTierPriority.js +33 -0
- package/dist/org/tiqian/layout/PunctuationGeometryLedger.d.ts +92 -0
- package/dist/org/tiqian/layout/PunctuationGeometryLedger.js +617 -0
- package/dist/org/tiqian/layout/PunctuationGeometryStage.d.ts +73 -0
- package/dist/org/tiqian/layout/PunctuationGeometryStage.js +631 -0
- package/dist/org/tiqian/layout/PunctuationModel.d.ts +181 -0
- package/dist/org/tiqian/layout/PunctuationModel.js +414 -0
- package/dist/org/tiqian/layout/QuotePairAnalyzer.d.ts +63 -0
- package/dist/org/tiqian/layout/QuotePairAnalyzer.js +251 -0
- package/dist/org/tiqian/layout/UnicodePunctuationBoundaryResolver.d.ts +88 -0
- package/dist/org/tiqian/layout/UnicodePunctuationBoundaryResolver.js +495 -0
- package/dist/org/tiqian/layout/WidthIndependentAnnotationCache.d.ts +102 -0
- package/dist/org/tiqian/layout/WidthIndependentAnnotationCache.js +1207 -0
- package/dist/org/tiqian/linebreak/BreakKind.d.ts +20 -0
- package/dist/org/tiqian/linebreak/BreakKind.js +20 -0
- package/dist/org/tiqian/linebreak/BreakOpportunity.d.ts +19 -0
- package/dist/org/tiqian/linebreak/BreakOpportunity.js +64 -0
- package/dist/org/tiqian/linebreak/EnglishHyphenation.d.ts +5 -0
- package/dist/org/tiqian/linebreak/EnglishHyphenation.js +14 -0
- package/dist/org/tiqian/linebreak/EnglishHyphenationPatterns.d.ts +4 -0
- package/dist/org/tiqian/linebreak/EnglishHyphenationPatterns.js +4294 -0
- package/dist/org/tiqian/linebreak/Hyphenator.d.ts +17 -0
- package/dist/org/tiqian/linebreak/Hyphenator.js +24 -0
- package/dist/org/tiqian/linebreak/LiangHyphenator.d.ts +10 -0
- package/dist/org/tiqian/linebreak/LiangHyphenator.js +67 -0
- package/dist/org/tiqian/linebreak/LineBreakAnalyzer.d.ts +9 -0
- package/dist/org/tiqian/linebreak/LineBreakAnalyzer.js +23 -0
- package/dist/org/tiqian/linebreak/LineBreakFns.d.ts +2 -0
- package/dist/org/tiqian/linebreak/LineBreakFns.js +7 -0
- package/dist/org/tiqian/linebreak/ParseTexHyphenationPatterns.d.ts +7 -0
- package/dist/org/tiqian/linebreak/ParseTexHyphenationPatterns.js +108 -0
- package/dist/org/tiqian/linebreak/ParsedTexHyphenation.d.ts +6 -0
- package/dist/org/tiqian/linebreak/ParsedTexHyphenation.js +9 -0
- package/dist/org/tiqian/linebreak/UnicodePunctuationLineBreak.d.ts +63 -0
- package/dist/org/tiqian/linebreak/UnicodePunctuationLineBreak.js +103 -0
- package/dist/org/tiqian/linebreak/UnicodePunctuationLineBreakData.d.ts +3 -0
- package/dist/org/tiqian/linebreak/UnicodePunctuationLineBreakData.js +164 -0
- package/dist/org/tiqian/protocol/NamedError.d.ts +88 -0
- package/dist/org/tiqian/protocol/NamedError.js +71 -0
- package/dist/org/tiqian/protocol/NamedErrorNames.d.ts +5 -0
- package/dist/org/tiqian/protocol/NamedErrorNames.js +53 -0
- package/dist/org/tiqian/protocol/Plan.d.ts +101 -0
- package/dist/org/tiqian/protocol/Plan.js +10 -0
- package/dist/org/tiqian/protocol/PlanEndReason.d.ts +16 -0
- package/dist/org/tiqian/protocol/PlanEndReason.js +17 -0
- package/dist/org/tiqian/protocol/PlanJson.d.ts +10 -0
- package/dist/org/tiqian/protocol/PlanJson.js +442 -0
- package/dist/org/tiqian/protocol/PlanJsonNumber.d.ts +43 -0
- package/dist/org/tiqian/protocol/PlanJsonNumber.js +362 -0
- package/dist/org/tiqian/protocol/PlanPacked.d.ts +34 -0
- package/dist/org/tiqian/protocol/PlanPacked.js +1166 -0
- package/dist/org/tiqian/protocol/PlanSchema.d.ts +4 -0
- package/dist/org/tiqian/protocol/PlanSchema.js +5 -0
- package/dist/org/tiqian/protocol/PlanStyleDelta.d.ts +5 -0
- package/dist/org/tiqian/protocol/PlanStyleDelta.js +2 -0
- package/dist/org/tiqian/shaping/ReplayableFontBackend.d.ts +48 -0
- package/dist/org/tiqian/shaping/ReplayableFontBackend.js +97 -0
- package/dist/org/tiqian/shaping/TextShaper.d.ts +71 -0
- package/dist/org/tiqian/shaping/TextShaper.js +176 -0
- package/dist/org/tiqian/test/TestHelpers.d.ts +5 -0
- package/dist/org/tiqian/test/TestHelpers.js +27 -0
- package/dist/org/tiqian/test/trace/TestTrace.d.ts +6 -0
- package/dist/org/tiqian/test/trace/TestTrace.js +8 -0
- package/dist/org/tiqian/test/trace/TestTracePlatform.d.ts +6 -0
- package/dist/org/tiqian/test/trace/TestTracePlatform.js +78 -0
- package/dist/org/tiqian/test/trace/TestTraceRecorder.d.ts +9 -0
- package/dist/org/tiqian/test/trace/TestTraceRecorder.js +36 -0
- package/dist/org/tiqian/test/trace/TestTraceRender.d.ts +47 -0
- package/dist/org/tiqian/test/trace/TestTraceRender.js +690 -0
- package/dist/org/tiqian/test/trace/TestTraceStore.d.ts +18 -0
- package/dist/org/tiqian/test/trace/TestTraceStore.js +149 -0
- package/dist/org/tiqian/test/trace/TraceAssertionError.d.ts +5 -0
- package/dist/org/tiqian/test/trace/TraceAssertionError.js +2 -0
- package/dist/org/tiqian/test/trace/TraceAssertionException.d.ts +6 -0
- package/dist/org/tiqian/test/trace/TraceAssertionException.js +16 -0
- package/dist/org/tiqian/test/trace/TraceField.d.ts +5 -0
- package/dist/org/tiqian/test/trace/TraceField.js +10 -0
- package/dist/org/tiqian/test/trace/TraceFormat.d.ts +21 -0
- package/dist/org/tiqian/test/trace/TraceFormat.js +184 -0
- package/dist/org/tiqian/test/trace/TracedAssertions.d.ts +78 -0
- package/dist/org/tiqian/test/trace/TracedAssertions.js +749 -0
- package/dist/runtime.d.ts +96 -0
- package/dist/runtime.js +1612 -0
- package/dist/std/FsError.d.ts +48 -0
- package/dist/std/FsError.js +2 -0
- package/dist/std/FsException.d.ts +6 -0
- package/dist/std/FsException.js +45 -0
- package/dist/std/UStringException.d.ts +6 -0
- package/dist/std/UStringException.js +21 -0
- package/dist/std/UStringFault.d.ts +9 -0
- package/dist/std/UStringFault.js +2 -0
- package/package.json +22 -4
- package/README.md +0 -3
|
@@ -0,0 +1,1297 @@
|
|
|
1
|
+
// Generated by the reflaxe TypeScript target. Do not edit.
|
|
2
|
+
import { PositionedCluster } from "./PositionedCluster.js";
|
|
3
|
+
import { Rect } from "./Rect.js";
|
|
4
|
+
import { RichTextCornerRadii } from "./RichTextCornerRadii.js";
|
|
5
|
+
import { RichTextLineSegment } from "./RichTextLineSegment.js";
|
|
6
|
+
import { Background, InlineCode, LineThrough, Underline } from "./RichTextRole.js";
|
|
7
|
+
import { RichTextSpan } from "./RichTextSpan.js";
|
|
8
|
+
import { SourceBoundaryBias } from "./SourceBoundaryBias.js";
|
|
9
|
+
import { SourceInteractionBoundaries } from "./SourceInteractionBoundaries.js";
|
|
10
|
+
import { TextRange } from "./TextRange.js";
|
|
11
|
+
import { TiqianIllegalArgumentException } from "./TiqianIllegalArgumentException.js";
|
|
12
|
+
import { TiqianNoSuchElementException } from "./TiqianNoSuchElementException.js";
|
|
13
|
+
import { UnicodeWordCharacterData } from "./UnicodeWordCharacterData.js";
|
|
14
|
+
import { UStringException } from "./../../../std/UStringException.js";
|
|
15
|
+
import { dictKey } from "../../../runtime.js";
|
|
16
|
+
export class SelectionBounds {
|
|
17
|
+
left;
|
|
18
|
+
right;
|
|
19
|
+
constructor(left, right) {
|
|
20
|
+
this.left = left;
|
|
21
|
+
this.right = right;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function projectTextForCopy(source, range, rubySpans) {
|
|
25
|
+
const start = (range.start < 0 ? 0 : (range.start > source.length ? source.length : range.start));
|
|
26
|
+
const end = (range.end < start ? start : (range.end > source.length ? source.length : range.end));
|
|
27
|
+
if (start === end) {
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
const annotations = [];
|
|
31
|
+
let index = 0;
|
|
32
|
+
while (index < rubySpans.length) {
|
|
33
|
+
const span = rubySpans[index];
|
|
34
|
+
if (span.baseRange.start >= start && span.baseRange.end <= end) {
|
|
35
|
+
annotations.push({ end: span.baseRange.end, text: span.text });
|
|
36
|
+
}
|
|
37
|
+
index += 1;
|
|
38
|
+
}
|
|
39
|
+
index = 1;
|
|
40
|
+
while (index < annotations.length) {
|
|
41
|
+
const value = annotations[index];
|
|
42
|
+
let cursor = index - 1;
|
|
43
|
+
while (cursor >= 0 && annotations[cursor].end > value.end) {
|
|
44
|
+
annotations[cursor + 1] = annotations[cursor];
|
|
45
|
+
cursor -= 1;
|
|
46
|
+
}
|
|
47
|
+
annotations[cursor + 1] = value;
|
|
48
|
+
index += 1;
|
|
49
|
+
}
|
|
50
|
+
let output = [];
|
|
51
|
+
let cursor2 = start;
|
|
52
|
+
index = 0;
|
|
53
|
+
while (index < annotations.length) {
|
|
54
|
+
const annotation = annotations[index];
|
|
55
|
+
if (annotation.end >= cursor2 && annotation.end <= end) {
|
|
56
|
+
const tail = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
57
|
+
if (tail >= 55296 && tail <= 56319 && source.substring(cursor2, annotation.end).length > 0 && !(source.substring(cursor2, annotation.end).charCodeAt(0) >= 56320 && source.substring(cursor2, annotation.end).charCodeAt(0) <= 57343)) {
|
|
58
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail });
|
|
59
|
+
}
|
|
60
|
+
if (source.substring(cursor2, annotation.end).length > 0) {
|
|
61
|
+
output.push(source.substring(cursor2, annotation.end));
|
|
62
|
+
}
|
|
63
|
+
const tail2 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
64
|
+
if (tail2 >= 55296 && tail2 <= 56319 && "(".length > 0 && !("(".charCodeAt(0) >= 56320 && "(".charCodeAt(0) <= 57343)) {
|
|
65
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail2 });
|
|
66
|
+
}
|
|
67
|
+
if ("(".length > 0) {
|
|
68
|
+
output.push("(");
|
|
69
|
+
}
|
|
70
|
+
const tail3 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
71
|
+
if (tail3 >= 55296 && tail3 <= 56319 && annotation.text.length > 0 && !(annotation.text.charCodeAt(0) >= 56320 && annotation.text.charCodeAt(0) <= 57343)) {
|
|
72
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail3 });
|
|
73
|
+
}
|
|
74
|
+
if (annotation.text.length > 0) {
|
|
75
|
+
output.push(annotation.text);
|
|
76
|
+
}
|
|
77
|
+
const tail4 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
78
|
+
if (tail4 >= 55296 && tail4 <= 56319 && ")".length > 0 && !(")".charCodeAt(0) >= 56320 && ")".charCodeAt(0) <= 57343)) {
|
|
79
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail4 });
|
|
80
|
+
}
|
|
81
|
+
if (")".length > 0) {
|
|
82
|
+
output.push(")");
|
|
83
|
+
}
|
|
84
|
+
cursor2 = annotation.end;
|
|
85
|
+
}
|
|
86
|
+
index += 1;
|
|
87
|
+
}
|
|
88
|
+
const tail5 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
89
|
+
if (tail5 >= 55296 && tail5 <= 56319 && source.substring(cursor2, end).length > 0 && !(source.substring(cursor2, end).charCodeAt(0) >= 56320 && source.substring(cursor2, end).charCodeAt(0) <= 57343)) {
|
|
90
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail5 });
|
|
91
|
+
}
|
|
92
|
+
if (source.substring(cursor2, end).length > 0) {
|
|
93
|
+
output.push(source.substring(cursor2, end));
|
|
94
|
+
}
|
|
95
|
+
const tail6 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
96
|
+
if (tail6 >= 55296 && tail6 <= 56319) {
|
|
97
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail6 });
|
|
98
|
+
}
|
|
99
|
+
return output.join("");
|
|
100
|
+
}
|
|
101
|
+
export function coerceTextSelectionOffset(text, inlineObjects, offset, bias) {
|
|
102
|
+
const clamped = (offset < 0 ? 0 : (offset > text.length ? text.length : offset));
|
|
103
|
+
let index = 0;
|
|
104
|
+
while (index < inlineObjects.length) {
|
|
105
|
+
const inlineObject = inlineObjects[index];
|
|
106
|
+
if (clamped > inlineObject.range.start && clamped < inlineObject.range.end) {
|
|
107
|
+
let snapped = inlineObject.range.start;
|
|
108
|
+
switch (bias.kind) {
|
|
109
|
+
case "Backward":
|
|
110
|
+
snapped = inlineObject.range.start;
|
|
111
|
+
break;
|
|
112
|
+
case "Forward":
|
|
113
|
+
snapped = inlineObject.range.end;
|
|
114
|
+
break;
|
|
115
|
+
case "Nearest":
|
|
116
|
+
snapped = (clamped - inlineObject.range.start < inlineObject.range.end - clamped ? inlineObject.range.start : inlineObject.range.end);
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
return snapped;
|
|
120
|
+
}
|
|
121
|
+
index += 1;
|
|
122
|
+
}
|
|
123
|
+
return SourceInteractionBoundaries.coerceToInteractionBoundary(text, clamped, new TextRange(0, text.length), bias);
|
|
124
|
+
}
|
|
125
|
+
export class LayoutQueries {
|
|
126
|
+
static INTERLINEAR_UNDERLINE_OFFSET_EM = 0.18;
|
|
127
|
+
static IDEOGRAPHIC_EM_BOX_NAME = "IdeographicEmBox";
|
|
128
|
+
static BACKGROUND_FALLBACK_ASCENT_EM = 0.88;
|
|
129
|
+
static BACKGROUND_FALLBACK_DESCENT_EM = 0.12;
|
|
130
|
+
static CR = 13;
|
|
131
|
+
static LF = 10;
|
|
132
|
+
static NEL = 133;
|
|
133
|
+
static LINE_SEPARATOR = 8232;
|
|
134
|
+
static PARAGRAPH_SEPARATOR = 8233;
|
|
135
|
+
static resolvedBackgroundCornerRadii(segment, inset) {
|
|
136
|
+
LayoutQueries.requireFiniteNonNegative(inset, "Failed requirement.");
|
|
137
|
+
const boxWidth = LayoutQueries.maxFloat(segment.width - inset * 2.0, 0.0);
|
|
138
|
+
const boxHeight = LayoutQueries.maxFloat(segment.height - inset * 2.0, 0.0);
|
|
139
|
+
const maximum = LayoutQueries.minFloat(boxWidth / 2.0, boxHeight / 2.0);
|
|
140
|
+
const paint = segment.span.paint.background;
|
|
141
|
+
const leftRadius = LayoutQueries.resolveRadius((segment.continuesFromPreviousLine ? paint.continuationCornerRadius : paint.cornerRadius), inset, maximum);
|
|
142
|
+
const rightRadius = LayoutQueries.resolveRadius((segment.continuesOnNextLine ? paint.continuationCornerRadius : paint.cornerRadius), inset, maximum);
|
|
143
|
+
return new RichTextCornerRadii(leftRadius, rightRadius, rightRadius, leftRadius);
|
|
144
|
+
}
|
|
145
|
+
static getTextForCopy(result, range) {
|
|
146
|
+
const source = result.input.content.text;
|
|
147
|
+
const start = LayoutQueries.clampInt(range.start, 0, source.length);
|
|
148
|
+
const end = LayoutQueries.clampInt(range.end, start, source.length);
|
|
149
|
+
if (start === end) {
|
|
150
|
+
return "";
|
|
151
|
+
}
|
|
152
|
+
const annotations = [];
|
|
153
|
+
let index = 0;
|
|
154
|
+
while (index < result.debug.rubyDecisions.length) {
|
|
155
|
+
const decision = result.debug.rubyDecisions[index];
|
|
156
|
+
LayoutQueries.addCopyAnnotation(annotations, decision.baseRange, decision.text, start, end);
|
|
157
|
+
index += 1;
|
|
158
|
+
}
|
|
159
|
+
index = 0;
|
|
160
|
+
while (index < result.debug.bopomofoDecisions.length) {
|
|
161
|
+
const decision2 = result.debug.bopomofoDecisions[index];
|
|
162
|
+
LayoutQueries.addCopyAnnotation(annotations, decision2.baseRange, decision2.text, start, end);
|
|
163
|
+
index += 1;
|
|
164
|
+
}
|
|
165
|
+
LayoutQueries.insertionSortAnnotations(annotations);
|
|
166
|
+
let output = [];
|
|
167
|
+
let cursor = start;
|
|
168
|
+
index = 0;
|
|
169
|
+
while (index < annotations.length) {
|
|
170
|
+
const annotation = annotations[index];
|
|
171
|
+
if (annotation.end >= cursor && annotation.end <= end) {
|
|
172
|
+
const tail7 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
173
|
+
if (tail7 >= 55296 && tail7 <= 56319 && source.substring(cursor, annotation.end).length > 0 && !(source.substring(cursor, annotation.end).charCodeAt(0) >= 56320 && source.substring(cursor, annotation.end).charCodeAt(0) <= 57343)) {
|
|
174
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail7 });
|
|
175
|
+
}
|
|
176
|
+
if (source.substring(cursor, annotation.end).length > 0) {
|
|
177
|
+
output.push(source.substring(cursor, annotation.end));
|
|
178
|
+
}
|
|
179
|
+
const tail8 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
180
|
+
if (tail8 >= 55296 && tail8 <= 56319 && "(".length > 0 && !("(".charCodeAt(0) >= 56320 && "(".charCodeAt(0) <= 57343)) {
|
|
181
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail8 });
|
|
182
|
+
}
|
|
183
|
+
if ("(".length > 0) {
|
|
184
|
+
output.push("(");
|
|
185
|
+
}
|
|
186
|
+
const tail9 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
187
|
+
if (tail9 >= 55296 && tail9 <= 56319 && annotation.text.length > 0 && !(annotation.text.charCodeAt(0) >= 56320 && annotation.text.charCodeAt(0) <= 57343)) {
|
|
188
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail9 });
|
|
189
|
+
}
|
|
190
|
+
if (annotation.text.length > 0) {
|
|
191
|
+
output.push(annotation.text);
|
|
192
|
+
}
|
|
193
|
+
const tail10 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
194
|
+
if (tail10 >= 55296 && tail10 <= 56319 && ")".length > 0 && !(")".charCodeAt(0) >= 56320 && ")".charCodeAt(0) <= 57343)) {
|
|
195
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail10 });
|
|
196
|
+
}
|
|
197
|
+
if (")".length > 0) {
|
|
198
|
+
output.push(")");
|
|
199
|
+
}
|
|
200
|
+
cursor = annotation.end;
|
|
201
|
+
}
|
|
202
|
+
index += 1;
|
|
203
|
+
}
|
|
204
|
+
const tail11 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
205
|
+
if (tail11 >= 55296 && tail11 <= 56319 && source.substring(cursor, end).length > 0 && !(source.substring(cursor, end).charCodeAt(0) >= 56320 && source.substring(cursor, end).charCodeAt(0) <= 57343)) {
|
|
206
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail11 });
|
|
207
|
+
}
|
|
208
|
+
if (source.substring(cursor, end).length > 0) {
|
|
209
|
+
output.push(source.substring(cursor, end));
|
|
210
|
+
}
|
|
211
|
+
const tail12 = output.length > 0 ? output[output.length - 1].charCodeAt(output[output.length - 1].length - 1) : NaN;
|
|
212
|
+
if (tail12 >= 55296 && tail12 <= 56319) {
|
|
213
|
+
throw new UStringException({ kind: "UnpairedSurrogate", unit: tail12 });
|
|
214
|
+
}
|
|
215
|
+
return output.join("");
|
|
216
|
+
}
|
|
217
|
+
static positionedClusters(result) {
|
|
218
|
+
const output = [];
|
|
219
|
+
let lineIndex = 0;
|
|
220
|
+
while (lineIndex < result.lines.length) {
|
|
221
|
+
const linePositions = LayoutQueries.positionedClustersAt(result, lineIndex, result.lines[lineIndex]);
|
|
222
|
+
let index = 0;
|
|
223
|
+
while (index < linePositions.length) {
|
|
224
|
+
output.push(linePositions[index]);
|
|
225
|
+
index += 1;
|
|
226
|
+
}
|
|
227
|
+
lineIndex += 1;
|
|
228
|
+
}
|
|
229
|
+
return output;
|
|
230
|
+
}
|
|
231
|
+
static positionedClustersForLine(result, line) {
|
|
232
|
+
let lineIndex = 0;
|
|
233
|
+
while (lineIndex < result.lines.length && dictKey(result.lines[lineIndex]) !== dictKey(line)) {
|
|
234
|
+
lineIndex += 1;
|
|
235
|
+
}
|
|
236
|
+
if (lineIndex >= result.lines.length) {
|
|
237
|
+
throw new TiqianIllegalArgumentException({ kind: "Message", text: "line must belong to this LayoutResult." });
|
|
238
|
+
}
|
|
239
|
+
return LayoutQueries.positionedClustersAt(result, lineIndex, line);
|
|
240
|
+
}
|
|
241
|
+
static glyphInkBounds(result) {
|
|
242
|
+
const positioned = LayoutQueries.positionedClusters(result);
|
|
243
|
+
let left = Infinity;
|
|
244
|
+
let top = Infinity;
|
|
245
|
+
let right = -Infinity;
|
|
246
|
+
let bottom = -Infinity;
|
|
247
|
+
let runIndex = 0;
|
|
248
|
+
while (runIndex < result.glyphRuns.length) {
|
|
249
|
+
const run = result.glyphRuns[runIndex];
|
|
250
|
+
let glyphIndex = 0;
|
|
251
|
+
while (glyphIndex < run.glyphs.length) {
|
|
252
|
+
const glyph = run.glyphs[glyphIndex];
|
|
253
|
+
if (glyph.bounds !== null) {
|
|
254
|
+
const cluster = LayoutQueries.findPositionedByRange(positioned, glyph.clusterRange);
|
|
255
|
+
if (cluster !== null) {
|
|
256
|
+
const bounds = glyph.bounds;
|
|
257
|
+
left = LayoutQueries.minFloat(left, cluster.drawX + glyph.x + bounds.left);
|
|
258
|
+
top = LayoutQueries.minFloat(top, cluster.baseline + glyph.y + bounds.top);
|
|
259
|
+
right = LayoutQueries.maxFloat(right, cluster.drawX + glyph.x + bounds.right);
|
|
260
|
+
bottom = LayoutQueries.maxFloat(bottom, cluster.baseline + glyph.y + bounds.bottom);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
glyphIndex += 1;
|
|
264
|
+
}
|
|
265
|
+
runIndex += 1;
|
|
266
|
+
}
|
|
267
|
+
if (!LayoutQueries.isFinite(left) || !LayoutQueries.isFinite(top) || !LayoutQueries.isFinite(right) || !LayoutQueries.isFinite(bottom)) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
return new Rect(left, top, right, bottom);
|
|
271
|
+
}
|
|
272
|
+
static getLineForOffset(result, offset) {
|
|
273
|
+
if (result.lines.length === 0) {
|
|
274
|
+
return -1;
|
|
275
|
+
}
|
|
276
|
+
const clamped = LayoutQueries.clampInt(offset, 0, result.input.content.text.length);
|
|
277
|
+
if (clamped === result.input.content.text.length) {
|
|
278
|
+
return result.lines.length - 1;
|
|
279
|
+
}
|
|
280
|
+
let index = 0;
|
|
281
|
+
while (index < result.lines.length) {
|
|
282
|
+
const line = result.lines[index];
|
|
283
|
+
if (clamped >= line.range.start && clamped < line.range.end) {
|
|
284
|
+
return index;
|
|
285
|
+
}
|
|
286
|
+
index += 1;
|
|
287
|
+
}
|
|
288
|
+
return LayoutQueries.nearestLineForOffset(result, clamped);
|
|
289
|
+
}
|
|
290
|
+
static getBoundingBox(result, offset) {
|
|
291
|
+
if (result.lines.length === 0) {
|
|
292
|
+
return new Rect(0.0, 0.0, 0.0, 0.0);
|
|
293
|
+
}
|
|
294
|
+
const clamped = LayoutQueries.clampInt(offset, 0, result.input.content.text.length);
|
|
295
|
+
if (clamped === result.input.content.text.length) {
|
|
296
|
+
return LayoutQueries.getCursorRect(result, clamped);
|
|
297
|
+
}
|
|
298
|
+
const positioned = LayoutQueries.positionedClusters(result);
|
|
299
|
+
let pipeline_result = null;
|
|
300
|
+
for (let pipeline_index = 0, count = positioned.length; pipeline_index < count; pipeline_index += 1) {
|
|
301
|
+
const cluster = positioned[pipeline_index];
|
|
302
|
+
if (clamped >= cluster.range.start && clamped < cluster.range.end) {
|
|
303
|
+
pipeline_result = cluster;
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const match = pipeline_result;
|
|
308
|
+
return (match === null ? LayoutQueries.getCursorRect(result, clamped) : match.rect);
|
|
309
|
+
}
|
|
310
|
+
static getBoundingBoxes(result, range) {
|
|
311
|
+
if (range.isEmpty || result.lines.length === 0) {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
const start = LayoutQueries.clampInt(range.start, 0, result.input.content.text.length);
|
|
315
|
+
const end = LayoutQueries.clampInt(range.end, start, result.input.content.text.length);
|
|
316
|
+
if (start === end) {
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
const positioned = LayoutQueries.positionedClusters(result);
|
|
320
|
+
const pipeline_result = new Array();
|
|
321
|
+
for (let pipeline_index = 0, count2 = positioned.length; pipeline_index < count2; pipeline_index += 1) {
|
|
322
|
+
const cluster = positioned[pipeline_index];
|
|
323
|
+
{
|
|
324
|
+
const pipeline_item = LayoutQueries.sliceRectIfCovered(cluster, start, end);
|
|
325
|
+
if (pipeline_item !== null) {
|
|
326
|
+
pipeline_result.push((pipeline_item));
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return pipeline_result;
|
|
331
|
+
}
|
|
332
|
+
static getBoundingBoxesInt(result, start, end) {
|
|
333
|
+
return LayoutQueries.getBoundingBoxes(result, new TextRange(start, end));
|
|
334
|
+
}
|
|
335
|
+
static positionedRichTextSegments(result, spans) {
|
|
336
|
+
if (spans.length === 0 || result.lines.length === 0) {
|
|
337
|
+
return [];
|
|
338
|
+
}
|
|
339
|
+
const clusters = LayoutQueries.positionedClusters(result);
|
|
340
|
+
const textLength = result.input.content.text.length;
|
|
341
|
+
const output = [];
|
|
342
|
+
let spanIndex = 0;
|
|
343
|
+
while (spanIndex < spans.length) {
|
|
344
|
+
const span = spans[spanIndex];
|
|
345
|
+
const start = LayoutQueries.clampInt(span.range.start, 0, textLength);
|
|
346
|
+
const end = LayoutQueries.clampInt(span.range.end, start, textLength);
|
|
347
|
+
if (start !== end) {
|
|
348
|
+
const normalized = new RichTextSpan(new TextRange(start, end), span.role, span.paint);
|
|
349
|
+
let pending = null;
|
|
350
|
+
let clusterIndex = 0;
|
|
351
|
+
while (clusterIndex < clusters.length) {
|
|
352
|
+
const cluster = clusters[clusterIndex];
|
|
353
|
+
if (cluster.range.start >= end) {
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
if (cluster.range.end > start) {
|
|
357
|
+
const sliceStart = LayoutQueries.maxInt(start, cluster.range.start);
|
|
358
|
+
const sliceEnd = LayoutQueries.minInt(end, cluster.range.end);
|
|
359
|
+
if (sliceStart < sliceEnd) {
|
|
360
|
+
const rect = LayoutQueries.sliceRect(cluster, sliceStart, sliceEnd);
|
|
361
|
+
const next = new RichTextLineSegment(normalized, cluster.lineIndex, new TextRange(sliceStart, sliceEnd), rect.left, rect.top, rect.right, rect.bottom, cluster.baseline);
|
|
362
|
+
if (pending !== null && pending.lineIndex === next.lineIndex && dictKey(pending.span) === dictKey(next.span) && pending.range.end === next.range.start) {
|
|
363
|
+
pending = new RichTextLineSegment(pending.span, pending.lineIndex, new TextRange(pending.range.start, next.range.end), pending.left, LayoutQueries.minFloat(pending.top, next.top), next.right, LayoutQueries.maxFloat(pending.bottom, next.bottom), pending.baseline);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
if (pending !== null) {
|
|
367
|
+
output.push((pending));
|
|
368
|
+
}
|
|
369
|
+
pending = next;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
clusterIndex += 1;
|
|
374
|
+
}
|
|
375
|
+
if (pending !== null) {
|
|
376
|
+
output.push((pending));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
spanIndex += 1;
|
|
380
|
+
}
|
|
381
|
+
return output;
|
|
382
|
+
}
|
|
383
|
+
static trimmedRichTextDecorationSegments(result, occupiedSegments) {
|
|
384
|
+
const count3 = occupiedSegments.length;
|
|
385
|
+
if (count3 === 0) {
|
|
386
|
+
return [];
|
|
387
|
+
}
|
|
388
|
+
const pipeline_result = new Array();
|
|
389
|
+
for (let pipeline_index = 0; pipeline_index < count3; pipeline_index += 1) {
|
|
390
|
+
const v = occupiedSegments[pipeline_index];
|
|
391
|
+
if (LayoutQueries.isDecorationRole(v.span.role)) {
|
|
392
|
+
pipeline_result.push(v);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
const decorations = pipeline_result;
|
|
396
|
+
if (decorations.length === 0) {
|
|
397
|
+
return [];
|
|
398
|
+
}
|
|
399
|
+
return LayoutQueries.withAdjacentSameStyleClearance(result, LayoutQueries.trimOuterPunctuationGlue(result, decorations));
|
|
400
|
+
}
|
|
401
|
+
static richTextBackgroundSegments(result, occupiedSegments) {
|
|
402
|
+
const count4 = occupiedSegments.length;
|
|
403
|
+
if (count4 === 0) {
|
|
404
|
+
return [];
|
|
405
|
+
}
|
|
406
|
+
const pipeline_result = new Array();
|
|
407
|
+
for (let pipeline_index = 0; pipeline_index < count4; pipeline_index += 1) {
|
|
408
|
+
const v = occupiedSegments[pipeline_index];
|
|
409
|
+
if (LayoutQueries.isBackgroundRole(v.span.role)) {
|
|
410
|
+
pipeline_result.push(v);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const backgrounds = pipeline_result;
|
|
414
|
+
if (backgrounds.length === 0) {
|
|
415
|
+
return [];
|
|
416
|
+
}
|
|
417
|
+
const positioned = LayoutQueries.positionedClusters(result);
|
|
418
|
+
const trimmed = LayoutQueries.trimOuterPunctuationGlue(result, backgrounds);
|
|
419
|
+
const output = [];
|
|
420
|
+
let index = 0;
|
|
421
|
+
while (index < trimmed.length) {
|
|
422
|
+
const segment = trimmed[index];
|
|
423
|
+
const covered = LayoutQueries.clustersOnSegmentLine(positioned, segment);
|
|
424
|
+
if (covered.length === 0) {
|
|
425
|
+
output.push(segment);
|
|
426
|
+
index += 1;
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
429
|
+
const first = covered[0];
|
|
430
|
+
const last = covered[covered.length - 1];
|
|
431
|
+
const horizontalPadding = segment.span.paint.background.horizontalPadding;
|
|
432
|
+
const leadingPadding = (segment.range.start === segment.span.range.start ? horizontalPadding : 0.0);
|
|
433
|
+
const trailingPadding = (segment.range.end === segment.span.range.end ? horizontalPadding : 0.0);
|
|
434
|
+
const left = LayoutQueries.minFloat(segment.right, LayoutQueries.maxFloat(segment.left, first.drawX - leadingPadding));
|
|
435
|
+
const naturalLastRight = LayoutQueries.naturalLastRight(result, last);
|
|
436
|
+
const right = LayoutQueries.maxFloat(left, LayoutQueries.minFloat(segment.right, naturalLastRight + trailingPadding));
|
|
437
|
+
let faceTop = 0.0;
|
|
438
|
+
let faceBottom = 0.0;
|
|
439
|
+
{
|
|
440
|
+
const _g = segment.span.paint.background.metricPolicy;
|
|
441
|
+
switch (_g.kind) {
|
|
442
|
+
case "MarkedFaces":
|
|
443
|
+
{
|
|
444
|
+
const faces = LayoutQueries.markedFaceVerticalBounds(result, covered);
|
|
445
|
+
faceTop = faces[0];
|
|
446
|
+
faceBottom = faces[1];
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
case "UniformTextStyle":
|
|
450
|
+
{
|
|
451
|
+
const uniform = LayoutQueries.uniformTextStyleVerticalBounds(result, segment, LayoutQueries.resolvedTextStyleAt(result, segment.range.start));
|
|
452
|
+
faceTop = uniform[0];
|
|
453
|
+
faceBottom = uniform[1];
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
case "UniformParagraphStyle":
|
|
457
|
+
{
|
|
458
|
+
const paragraph = LayoutQueries.uniformTextStyleVerticalBounds(result, segment, result.input.textStyle);
|
|
459
|
+
faceTop = paragraph[0];
|
|
460
|
+
faceBottom = paragraph[1];
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const verticalPadding = segment.span.paint.background.verticalPadding;
|
|
466
|
+
output.push(new RichTextLineSegment(segment.span, segment.lineIndex, segment.range, left, LayoutQueries.maxFloat(faceTop - verticalPadding, segment.top), right, LayoutQueries.minFloat(faceBottom + verticalPadding, segment.bottom), segment.baseline));
|
|
467
|
+
index += 1;
|
|
468
|
+
}
|
|
469
|
+
return LayoutQueries.withAdjacentSameStyleClearance(result, output);
|
|
470
|
+
}
|
|
471
|
+
static richTextDecorationLineY(result, segment, strokeWidth) {
|
|
472
|
+
LayoutQueries.requireFiniteNonNegative(strokeWidth, "strokeWidth must be finite and non-negative");
|
|
473
|
+
if (!LayoutQueries.isDecorationRole(segment.span.role)) {
|
|
474
|
+
throw new TiqianIllegalArgumentException({ kind: "Message", text: "richTextDecorationLineY only supports underline and line-through segments" });
|
|
475
|
+
}
|
|
476
|
+
const style = LayoutQueries.resolvedTextStyleAt(result, segment.range.start);
|
|
477
|
+
let rawLineY = segment.baseline;
|
|
478
|
+
if (segment.span.role instanceof Underline) {
|
|
479
|
+
rawLineY = segment.baseline + style.fontSize * LayoutQueries.INTERLINEAR_UNDERLINE_OFFSET_EM;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
if (segment.span.role instanceof LineThrough) {
|
|
483
|
+
const face = LayoutQueries.uniformTextStyleVerticalBounds(result, segment, style);
|
|
484
|
+
rawLineY = (face[0] + face[1]) / 2.0;
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
rawLineY = segment.baseline;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
return LayoutQueries.clampFloat(rawLineY, segment.top + strokeWidth / 2.0, segment.bottom - strokeWidth / 2.0);
|
|
491
|
+
}
|
|
492
|
+
static getCursorRect(result, offset) {
|
|
493
|
+
if (result.lines.length === 0) {
|
|
494
|
+
return new Rect(0.0, 0.0, 0.0, 0.0);
|
|
495
|
+
}
|
|
496
|
+
const clamped = LayoutQueries.clampInt(offset, 0, result.input.content.text.length);
|
|
497
|
+
const lineIndex = LayoutQueries.maxInt(LayoutQueries.getLineForOffset(result, clamped), 0);
|
|
498
|
+
const line = result.lines[lineIndex];
|
|
499
|
+
const positioned = LayoutQueries.positionedClustersAt(result, lineIndex, line);
|
|
500
|
+
let x = line.indent;
|
|
501
|
+
if (positioned.length > 0) {
|
|
502
|
+
if (clamped <= positioned[0].range.start) {
|
|
503
|
+
x = positioned[0].left;
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
if (clamped >= positioned[positioned.length - 1].range.end) {
|
|
507
|
+
x = positioned[positioned.length - 1].right;
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
let index = 0;
|
|
511
|
+
let found = false;
|
|
512
|
+
while (index < positioned.length) {
|
|
513
|
+
const cluster = positioned[index];
|
|
514
|
+
if (clamped >= cluster.range.start && clamped <= cluster.range.end) {
|
|
515
|
+
x = LayoutQueries.xForOffset(cluster, clamped);
|
|
516
|
+
found = true;
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
index += 1;
|
|
520
|
+
}
|
|
521
|
+
if (!found) {
|
|
522
|
+
throw new TiqianNoSuchElementException({ kind: "Message", text: "Collection contains no element matching the predicate." });
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return new Rect(x, line.top, x + 1.0, line.bottom);
|
|
528
|
+
}
|
|
529
|
+
static getOffsetForPosition(result, x, y) {
|
|
530
|
+
if (result.lines.length === 0) {
|
|
531
|
+
return 0;
|
|
532
|
+
}
|
|
533
|
+
const lineIndex = LayoutQueries.nearestLineForY(result, y);
|
|
534
|
+
const positioned = LayoutQueries.positionedClustersAt(result, lineIndex, result.lines[lineIndex]);
|
|
535
|
+
if (positioned.length === 0) {
|
|
536
|
+
return result.lines[lineIndex].range.start;
|
|
537
|
+
}
|
|
538
|
+
if (x <= positioned[0].left) {
|
|
539
|
+
return positioned[0].range.start;
|
|
540
|
+
}
|
|
541
|
+
if (x >= positioned[positioned.length - 1].right) {
|
|
542
|
+
return positioned[positioned.length - 1].range.end;
|
|
543
|
+
}
|
|
544
|
+
const cluster = LayoutQueries.nearestCluster(positioned, x);
|
|
545
|
+
return LayoutQueries.offsetForX(cluster, x);
|
|
546
|
+
}
|
|
547
|
+
static getSelectionOffsetForPosition(result, x, y) {
|
|
548
|
+
if (result.lines.length === 0) {
|
|
549
|
+
return 0;
|
|
550
|
+
}
|
|
551
|
+
const lineIndex = LayoutQueries.nearestLineForY(result, y);
|
|
552
|
+
const positioned = LayoutQueries.positionedClustersAt(result, lineIndex, result.lines[lineIndex]);
|
|
553
|
+
const count5 = positioned.length;
|
|
554
|
+
if (count5 === 0) {
|
|
555
|
+
return LayoutQueries.coerceSelectionOffset(result, result.lines[lineIndex].range.start, SourceBoundaryBias.Nearest);
|
|
556
|
+
}
|
|
557
|
+
if (x <= positioned[0].left) {
|
|
558
|
+
return LayoutQueries.coerceSelectionOffset(result, positioned[0].range.start, SourceBoundaryBias.Nearest);
|
|
559
|
+
}
|
|
560
|
+
if (x >= positioned[count5 - 1].right) {
|
|
561
|
+
return LayoutQueries.coerceSelectionOffset(result, positioned[count5 - 1].range.end, SourceBoundaryBias.Nearest);
|
|
562
|
+
}
|
|
563
|
+
let pipeline_result = null;
|
|
564
|
+
for (let pipeline_index = 0; pipeline_index < count5; pipeline_index += 1) {
|
|
565
|
+
const cluster = positioned[pipeline_index];
|
|
566
|
+
if (x >= cluster.left && x <= cluster.right) {
|
|
567
|
+
pipeline_result = cluster;
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
const candidate = pipeline_result;
|
|
572
|
+
const cluster2 = (candidate !== null ? candidate : LayoutQueries.nearestCluster(positioned, x));
|
|
573
|
+
const rawOffset = LayoutQueries.offsetForX(cluster2, x);
|
|
574
|
+
const backward = LayoutQueries.coerceSelectionOffset(result, rawOffset, SourceBoundaryBias.Backward);
|
|
575
|
+
const forward = LayoutQueries.coerceSelectionOffset(result, rawOffset, SourceBoundaryBias.Forward);
|
|
576
|
+
if (backward === forward) {
|
|
577
|
+
return backward;
|
|
578
|
+
}
|
|
579
|
+
const backwardDistance = Math.abs(LayoutQueries.getCursorRect(result, backward).left - x);
|
|
580
|
+
const forwardDistance = Math.abs(LayoutQueries.getCursorRect(result, forward).left - x);
|
|
581
|
+
return (backwardDistance < forwardDistance ? backward : forward);
|
|
582
|
+
}
|
|
583
|
+
static coerceSelectionOffset(result, offset, bias) {
|
|
584
|
+
return coerceTextSelectionOffset(result.input.content.text, result.input.inlineObjects, offset, bias);
|
|
585
|
+
}
|
|
586
|
+
static getSelectionWordBoundary(result, offset) {
|
|
587
|
+
const text = result.input.content.text;
|
|
588
|
+
if (text.length === 0) {
|
|
589
|
+
return new TextRange(0, 0);
|
|
590
|
+
}
|
|
591
|
+
const clamped = LayoutQueries.clampInt(offset, 0, text.length);
|
|
592
|
+
let objectIndex = 0;
|
|
593
|
+
while (objectIndex < result.input.inlineObjects.length) {
|
|
594
|
+
const inlineObject = result.input.inlineObjects[objectIndex];
|
|
595
|
+
if (clamped >= inlineObject.range.start && clamped < inlineObject.range.end) {
|
|
596
|
+
return inlineObject.range;
|
|
597
|
+
}
|
|
598
|
+
objectIndex += 1;
|
|
599
|
+
}
|
|
600
|
+
const boundaries = SourceInteractionBoundaries.interactionBoundaries(text, new TextRange(0, text.length));
|
|
601
|
+
let unitIndex = 0;
|
|
602
|
+
if (clamped === text.length) {
|
|
603
|
+
unitIndex = boundaries.length - 2;
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
unitIndex = LayoutQueries.boundaryIndex(boundaries, clamped);
|
|
607
|
+
}
|
|
608
|
+
if (unitIndex < 0) {
|
|
609
|
+
unitIndex = 0;
|
|
610
|
+
}
|
|
611
|
+
const kind = LayoutQueries.selectionWordKind(text, boundaries[unitIndex], boundaries[unitIndex + 1]);
|
|
612
|
+
if (kind.kind === "Single") {
|
|
613
|
+
return new TextRange(boundaries[unitIndex], boundaries[unitIndex + 1]);
|
|
614
|
+
}
|
|
615
|
+
let first = unitIndex;
|
|
616
|
+
let last = unitIndex;
|
|
617
|
+
while (first > 0 && LayoutQueries.selectionWordKind(text, boundaries[first - 1], boundaries[first]) === kind) {
|
|
618
|
+
first -= 1;
|
|
619
|
+
}
|
|
620
|
+
while (last + 2 < boundaries.length && LayoutQueries.selectionWordKind(text, boundaries[last + 1], boundaries[last + 2]) === kind) {
|
|
621
|
+
last += 1;
|
|
622
|
+
}
|
|
623
|
+
return new TextRange(boundaries[first], boundaries[last + 1]);
|
|
624
|
+
}
|
|
625
|
+
static getSelectionWordBoundaryForPosition(result, x, y) {
|
|
626
|
+
if (result.lines.length === 0 || result.input.content.text.length === 0) {
|
|
627
|
+
return null;
|
|
628
|
+
}
|
|
629
|
+
const lineIndex = LayoutQueries.nearestLineForY(result, y);
|
|
630
|
+
const positioned = LayoutQueries.positionedClustersAt(result, lineIndex, result.lines[lineIndex]);
|
|
631
|
+
const count6 = positioned.length;
|
|
632
|
+
if (count6 === 0) {
|
|
633
|
+
return null;
|
|
634
|
+
}
|
|
635
|
+
let pipeline_result = null;
|
|
636
|
+
for (let pipeline_index = 0; pipeline_index < count6; pipeline_index += 1) {
|
|
637
|
+
const cluster = positioned[pipeline_index];
|
|
638
|
+
if (x >= cluster.left && x <= cluster.right) {
|
|
639
|
+
pipeline_result = cluster;
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const candidate = pipeline_result;
|
|
644
|
+
const cluster2 = (candidate !== null ? candidate : LayoutQueries.nearestCluster(positioned, x));
|
|
645
|
+
if (cluster2.range.isEmpty) {
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
const sourceUnitOffset = LayoutQueries.clampInt(LayoutQueries.offsetForX(cluster2, x), cluster2.range.start, cluster2.range.end - 1);
|
|
649
|
+
return LayoutQueries.getSelectionWordBoundary(result, sourceUnitOffset);
|
|
650
|
+
}
|
|
651
|
+
static positionedClustersAt(result, lineIndex, line) {
|
|
652
|
+
const leadingConsumed = [];
|
|
653
|
+
let index = 0;
|
|
654
|
+
while (index < result.debug.geometryDecisions.length) {
|
|
655
|
+
const decision = result.debug.geometryDecisions[index];
|
|
656
|
+
if (decision.leadingGlueConsumed > 0.0) {
|
|
657
|
+
LayoutQueries.setFloatByRange(leadingConsumed, decision.range, decision.leadingGlueConsumed);
|
|
658
|
+
}
|
|
659
|
+
index += 1;
|
|
660
|
+
}
|
|
661
|
+
const leadingAutoSpaceGaps = [];
|
|
662
|
+
index = 0;
|
|
663
|
+
while (index < result.debug.autoSpaceDecisions.length) {
|
|
664
|
+
const decision2 = result.debug.autoSpaceDecisions[index];
|
|
665
|
+
if (decision2.side === "leading") {
|
|
666
|
+
LayoutQueries.setFloatByRange(leadingAutoSpaceGaps, decision2.clusterRange, -decision2.totalReduction);
|
|
667
|
+
}
|
|
668
|
+
index += 1;
|
|
669
|
+
}
|
|
670
|
+
const positioned = [];
|
|
671
|
+
let x = line.indent;
|
|
672
|
+
let clusterIndex = line.clusterRange.start;
|
|
673
|
+
let indexInLine = 0;
|
|
674
|
+
while (!line.clusterRange.isEmpty && clusterIndex <= line.clusterRange.end) {
|
|
675
|
+
if (clusterIndex >= 0 && clusterIndex < result.clusters.length) {
|
|
676
|
+
const cluster = result.clusters[clusterIndex];
|
|
677
|
+
const leadingGap = (indexInLine === 0 ? 0.0 : LayoutQueries.floatByRange(leadingAutoSpaceGaps, cluster.range));
|
|
678
|
+
const drawX = x + cluster.leadingLayoutAdvance + cluster.glyphInlineShift + leadingGap - LayoutQueries.floatByRange(leadingConsumed, cluster.range);
|
|
679
|
+
const right = x + cluster.advance;
|
|
680
|
+
const glyphs = LayoutQueries.glyphsForCluster(result, cluster.range);
|
|
681
|
+
let sourceStops = null;
|
|
682
|
+
if (cluster.range.length > 1 && glyphs.length === cluster.range.length) {
|
|
683
|
+
const stops = [x];
|
|
684
|
+
let glyphIndex = 1;
|
|
685
|
+
while (glyphIndex < cluster.range.length) {
|
|
686
|
+
stops.push(LayoutQueries.clampFloat(drawX + glyphs[glyphIndex].x, x, right));
|
|
687
|
+
glyphIndex += 1;
|
|
688
|
+
}
|
|
689
|
+
stops.push(right);
|
|
690
|
+
sourceStops = stops;
|
|
691
|
+
}
|
|
692
|
+
positioned.push(new PositionedCluster(lineIndex, clusterIndex, cluster.range, x, line.top, right, line.bottom, line.baseline + cluster.baselineShift, drawX, sourceStops));
|
|
693
|
+
x += cluster.advance;
|
|
694
|
+
indexInLine += 1;
|
|
695
|
+
}
|
|
696
|
+
clusterIndex += 1;
|
|
697
|
+
}
|
|
698
|
+
return LayoutQueries.withRubySelectionGeometry(result, positioned, lineIndex);
|
|
699
|
+
}
|
|
700
|
+
static withRubySelectionGeometry(result, positioned, lineIndex) {
|
|
701
|
+
const rubies = [];
|
|
702
|
+
let rubyIndex = 0;
|
|
703
|
+
while (rubyIndex < result.debug.rubyDecisions.length) {
|
|
704
|
+
const ruby = result.debug.rubyDecisions[rubyIndex];
|
|
705
|
+
if (ruby.lineIndex === lineIndex && ruby.width > 0.0) {
|
|
706
|
+
rubies.push(ruby);
|
|
707
|
+
}
|
|
708
|
+
rubyIndex++;
|
|
709
|
+
}
|
|
710
|
+
if (rubies.length === 0) {
|
|
711
|
+
return positioned;
|
|
712
|
+
}
|
|
713
|
+
const count7 = positioned.length;
|
|
714
|
+
const pipeline_result = new Array(count7);
|
|
715
|
+
for (let pipeline_index = 0; pipeline_index < count7; pipeline_index += 1) {
|
|
716
|
+
const v = positioned[pipeline_index];
|
|
717
|
+
const spread = LayoutQueries.floatByRangeFromGeometry(result, v.range);
|
|
718
|
+
pipeline_result[pipeline_index] = new SelectionBounds(v.left, LayoutQueries.maxFloat(v.right - spread, v.left));
|
|
719
|
+
}
|
|
720
|
+
const bounds = pipeline_result;
|
|
721
|
+
let rubyIndex2 = 0;
|
|
722
|
+
let index = 0;
|
|
723
|
+
while (rubyIndex2 < rubies.length) {
|
|
724
|
+
const ruby2 = rubies[rubyIndex2];
|
|
725
|
+
const _g = [];
|
|
726
|
+
for (let index2 = 0, count8 = positioned.length; index2 < count8; index2 += 1) {
|
|
727
|
+
if (positioned[index2].range.start >= ruby2.baseRange.start && positioned[index2].range.end <= ruby2.baseRange.end) {
|
|
728
|
+
_g.push(index2);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
const baseIndices = _g;
|
|
732
|
+
if (baseIndices.length > 0) {
|
|
733
|
+
const count9 = baseIndices.length;
|
|
734
|
+
const pipeline_result1 = new Array(count9);
|
|
735
|
+
for (let pipeline_index1 = 0; pipeline_index1 < count9; pipeline_index1 += 1) {
|
|
736
|
+
const v2 = baseIndices[pipeline_index1];
|
|
737
|
+
pipeline_result1[pipeline_index1] = LayoutQueries.centerOfCluster(result, positioned[v2]);
|
|
738
|
+
}
|
|
739
|
+
const centers = pipeline_result1;
|
|
740
|
+
const rubyLeft = ruby2.centerX - ruby2.width / 2.0;
|
|
741
|
+
const rubyRight = ruby2.centerX + ruby2.width / 2.0;
|
|
742
|
+
index = 0;
|
|
743
|
+
while (index < baseIndices.length) {
|
|
744
|
+
const idx = baseIndices[index];
|
|
745
|
+
const bound = bounds[idx];
|
|
746
|
+
bounds[idx] = new SelectionBounds(LayoutQueries.minFloat(bound.left, (index === 0 ? rubyLeft : LayoutQueries.maxFloat(rubyLeft, (centers[index - 1] + centers[index]) / 2.0))), LayoutQueries.maxFloat(bound.right, (index === baseIndices.length - 1 ? rubyRight : LayoutQueries.minFloat(rubyRight, (centers[index] + centers[index + 1]) / 2.0))));
|
|
747
|
+
index++;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
rubyIndex2++;
|
|
751
|
+
}
|
|
752
|
+
let index3 = 0;
|
|
753
|
+
while (index3 + 1 < bounds.length) {
|
|
754
|
+
const left = bounds[index3];
|
|
755
|
+
const right = bounds[index3 + 1];
|
|
756
|
+
if (left.right > right.left) {
|
|
757
|
+
const center = LayoutQueries.clampFloat((LayoutQueries.centerOfCluster(result, positioned[index3]) + LayoutQueries.centerOfCluster(result, positioned[index3 + 1])) / 2.0, LayoutQueries.minFloat(left.left, right.left), LayoutQueries.maxFloat(left.right, right.right));
|
|
758
|
+
bounds[index3] = new SelectionBounds(left.left, LayoutQueries.maxFloat(LayoutQueries.minFloat(left.right, center), left.left));
|
|
759
|
+
bounds[index3 + 1] = new SelectionBounds(LayoutQueries.minFloat(LayoutQueries.maxFloat(right.left, center), right.right), right.right);
|
|
760
|
+
}
|
|
761
|
+
index3++;
|
|
762
|
+
}
|
|
763
|
+
const output = [];
|
|
764
|
+
index3 = 0;
|
|
765
|
+
while (index3 < positioned.length) {
|
|
766
|
+
const cluster = positioned[index3];
|
|
767
|
+
const bound2 = bounds[index3];
|
|
768
|
+
output.push(new PositionedCluster(cluster.lineIndex, cluster.clusterIndex, cluster.range, bound2.left, cluster.top, bound2.right, cluster.bottom, cluster.baseline, cluster.drawX, null));
|
|
769
|
+
index3++;
|
|
770
|
+
}
|
|
771
|
+
return output;
|
|
772
|
+
}
|
|
773
|
+
static trimOuterPunctuationGlue(result, segments) {
|
|
774
|
+
const output = [];
|
|
775
|
+
let segmentIndex = 0;
|
|
776
|
+
while (segmentIndex < segments.length) {
|
|
777
|
+
const segment = segments[segmentIndex];
|
|
778
|
+
if (segment.lineIndex < 0 || segment.lineIndex >= result.lines.length) {
|
|
779
|
+
output.push(segment);
|
|
780
|
+
segmentIndex += 1;
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
const line = result.lines[segment.lineIndex];
|
|
784
|
+
let first = null;
|
|
785
|
+
let last = null;
|
|
786
|
+
let clusterIndex = line.clusterRange.start;
|
|
787
|
+
while (!line.clusterRange.isEmpty && clusterIndex <= line.clusterRange.end) {
|
|
788
|
+
if (clusterIndex >= 0 && clusterIndex < result.clusters.length) {
|
|
789
|
+
const cluster = result.clusters[clusterIndex];
|
|
790
|
+
if (cluster.range.end > segment.range.start && first === null) {
|
|
791
|
+
first = cluster;
|
|
792
|
+
}
|
|
793
|
+
if (cluster.range.start < segment.range.end) {
|
|
794
|
+
last = cluster;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
clusterIndex += 1;
|
|
798
|
+
}
|
|
799
|
+
let leadingGlue = 0.0;
|
|
800
|
+
let trailingGlue = 0.0;
|
|
801
|
+
if (first !== null && segment.range.start === first.range.start) {
|
|
802
|
+
const decision = LayoutQueries.geometryDecisionForRange(result, first.range);
|
|
803
|
+
if (decision !== null) {
|
|
804
|
+
leadingGlue = LayoutQueries.maxFloat(decision.leadingGlueNatural - decision.leadingGlueConsumed, 0.0);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (last !== null && segment.range.end === last.range.end) {
|
|
808
|
+
const decision2 = LayoutQueries.geometryDecisionForRange(result, last.range);
|
|
809
|
+
if (decision2 !== null) {
|
|
810
|
+
trailingGlue = LayoutQueries.maxFloat(decision2.trailingGlueNatural - decision2.trailingGlueConsumed, 0.0);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
const left = LayoutQueries.minFloat(segment.right, segment.left + leadingGlue);
|
|
814
|
+
output.push(new RichTextLineSegment(segment.span, segment.lineIndex, segment.range, left, segment.top, LayoutQueries.maxFloat(left, segment.right - trailingGlue), segment.bottom, segment.baseline));
|
|
815
|
+
segmentIndex += 1;
|
|
816
|
+
}
|
|
817
|
+
return output;
|
|
818
|
+
}
|
|
819
|
+
static withAdjacentSameStyleClearance(_result, segments) {
|
|
820
|
+
if (segments.length < 2) {
|
|
821
|
+
return segments;
|
|
822
|
+
}
|
|
823
|
+
const output = [];
|
|
824
|
+
let index = 0;
|
|
825
|
+
while (index < segments.length) {
|
|
826
|
+
const segment = segments[index];
|
|
827
|
+
let leadingNeighbour = null;
|
|
828
|
+
let trailingNeighbour = null;
|
|
829
|
+
let otherIndex = 0;
|
|
830
|
+
while (otherIndex < segments.length) {
|
|
831
|
+
const other = segments[otherIndex];
|
|
832
|
+
if (other.lineIndex === segment.lineIndex && LayoutQueries.sameVisibleStyle(segment, other)) {
|
|
833
|
+
if (other.range.end === segment.range.start) {
|
|
834
|
+
leadingNeighbour = other;
|
|
835
|
+
}
|
|
836
|
+
if (other.range.start === segment.range.end) {
|
|
837
|
+
trailingNeighbour = other;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
otherIndex += 1;
|
|
841
|
+
}
|
|
842
|
+
const leadingClearance = LayoutQueries.sharedClearance(segment, leadingNeighbour);
|
|
843
|
+
const trailingClearance = LayoutQueries.sharedClearance(segment, trailingNeighbour);
|
|
844
|
+
const left = LayoutQueries.minFloat(segment.right, segment.left + leadingClearance / 2.0);
|
|
845
|
+
output.push(new RichTextLineSegment(segment.span, segment.lineIndex, segment.range, left, segment.top, LayoutQueries.maxFloat(left, segment.right - trailingClearance / 2.0), segment.bottom, segment.baseline));
|
|
846
|
+
index += 1;
|
|
847
|
+
}
|
|
848
|
+
return output;
|
|
849
|
+
}
|
|
850
|
+
static markedFaceVerticalBounds(result, covered) {
|
|
851
|
+
let top = Infinity;
|
|
852
|
+
let bottom = -Infinity;
|
|
853
|
+
for (let pipeline_index = 0, count10 = covered.length; pipeline_index < count10; pipeline_index += 1) {
|
|
854
|
+
const cluster = covered[pipeline_index];
|
|
855
|
+
const metric = LayoutQueries.lastMetricContaining(result, cluster.range);
|
|
856
|
+
if (metric !== null) {
|
|
857
|
+
top = LayoutQueries.minFloat(top, cluster.baseline - metric.layoutAscent);
|
|
858
|
+
bottom = LayoutQueries.maxFloat(bottom, cluster.baseline + metric.layoutDescent);
|
|
859
|
+
}
|
|
860
|
+
else {
|
|
861
|
+
const style = LayoutQueries.resolvedTextStyleAt(result, cluster.range.start);
|
|
862
|
+
top = LayoutQueries.minFloat(top, cluster.baseline - style.fontSize * LayoutQueries.BACKGROUND_FALLBACK_ASCENT_EM);
|
|
863
|
+
bottom = LayoutQueries.maxFloat(bottom, cluster.baseline + style.fontSize * LayoutQueries.BACKGROUND_FALLBACK_DESCENT_EM);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return [top, bottom];
|
|
867
|
+
}
|
|
868
|
+
static uniformTextStyleVerticalBounds(result, segment, style) {
|
|
869
|
+
let reference = null;
|
|
870
|
+
let firstMatch = null;
|
|
871
|
+
let index = 0;
|
|
872
|
+
while (index < result.debug.metricDecisions.length) {
|
|
873
|
+
const decision = result.debug.metricDecisions[index];
|
|
874
|
+
if (LayoutQueries.sameFontMetricStyle(LayoutQueries.resolvedTextStyleAt(result, decision.range.start), style)) {
|
|
875
|
+
if (firstMatch === null) {
|
|
876
|
+
firstMatch = decision;
|
|
877
|
+
}
|
|
878
|
+
if (decision.metricBox === LayoutQueries.IDEOGRAPHIC_EM_BOX_NAME) {
|
|
879
|
+
reference = decision;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
index += 1;
|
|
883
|
+
}
|
|
884
|
+
if (reference === null) {
|
|
885
|
+
reference = firstMatch;
|
|
886
|
+
}
|
|
887
|
+
const ascent = (reference === null ? style.fontSize * LayoutQueries.BACKGROUND_FALLBACK_ASCENT_EM : reference.layoutAscent);
|
|
888
|
+
const descent = (reference === null ? style.fontSize * LayoutQueries.BACKGROUND_FALLBACK_DESCENT_EM : reference.layoutDescent);
|
|
889
|
+
return [segment.baseline - ascent, segment.baseline + descent];
|
|
890
|
+
}
|
|
891
|
+
static resolvedTextStyleAt(result, offset) {
|
|
892
|
+
let index = result.input.content.spans.length - 1;
|
|
893
|
+
while (index >= 0) {
|
|
894
|
+
const span = result.input.content.spans[index];
|
|
895
|
+
if (offset >= span.range.start && offset < span.range.end) {
|
|
896
|
+
return span.style;
|
|
897
|
+
}
|
|
898
|
+
index -= 1;
|
|
899
|
+
}
|
|
900
|
+
return result.input.textStyle;
|
|
901
|
+
}
|
|
902
|
+
static sameFontMetricStyle(first, second) {
|
|
903
|
+
return LayoutQueries.sameStringArray(first.fontFamilies, second.fontFamilies) && first.fontSize === second.fontSize && first.locale === second.locale && first.fontWeight === second.fontWeight && first.italic === second.italic && first.baselineShift === second.baselineShift;
|
|
904
|
+
}
|
|
905
|
+
static nearestLineForOffset(result, offset) {
|
|
906
|
+
let bestIndex = 0;
|
|
907
|
+
let bestDistance = 2147483647;
|
|
908
|
+
let index = 0;
|
|
909
|
+
while (index < result.lines.length) {
|
|
910
|
+
const line = result.lines[index];
|
|
911
|
+
const distance = (offset < line.range.start ? line.range.start - offset : (offset > line.range.end ? offset - line.range.end : 0));
|
|
912
|
+
if (distance < bestDistance) {
|
|
913
|
+
bestDistance = distance;
|
|
914
|
+
bestIndex = index;
|
|
915
|
+
}
|
|
916
|
+
index += 1;
|
|
917
|
+
}
|
|
918
|
+
return bestIndex;
|
|
919
|
+
}
|
|
920
|
+
static nearestLineForY(result, y) {
|
|
921
|
+
let bestIndex = 0;
|
|
922
|
+
let bestDistance = Infinity;
|
|
923
|
+
let index = 0;
|
|
924
|
+
while (index < result.lines.length) {
|
|
925
|
+
const line = result.lines[index];
|
|
926
|
+
const distance = (y < line.top ? line.top - y : (y > line.bottom ? y - line.bottom : 0.0));
|
|
927
|
+
if (distance < bestDistance) {
|
|
928
|
+
bestDistance = distance;
|
|
929
|
+
bestIndex = index;
|
|
930
|
+
}
|
|
931
|
+
index += 1;
|
|
932
|
+
}
|
|
933
|
+
return bestIndex;
|
|
934
|
+
}
|
|
935
|
+
static nearestCluster(clusters, x) {
|
|
936
|
+
let best = clusters[0];
|
|
937
|
+
let bestDistance = LayoutQueries.distanceToCluster(best, x);
|
|
938
|
+
let index = 1;
|
|
939
|
+
while (index < clusters.length) {
|
|
940
|
+
const candidate = clusters[index];
|
|
941
|
+
const distance = LayoutQueries.distanceToCluster(candidate, x);
|
|
942
|
+
if (distance < bestDistance) {
|
|
943
|
+
best = candidate;
|
|
944
|
+
bestDistance = distance;
|
|
945
|
+
}
|
|
946
|
+
index += 1;
|
|
947
|
+
}
|
|
948
|
+
return best;
|
|
949
|
+
}
|
|
950
|
+
static distanceToCluster(cluster, x) {
|
|
951
|
+
if (x < cluster.left) {
|
|
952
|
+
return cluster.left - x;
|
|
953
|
+
}
|
|
954
|
+
if (x > cluster.right) {
|
|
955
|
+
return x - cluster.right;
|
|
956
|
+
}
|
|
957
|
+
return 0.0;
|
|
958
|
+
}
|
|
959
|
+
static xForOffset(cluster, offset) {
|
|
960
|
+
if (cluster.range.length <= 0) {
|
|
961
|
+
return cluster.left;
|
|
962
|
+
}
|
|
963
|
+
const index = LayoutQueries.clampInt(offset - cluster.range.start, 0, cluster.range.length);
|
|
964
|
+
if (cluster.sourceStops !== null) {
|
|
965
|
+
return cluster.sourceStops[index];
|
|
966
|
+
}
|
|
967
|
+
return cluster.left + cluster.width * (index * 1.0 / cluster.range.length);
|
|
968
|
+
}
|
|
969
|
+
static offsetForX(cluster, x) {
|
|
970
|
+
if (cluster.range.length <= 0) {
|
|
971
|
+
return cluster.range.start;
|
|
972
|
+
}
|
|
973
|
+
if (cluster.sourceStops !== null) {
|
|
974
|
+
let bestIndex = 0;
|
|
975
|
+
let bestDistance = Infinity;
|
|
976
|
+
let index = 0;
|
|
977
|
+
while (index < cluster.sourceStops.length) {
|
|
978
|
+
const distance = Math.abs(x - cluster.sourceStops[index]);
|
|
979
|
+
if (distance < bestDistance) {
|
|
980
|
+
bestDistance = distance;
|
|
981
|
+
bestIndex = index;
|
|
982
|
+
}
|
|
983
|
+
index += 1;
|
|
984
|
+
}
|
|
985
|
+
return LayoutQueries.clampInt(cluster.range.start + bestIndex, cluster.range.start, cluster.range.end);
|
|
986
|
+
}
|
|
987
|
+
if (cluster.width <= 0.0) {
|
|
988
|
+
return cluster.range.start;
|
|
989
|
+
}
|
|
990
|
+
const ratio = LayoutQueries.clampFloat((x - cluster.left) / cluster.width, 0.0, 1.0);
|
|
991
|
+
return LayoutQueries.clampInt(cluster.range.start + Math.round(ratio * cluster.range.length), cluster.range.start, cluster.range.end);
|
|
992
|
+
}
|
|
993
|
+
static sliceRect(cluster, start, end) {
|
|
994
|
+
if (cluster.range.length <= 0 || cluster.width <= 0.0) {
|
|
995
|
+
return cluster.rect;
|
|
996
|
+
}
|
|
997
|
+
return new Rect(LayoutQueries.xForOffset(cluster, start), cluster.top, LayoutQueries.xForOffset(cluster, end), cluster.bottom);
|
|
998
|
+
}
|
|
999
|
+
static sliceRectIfCovered(cluster, start, end) {
|
|
1000
|
+
const sliceStart = LayoutQueries.maxInt(start, cluster.range.start);
|
|
1001
|
+
const sliceEnd = LayoutQueries.minInt(end, cluster.range.end);
|
|
1002
|
+
return (sliceStart < sliceEnd ? LayoutQueries.sliceRect(cluster, sliceStart, sliceEnd) : null);
|
|
1003
|
+
}
|
|
1004
|
+
static glyphsForCluster(result, range) {
|
|
1005
|
+
const output = [];
|
|
1006
|
+
let runIndex = 0;
|
|
1007
|
+
while (runIndex < result.glyphRuns.length) {
|
|
1008
|
+
const glyphs = result.glyphRuns[runIndex].glyphs;
|
|
1009
|
+
let glyphIndex = 0;
|
|
1010
|
+
while (glyphIndex < glyphs.length) {
|
|
1011
|
+
if (LayoutQueries.sameRange(glyphs[glyphIndex].clusterRange, range)) {
|
|
1012
|
+
output.push(glyphs[glyphIndex]);
|
|
1013
|
+
}
|
|
1014
|
+
glyphIndex += 1;
|
|
1015
|
+
}
|
|
1016
|
+
runIndex += 1;
|
|
1017
|
+
}
|
|
1018
|
+
return output;
|
|
1019
|
+
}
|
|
1020
|
+
static naturalLastRight(result, cluster) {
|
|
1021
|
+
const glyphs = LayoutQueries.glyphsForCluster(result, cluster.range);
|
|
1022
|
+
if (glyphs.length === 0) {
|
|
1023
|
+
return cluster.right;
|
|
1024
|
+
}
|
|
1025
|
+
let right = -Infinity;
|
|
1026
|
+
let index = 0;
|
|
1027
|
+
while (index < glyphs.length) {
|
|
1028
|
+
right = LayoutQueries.maxFloat(right, cluster.drawX + glyphs[index].x + glyphs[index].advance);
|
|
1029
|
+
index += 1;
|
|
1030
|
+
}
|
|
1031
|
+
return right;
|
|
1032
|
+
}
|
|
1033
|
+
static centerOfCluster(result, cluster) {
|
|
1034
|
+
const glyphs = LayoutQueries.glyphsForCluster(result, cluster.range);
|
|
1035
|
+
let natural = 0.0;
|
|
1036
|
+
let index = 0;
|
|
1037
|
+
while (index < glyphs.length) {
|
|
1038
|
+
natural += glyphs[index].advance;
|
|
1039
|
+
index += 1;
|
|
1040
|
+
}
|
|
1041
|
+
if (glyphs.length === 0) {
|
|
1042
|
+
natural = cluster.width - LayoutQueries.floatByRangeFromGeometry(result, cluster.range);
|
|
1043
|
+
}
|
|
1044
|
+
return cluster.drawX + LayoutQueries.maxFloat(natural, 0.0) / 2.0;
|
|
1045
|
+
}
|
|
1046
|
+
static floatByRangeFromGeometry(result, range) {
|
|
1047
|
+
let index = 0;
|
|
1048
|
+
while (index < result.debug.geometryDecisions.length) {
|
|
1049
|
+
const decision = result.debug.geometryDecisions[index];
|
|
1050
|
+
if (LayoutQueries.sameRange(decision.range, range) && decision.rubySpread !== 0.0) {
|
|
1051
|
+
return decision.rubySpread;
|
|
1052
|
+
}
|
|
1053
|
+
index += 1;
|
|
1054
|
+
}
|
|
1055
|
+
return 0.0;
|
|
1056
|
+
}
|
|
1057
|
+
static clustersOnSegmentLine(positioned, segment) {
|
|
1058
|
+
const output = [];
|
|
1059
|
+
let index = 0;
|
|
1060
|
+
while (index < positioned.length) {
|
|
1061
|
+
const cluster = positioned[index];
|
|
1062
|
+
if (cluster.lineIndex === segment.lineIndex && cluster.range.end > segment.range.start && cluster.range.start < segment.range.end) {
|
|
1063
|
+
output.push(cluster);
|
|
1064
|
+
}
|
|
1065
|
+
index += 1;
|
|
1066
|
+
}
|
|
1067
|
+
return output;
|
|
1068
|
+
}
|
|
1069
|
+
static findPositionedByRange(positioned, range) {
|
|
1070
|
+
let index = 0;
|
|
1071
|
+
while (index < positioned.length) {
|
|
1072
|
+
if (LayoutQueries.sameRange(positioned[index].range, range)) {
|
|
1073
|
+
return positioned[index];
|
|
1074
|
+
}
|
|
1075
|
+
index += 1;
|
|
1076
|
+
}
|
|
1077
|
+
return null;
|
|
1078
|
+
}
|
|
1079
|
+
static geometryDecisionForRange(result, range) {
|
|
1080
|
+
let found = null;
|
|
1081
|
+
let index = 0;
|
|
1082
|
+
while (index < result.debug.geometryDecisions.length) {
|
|
1083
|
+
const decision = result.debug.geometryDecisions[index];
|
|
1084
|
+
if (LayoutQueries.sameRange(decision.range, range)) {
|
|
1085
|
+
found = decision;
|
|
1086
|
+
}
|
|
1087
|
+
index += 1;
|
|
1088
|
+
}
|
|
1089
|
+
return found;
|
|
1090
|
+
}
|
|
1091
|
+
static lastMetricContaining(result, range) {
|
|
1092
|
+
let found = null;
|
|
1093
|
+
let index = 0;
|
|
1094
|
+
while (index < result.debug.metricDecisions.length) {
|
|
1095
|
+
const decision = result.debug.metricDecisions[index];
|
|
1096
|
+
if (range.start >= decision.range.start && range.end <= decision.range.end) {
|
|
1097
|
+
found = decision;
|
|
1098
|
+
}
|
|
1099
|
+
index += 1;
|
|
1100
|
+
}
|
|
1101
|
+
return found;
|
|
1102
|
+
}
|
|
1103
|
+
static setFloatByRange(values, range, value) {
|
|
1104
|
+
let index = 0;
|
|
1105
|
+
while (index < values.length) {
|
|
1106
|
+
if (LayoutQueries.sameRange(values[index].range, range)) {
|
|
1107
|
+
values[index].value = value;
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
index += 1;
|
|
1111
|
+
}
|
|
1112
|
+
values.push({ range, value });
|
|
1113
|
+
}
|
|
1114
|
+
static floatByRange(values, range) {
|
|
1115
|
+
let index = 0;
|
|
1116
|
+
while (index < values.length) {
|
|
1117
|
+
if (LayoutQueries.sameRange(values[index].range, range)) {
|
|
1118
|
+
return values[index].value;
|
|
1119
|
+
}
|
|
1120
|
+
index += 1;
|
|
1121
|
+
}
|
|
1122
|
+
return 0.0;
|
|
1123
|
+
}
|
|
1124
|
+
static selectionWordKind(text, start, end) {
|
|
1125
|
+
const codePoint = SourceInteractionBoundaries.codePointAtCompat(text, start, end);
|
|
1126
|
+
if (codePoint === LayoutQueries.CR || codePoint === LayoutQueries.LF || codePoint === LayoutQueries.NEL || codePoint === LayoutQueries.LINE_SEPARATOR || codePoint === LayoutQueries.PARAGRAPH_SEPARATOR) {
|
|
1127
|
+
return SelectionWordKind.Single;
|
|
1128
|
+
}
|
|
1129
|
+
if (LayoutQueries.isWhitespace(codePoint)) {
|
|
1130
|
+
return SelectionWordKind.Whitespace;
|
|
1131
|
+
}
|
|
1132
|
+
if (LayoutQueries.isHanIdeograph(codePoint)) {
|
|
1133
|
+
return SelectionWordKind.Single;
|
|
1134
|
+
}
|
|
1135
|
+
if (LayoutQueries.isLetterOrDigit(codePoint) || codePoint === 95 || codePoint === 39 || codePoint === 8217) {
|
|
1136
|
+
return SelectionWordKind.Word;
|
|
1137
|
+
}
|
|
1138
|
+
return SelectionWordKind.Single;
|
|
1139
|
+
}
|
|
1140
|
+
static isWhitespace(codePoint) {
|
|
1141
|
+
return codePoint >= 9 && codePoint <= 13 || codePoint >= 28 && codePoint <= 32 || codePoint === 160 || codePoint === 5760 || codePoint >= 8192 && codePoint <= 8202 || codePoint === 8232 || codePoint === 8233 || codePoint === 8239 || codePoint === 8287 || codePoint === 12288;
|
|
1142
|
+
}
|
|
1143
|
+
static isLetterOrDigit(codePoint) {
|
|
1144
|
+
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
1145
|
+
return false;
|
|
1146
|
+
}
|
|
1147
|
+
if (codePoint >= 65 && codePoint <= 90 || codePoint >= 97 && codePoint <= 122 || codePoint >= 48 && codePoint <= 57) {
|
|
1148
|
+
return true;
|
|
1149
|
+
}
|
|
1150
|
+
if (codePoint < 0 || codePoint > 1114111) {
|
|
1151
|
+
return false;
|
|
1152
|
+
}
|
|
1153
|
+
return UnicodeWordCharacterData.contains(codePoint);
|
|
1154
|
+
}
|
|
1155
|
+
static isHanIdeograph(codePoint) {
|
|
1156
|
+
return codePoint >= 13312 && codePoint <= 19903 || codePoint >= 19968 && codePoint <= 40959 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 131072 && codePoint <= 205743;
|
|
1157
|
+
}
|
|
1158
|
+
static boundaryIndex(boundaries, offset) {
|
|
1159
|
+
let low = 0;
|
|
1160
|
+
let high = boundaries.length - 1;
|
|
1161
|
+
while (low <= high) {
|
|
1162
|
+
const middle = low + high >> 1;
|
|
1163
|
+
const value = boundaries[middle];
|
|
1164
|
+
if (value === offset) {
|
|
1165
|
+
return (middle === boundaries.length - 1 ? middle - 1 : middle);
|
|
1166
|
+
}
|
|
1167
|
+
if (value < offset) {
|
|
1168
|
+
low = middle + 1;
|
|
1169
|
+
}
|
|
1170
|
+
else {
|
|
1171
|
+
high = middle - 1;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
return LayoutQueries.maxInt(0, high);
|
|
1175
|
+
}
|
|
1176
|
+
static addCopyAnnotation(values, baseRange, text, start, end) {
|
|
1177
|
+
if (baseRange.start >= start && baseRange.end <= end) {
|
|
1178
|
+
values.push({ end: baseRange.end, text });
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
static insertionSortAnnotations(values) {
|
|
1182
|
+
let index = 1;
|
|
1183
|
+
while (index < values.length) {
|
|
1184
|
+
const value = values[index];
|
|
1185
|
+
let cursor = index - 1;
|
|
1186
|
+
while (cursor >= 0 && values[cursor].end > value.end) {
|
|
1187
|
+
values[cursor + 1] = values[cursor];
|
|
1188
|
+
cursor -= 1;
|
|
1189
|
+
}
|
|
1190
|
+
values[cursor + 1] = value;
|
|
1191
|
+
index += 1;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
static sameRange(first, second) {
|
|
1195
|
+
return first.start === second.start && first.end === second.end;
|
|
1196
|
+
}
|
|
1197
|
+
static sameStringArray(first, second) {
|
|
1198
|
+
if (first.length !== second.length) {
|
|
1199
|
+
return false;
|
|
1200
|
+
}
|
|
1201
|
+
let index = 0;
|
|
1202
|
+
while (index < first.length) {
|
|
1203
|
+
if (first[index] !== second[index]) {
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
index += 1;
|
|
1207
|
+
}
|
|
1208
|
+
return true;
|
|
1209
|
+
}
|
|
1210
|
+
static sameVisibleStyle(first, second) {
|
|
1211
|
+
return RichTextSpan.sameRole(first.span.role, second.span.role) && first.span.paint.sameVisibleStyle(second.span.paint);
|
|
1212
|
+
}
|
|
1213
|
+
static sharedClearance(segment, neighbour) {
|
|
1214
|
+
if (neighbour === null || !LayoutQueries.sameVisibleStyle(segment, (neighbour))) {
|
|
1215
|
+
return 0.0;
|
|
1216
|
+
}
|
|
1217
|
+
return LayoutQueries.minFloat(segment.span.paint.adjacentSameStyleClearance, neighbour.span.paint.adjacentSameStyleClearance);
|
|
1218
|
+
}
|
|
1219
|
+
static isDecorationRole(role) {
|
|
1220
|
+
if (role instanceof Underline || role instanceof LineThrough) {
|
|
1221
|
+
return true;
|
|
1222
|
+
}
|
|
1223
|
+
return false;
|
|
1224
|
+
}
|
|
1225
|
+
static isBackgroundRole(role) {
|
|
1226
|
+
if (role instanceof Background || role instanceof InlineCode) {
|
|
1227
|
+
return true;
|
|
1228
|
+
}
|
|
1229
|
+
return false;
|
|
1230
|
+
}
|
|
1231
|
+
static resolveRadius(radius, inset, maximum) {
|
|
1232
|
+
return LayoutQueries.clampFloat(radius - inset, 0.0, maximum);
|
|
1233
|
+
}
|
|
1234
|
+
static requireFiniteNonNegative(value, message) {
|
|
1235
|
+
if (!LayoutQueries.isFinite(value) || value < 0.0) {
|
|
1236
|
+
throw new TiqianIllegalArgumentException({ kind: "Message", text: message });
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
static isFinite(value) {
|
|
1240
|
+
return value === value && value !== Infinity && value !== -Infinity;
|
|
1241
|
+
}
|
|
1242
|
+
static clampInt(value, low, high) {
|
|
1243
|
+
if (value < low) {
|
|
1244
|
+
return low;
|
|
1245
|
+
}
|
|
1246
|
+
if (value > high) {
|
|
1247
|
+
return high;
|
|
1248
|
+
}
|
|
1249
|
+
return value;
|
|
1250
|
+
}
|
|
1251
|
+
static maxInt(first, second) {
|
|
1252
|
+
return (first > second ? first : second);
|
|
1253
|
+
}
|
|
1254
|
+
static minInt(first, second) {
|
|
1255
|
+
return (first < second ? first : second);
|
|
1256
|
+
}
|
|
1257
|
+
static clampFloat(value, low, high) {
|
|
1258
|
+
if (value < low) {
|
|
1259
|
+
return low;
|
|
1260
|
+
}
|
|
1261
|
+
if (value > high) {
|
|
1262
|
+
return high;
|
|
1263
|
+
}
|
|
1264
|
+
return value;
|
|
1265
|
+
}
|
|
1266
|
+
static maxFloat(first, second) {
|
|
1267
|
+
return (first > second ? first : second);
|
|
1268
|
+
}
|
|
1269
|
+
static minFloat(first, second) {
|
|
1270
|
+
return (first < second ? first : second);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
export const SelectionWordKind = Object.freeze({
|
|
1274
|
+
Word: Object.freeze({ kind: "Word" }),
|
|
1275
|
+
Whitespace: Object.freeze({ kind: "Whitespace" }),
|
|
1276
|
+
Single: Object.freeze({ kind: "Single" })
|
|
1277
|
+
});
|
|
1278
|
+
export function compareSelectionWordKind(a, b) {
|
|
1279
|
+
if (a === b)
|
|
1280
|
+
return 0;
|
|
1281
|
+
if (a.kind === "Word")
|
|
1282
|
+
return 0 - (b.kind === "Word" ? 0 : 0);
|
|
1283
|
+
if (a.kind === "Whitespace")
|
|
1284
|
+
return 1 - (b.kind === "Whitespace" ? 1 : 0);
|
|
1285
|
+
if (a.kind === "Single")
|
|
1286
|
+
return 2 - (b.kind === "Single" ? 2 : 0);
|
|
1287
|
+
return 0;
|
|
1288
|
+
}
|
|
1289
|
+
export function compareCopyAnnotation(a, b) {
|
|
1290
|
+
if (a === b)
|
|
1291
|
+
return 0;
|
|
1292
|
+
if (a.end !== b.end)
|
|
1293
|
+
return a.end - b.end;
|
|
1294
|
+
if (a.text !== b.text)
|
|
1295
|
+
return a.text < b.text ? -1 : 1;
|
|
1296
|
+
return 0;
|
|
1297
|
+
}
|