-
mitz@apple.com authored
2009-04-09 Dan Bernstein <mitz@apple.com> Reviewed by Dave Hyatt. - fix <rdar://problem/6166612> Text boxes' metrics should be based on the actual fonts used in them, not just the primary font Covered by many existing layout tests * platform/graphics/Font.cpp: (WebCore::Font::floatWidth): Added a fallbackFonts parameter. If the platform supports collecting fallback fonts in its complex font path and fallbackFonts is not null, all fallback fonts used for the text run will be added to it. * platform/graphics/Font.h: (WebCore::Font::width): Ditto. * platform/graphics/FontFastPath.cpp: (WebCore::Font::glyphDataForCharacter): Removed an unnecessary namespace qualifier. (WebCore::Font::floatWidthForSimpleText): Added a fallbackFonts parameter, which is passed down to WidthIterator. * platform/graphics/WidthIterator.cpp: (WebCore::WidthIterator::WidthIterator): Added a fallbackFonts parameter and used it to initialize the m_fallbackFonts member. (WebCore::WidthIterator::advance): Track the fonts being used and add any fallback fonts to the m_fallbackFonts set. Make sure to only add non-small-caps fonts. * platform/graphics/WidthIterator.h: * platform/graphics/chromium/FontChromiumWin.cpp: (WebCore::Font::canReturnFallbackFontsForComplexText): Added an implementation that returns false, meaning this platform's implementation of floatWidthForComplexText() does not populate the fallbackFonts set. (WebCore::Font::floatWidthForComplexText): Updated for the new prototype. * platform/graphics/chromium/FontLinux.cpp: Ditto. * platform/graphics/gtk/FontGtk.cpp: Ditto. * platform/graphics/mac/CoreTextController.cpp: (WebCore::CoreTextController::CoreTextController): Added a fallbackFonts parameter and used it to initialize the m_fallbackFonts member. (WebCore::CoreTextController::collectCoreTextRunsForCharacters): Add fallback fonts to m_fallbackFonts. * platform/graphics/mac/CoreTextController.h: * platform/graphics/mac/FontMac.mm: (WebCore::Font::canReturnFallbackFontsForComplexText): Added an implementation that returns true, indicating that the Mac implementations of floatWidthForComplexText() populate the fallbackFonts set. * platform/graphics/mac/FontMacATSUI.mm: (WebCore::ATSULayoutParameters::ATSULayoutParameters): Added a fallbackFonts parameter and used it to initialize the m_fallbackFonts member. (WebCore::ATSULayoutParameters::initialize): Add fallback fonts to m_fallbackFonts. (WebCore::Font::floatWidthForComplexText): Added a fallbackFonts parameter, which is passed down to ATSULayoutParameters. * platform/graphics/mac/FontMacCoreText.cpp: (WebCore::Font::floatWidthForComplexText): Added a fallbackFonts parameter, which is passed down to CoreTextController. * platform/graphics/win/FontWin.cpp: (WebCore::Font::canReturnFallbackFontsForComplexText): Added an implementation that returns true, indicating that the UniscribeController-based implementations of floatWidthForComplexText() populate the fallbackFonts set. (WebCore::Font::floatWidthForComplexText): Added a fallbackFonts parameter, which is passed down to UniscribeController. * platform/graphics/win/UniscribeController.cpp: (WebCore::UniscribeController::UniscribeController): Added a fallbackfonts parameter and used it to initialize m_fallbackFonts. (WebCore::UniscribeController::advance): Add fallback fonts to m_fallbackFonts. * platform/graphics/win/UniscribeController.h: * platform/graphics/wx/FontWx.cpp: (WebCore::Font::canReturnFallbackFontsForComplexText): Added an implementation that returns false, meaning this platform's implementation of floatWidthForComplexText() does not populate the fallbackFonts set. (WebCore::Font::floatWidthForComplexText): Updated for the new prototype. * rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::computeLogicalBoxHeights): For an InlineTextBox with multiple fonts, compute a common baseline and line height by considering all fonts' ascents and descents (and line spacing, if applicable). * rendering/InlineTextBox.cpp: (WebCore::InlineTextBox::setFallbackFonts): Added. Temporarily stores the set of fallback fonts in a vector. (WebCore::InlineTextBox::takeFallbackFonts): Added. Returns the fallback fonts previously stored and removes them from storage. * rendering/InlineTextBox.h: * rendering/RenderText.cpp: (WebCore::RenderText::RenderText): Initialized the m_knownNotToUseFallbackFonts to false. (WebCore::RenderText::styleDidChange): Reset m_knownNotToUseFallbackFonts to false if the style difference is such that affects layout. (WebCore::RenderText::widthFromCache): Added a fallbackFonts parameter, which is passed down to Font::width(). (WebCore::RenderText::trimmedPrefWidths): Updated for the change to widthFromCache(). (WebCore::RenderText::calcPrefWidths): Made this call a private version of calcPrefWidths() that takes a fallbackFonts parameter and set the m_knownNotToUseFallbackFonts to true if the set comes back empty. The private version passes the fallbackFonts set to widthFromCache(). (WebCore::RenderText::setText): Reset m_knownNotToUseFallbackFonts to false. (WebCore::RenderText::createFallbackFontMetricsBox): Added. (WebCore::RenderText::width): Added a fallbackFonts parameter, which is passed down to calcPrefWidths(), widthFromCache() and Font::width(). Set m_knownNotToUseFallbackFonts to true when appropriate. * rendering/RenderText.h: * rendering/bidi.cpp: (WebCore::RenderBlock::constructLine): Added an assertion and a continue statement to remove one level of indentation. (WebCore::RenderBlock::computeHorizontalPositionsForLine): Temporarily store the set of fallback fonts in the InlineTextBox. (WebCore::RenderBlock::computeVerticalPositionsForLine): Added an assertion. LayoutTests: 2009-04-09 Dan Bernstein <mitz@apple.com> Reviewed by Dave Hyatt. - updated results for <rdar://problem/6166612> Text boxes' metrics should be based on the actual fonts used in them, not just the primary font * editing/selection/extend-selection-bidi-expected.txt: * fast/text/offsetForPosition-cluster-at-zero-expected.txt: * platform/mac-leopard/fast/text/atsui-multiple-renderers-expected.checksum: * platform/mac-leopard/fast/text/atsui-multiple-renderers-expected.png: * platform/mac-leopard/fast/text/atsui-multiple-renderers-expected.txt: * platform/mac-leopard/fast/text/international/bidi-AN-after-empty-run-expected.checksum: * platform/mac-leopard/fast/text/international/bidi-AN-after-empty-run-expected.png: * platform/mac-leopard/fast/text/international/bidi-AN-after-empty-run-expected.txt: * platform/mac-leopard/fast/text/international/bidi-CS-after-AN-expected.checksum: * platform/mac-leopard/fast/text/international/bidi-CS-after-AN-expected.png: * platform/mac-leopard/fast/text/international/bidi-CS-after-AN-expected.txt: * platform/mac-leopard/fast/text/international/bidi-neutral-run-expected.checksum: * platform/mac-leopard/fast/text/international/bidi-neutral-run-expected.png: * platform/mac-leopard/fast/text/international/bidi-neutral-run-expected.txt: * platform/mac/css2.1/t0805-c5518-brdr-t-01-e-expected.checksum: * platform/mac/css2.1/t0805-c5518-brdr-t-01-e-expected.png: * platform/mac/css2.1/t0805-c5518-brdr-t-01-e-expected.txt: * platform/mac/css2.1/t0805-c5519-brdr-r-00-a-expected.checksum: * platform/mac/css2.1/t0805-c5519-brdr-r-00-a-expected.png: * platform/mac/css2.1/t0805-c5519-brdr-r-00-a-expected.txt: * platform/mac/css2.1/t0805-c5520-brdr-b-01-e-expected.checksum: * platform/mac/css2.1/t0805-c5520-brdr-b-01-e-expected.png: * platform/mac/css2.1/t0805-c5520-brdr-b-01-e-expected.txt: * platform/mac/css2.1/t0805-c5521-brdr-l-00-a-expected.checksum: * platform/mac/css2.1/t0805-c5521-brdr-l-00-a-expected.png: * platform/mac/css2.1/t0805-c5521-brdr-l-00-a-expected.txt: * platform/mac/css2.1/t0805-c5521-brdr-l-01-e-expected.checksum: * platform/mac/css2.1/t0805-c5521-brdr-l-01-e-expected.png: * platform/mac/css2.1/t0805-c5521-brdr-l-01-e-expected.txt: * platform/mac/css2.1/t0805-c5521-ibrdr-l-00-a-expected.checksum: * platform/mac/css2.1/t0805-c5521-ibrdr-l-00-a-expected.png: * platform/mac/css2.1/t0805-c5521-ibrdr-l-00-a-expected.txt: * platform/mac/css2.1/t0905-c414-flt-02-c-expected.checksum: * platform/mac/css2.1/t0905-c414-flt-02-c-expected.png: * platform/mac/css2.1/t0905-c414-flt-02-c-expected.txt: * platform/mac/css2.1/t0905-c414-flt-03-c-expected.checksum: * platform/mac/css2.1/t0905-c414-flt-03-c-expected.png: * platform/mac/css2.1/t0905-c414-flt-03-c-expected.txt: * platform/mac/css2.1/t0905-c414-flt-04-c-expected.checksum: * platform/mac/css2.1/t0905-c414-flt-04-c-expected.png: * platform/mac/css2.1/t0905-c414-flt-04-c-expected.txt: * platform/mac/css2.1/t0905-c414-flt-fit-01-d-g-expected.checksum: * platform/mac/css2.1/t0905-c414-flt-fit-01-d-g-expected.png: * platform/mac/css2.1/t0905-c414-flt-fit-01-d-g-expected.txt: * platform/mac/css2.1/t0905-c5525-fltblck-01-d-expected.checksum: * platform/mac/css2.1/t0905-c5525-fltblck-01-d-expected.png: * platform/mac/css2.1/t0905-c5525-fltblck-01-d-expected.txt: * platform/mac/css2.1/t0905-c5525-fltcont-00-d-g-expected.checksum: * platform/mac/css2.1/t0905-c5525-fltcont-00-d-g-expected.png: * platform/mac/css2.1/t0905-c5525-fltcont-00-d-g-expected.txt: * platform/mac/css2.1/t0905-c5525-fltwidth-00-c-g-expected.checksum: * platform/mac/css2.1/t0905-c5525-fltwidth-00-c-g-expected.png: * platform/mac/css2.1/t0905-c5525-fltwidth-00-c-g-expected.txt: * platform/mac/css2.1/t0905-c5525-fltwidth-02-c-g-expected.checksum: * platform/mac/css2.1/t0905-c5525-fltwidth-02-c-g-expected.png: * platform/mac/css2.1/t0905-c5525-fltwidth-02-c-g-expected.txt: * platform/mac/css2.1/t0905-c5525-fltwidth-03-c-g-expected.checksum: * platform/mac/css2.1/t0905-c5525-fltwidth-03-c-g-expected.png: * platform/mac/css2.1/t0905-c5525-fltwidth-03-c-g-expected.txt: * platform/mac/css2.1/t0905-c5525-fltwrap-00-b-expected.checksum: * platform/mac/css2.1/t0905-c5525-fltwrap-00-b-expected.png: * platform/mac/css2.1/t0905-c5525-fltwrap-00-b-expected.txt: * platform/mac/css2.1/t090501-c414-flt-01-b-expected.checksum: * platform/mac/css2.1/t090501-c414-flt-01-b-expected.png: * platform/mac/css2.1/t090501-c414-flt-01-b-expected.txt: * platform/mac/css2.1/t090501-c414-flt-03-b-g-expected.checksum: * platform/mac/css2.1/t090501-c414-flt-03-b-g-expected.png: * platform/mac/css2.1/t090501-c414-flt-03-b-g-expected.txt: * platform/mac/css2.1/t090501-c5525-flt-l-00-b-g-expected.checksum: * platform/mac/css2.1/t090501-c5525-flt-l-00-b-g-expected.png: * platform/mac/css2.1/t090501-c5525-flt-l-00-b-g-expected.txt: * platform/mac/css2.1/t090501-c5525-flt-r-00-b-g-expected.checksum: * platform/mac/css2.1/t090501-c5525-flt-r-00-b-g-expected.png: * platform/mac/css2.1/t090501-c5525-flt-r-00-b-g-expected.txt: * platform/mac/css2.1/t100304-c43-rpl-bbx-01-d-g-expected.checksum: * platform/mac/css2.1/t100304-c43-rpl-bbx-01-d-g-expected.png: * platform/mac/css2.1/t100304-c43-rpl-bbx-01-d-g-expected.txt: * platform/mac/css2.1/t1202-counter-03-b-expected.checksum: * platform/mac/css2.1/t1202-counter-03-b-expected.png: * platform/mac/css2.1/t1202-counter-03-b-expected.txt: * platform/mac/css2.1/t1202-counter-04-b-expected.checksum: * platform/mac/css2.1/t1202-counter-04-b-expected.png: * platform/mac/css2.1/t1202-counter-04-b-expected.txt: * platform/mac/css2.1/t1202-counter-09-b-expected.checksum: * platform/mac/css2.1/t1202-counter-09-b-expected.png: * platform/mac/css2.1/t1202-counter-09-b-expected.txt: * platform/mac/css2.1/t1202-counters-03-b-expected.checksum: * platform/mac/css2.1/t1202-counters-03-b-expected.png: * platform/mac/css2.1/t1202-counters-03-b-expected.txt: * platform/mac/css2.1/t1202-counters-04-b-expected.checksum: * platform/mac/css2.1/t1202-counters-04-b-expected.png: * platform/mac/css2.1/t1202-counters-04-b-expected.txt: * platform/mac/css2.1/t1202-counters-09-b-expected.checksum: * platform/mac/css2.1/t1202-counters-09-b-expected.png: * platform/mac/css2.1/t1202-counters-09-b-expected.txt: * platform/mac/editing/deleting/5144139-2-expected.checksum: * platform/mac/editing/deleting/5144139-2-expected.png: * platform/mac/editing/deleting/5144139-2-expected.txt: * platform/mac/editing/input/devanagari-ligature-expected.checksum: * platform/mac/editing/input/devanagari-ligature-expected.png: * platform/mac/editing/input/devanagari-ligature-expected.txt: * platform/mac/editing/pasteboard/copy-paste-bidi-expected.checksum: * platform/mac/editing/pasteboard/copy-paste-bidi-expected.png: * platform/mac/editing/pasteboard/copy-paste-bidi-expected.txt: * platform/mac/editing/selection/caret-rtl-2-expected.checksum: * platform/mac/editing/selection/caret-rtl-2-expected.png: * platform/mac/editing/selection/caret-rtl-2-expected.txt: * platform/mac/editing/selection/caret-rtl-expected.checksum: * platform/mac/editing/selection/caret-rtl-expected.png: * platform/mac/editing/selection/caret-rtl-expected.txt: * platform/mac/editing/selection/extend-selection-bidi-expected.checksum: * platform/mac/editing/selection/extend-selection-bidi-expected.png: * platform/mac/fast/css/beforeSelectorOnCodeElement-expected.checksum: * platform/mac/fast/css/beforeSelectorOnCodeElement-expected.png: * platform/mac/fast/css/beforeSelectorOnCodeElement-expected.txt: * platform/mac/fast/css/rtl-ordering-expected.checksum: * platform/mac/fast/css/rtl-ordering-expected.png: * platform/mac/fast/css/rtl-ordering-expected.txt: * platform/mac/fast/css/text-overflow-ellipsis-expected.checksum: * platform/mac/fast/css/text-overflow-ellipsis-expected.png: * platform/mac/fast/css/text-overflow-ellipsis-expected.txt: * platform/mac/fast/css/text-security-expected.checksum: * platform/mac/fast/css/text-security-expected.png: * platform/mac/fast/css/text-security-expected.txt: * platform/mac/fast/encoding/denormalised-voiced-japanese-chars-expected.checksum: * platform/mac/fast/encoding/denormalised-voiced-japanese-chars-expected.png: * platform/mac/fast/encoding/denormalised-voiced-japanese-chars-expected.txt: * platform/mac/fast/encoding/invalid-UTF-8-expected.checksum: * platform/mac/fast/encoding/invalid-UTF-8-expected.png: * platform/mac/fast/encoding/invalid-UTF-8-expected.txt: * platform/mac/fast/events/updateLayoutForHitTest-expected.checksum: * platform/mac/fast/events/updateLayoutForHitTest-expected.png: * platform/mac/fast/events/updateLayoutForHitTest-expected.txt: * platform/mac/fast/forms/select-visual-hebrew-expected.checksum: * platform/mac/fast/forms/select-visual-hebrew-expected.png: * platform/mac/fast/forms/select-visual-hebrew-expected.txt: * platform/mac/fast/forms/select-writing-direction-natural-expected.checksum: * platform/mac/fast/forms/select-writing-direction-natural-expected.png: * platform/mac/fast/forms/select-writing-direction-natural-expected.txt: * platform/mac/fast/forms/visual-hebrew-text-field-expected.checksum: * platform/mac/fast/forms/visual-hebrew-text-field-expected.png: * platform/mac/fast/forms/visual-hebrew-text-field-expected.txt: * platform/mac/fast/lists/w3-list-styles-expected.checksum: * platform/mac/fast/lists/w3-list-styles-expected.png: * platform/mac/fast/lists/w3-list-styles-expected.txt: * platform/mac/fast/text/bidi-embedding-pop-and-push-same-expected.checksum: * platform/mac/fast/text/bidi-embedding-pop-and-push-same-expected.png: * platform/mac/fast/text/bidi-embedding-pop-and-push-same-expected.txt: * platform/mac/fast/text/capitalize-boundaries-expected.checksum: * platform/mac/fast/text/capitalize-boundaries-expected.png: * platform/mac/fast/text/capitalize-boundaries-expected.txt: * platform/mac/fast/text/cg-fallback-bolding-expected.checksum: * platform/mac/fast/text/cg-fallback-bolding-expected.png: * platform/mac/fast/text/cg-fallback-bolding-expected.txt: * platform/mac/fast/text/complex-text-opacity-expected.checksum: * platform/mac/fast/text/complex-text-opacity-expected.png: * platform/mac/fast/text/complex-text-opacity-expected.txt: * platform/mac/fast/text/in-rendered-text-rtl-expected.checksum: * platform/mac/fast/text/in-rendered-text-rtl-expected.png: * platform/mac/fast/text/in-rendered-text-rtl-expected.txt: * platform/mac/fast/text/international/001-expected.checksum: * platform/mac/fast/text/international/001-expected.png: * platform/mac/fast/text/international/001-expected.txt: * platform/mac/fast/text/international/002-expected.checksum: * platform/mac/fast/text/international/002-expected.png: * platform/mac/fast/text/international/002-expected.txt: * platform/mac/fast/text/international/003-expected.checksum: * platform/mac/fast/text/international/003-expected.png: * platform/mac/fast/text/international/003-expected.txt: * platform/mac/fast/text/international/bidi-AN-after-L-expected.checksum: * platform/mac/fast/text/international/bidi-AN-after-L-expected.png: * platform/mac/fast/text/international/bidi-AN-after-L-expected.txt: * platform/mac/fast/text/international/bidi-L2-run-reordering-expected.checksum: * platform/mac/fast/text/international/bidi-L2-run-reordering-expected.png: * platform/mac/fast/text/international/bidi-L2-run-reordering-expected.txt: * platform/mac/fast/text/international/bidi-LDB-2-CSS-expected.checksum: * platform/mac/fast/text/international/bidi-LDB-2-CSS-expected.png: * platform/mac/fast/text/international/bidi-LDB-2-CSS-expected.txt: * platform/mac/fast/text/international/bidi-LDB-2-HTML-expected.checksum: * platform/mac/fast/text/international/bidi-LDB-2-HTML-expected.png: * platform/mac/fast/text/international/bidi-LDB-2-HTML-expected.txt: * platform/mac/fast/text/international/bidi-LDB-2-formatting-characters-expected.checksum: * platform/mac/fast/text/international/bidi-LDB-2-formatting-characters-expected.png: * platform/mac/fast/text/international/bidi-LDB-2-formatting-characters-expected.txt: * platform/mac/fast/text/international/bidi-european-terminators-expected.checksum: * platform/mac/fast/text/international/bidi-european-terminators-expected.png: * platform/mac/fast/text/international/bidi-european-terminators-expected.txt: * platform/mac/fast/text/international/bidi-fallback-font-weight-expected.checksum: * platform/mac/fast/text/international/bidi-fallback-font-weight-expected.png: * platform/mac/fast/text/international/bidi-fallback-font-weight-expected.txt: * platform/mac/fast/text/international/bidi-ignored-for-first-child-inline-expected.checksum: * platform/mac/fast/text/international/bidi-ignored-for-first-child-inline-expected.png: * platform/mac/fast/text/international/bidi-ignored-for-first-child-inline-expected.txt: * platform/mac/fast/text/international/bidi-innertext-expected.checksum: * platform/mac/fast/text/international/bidi-innertext-expected.png: * platform/mac/fast/text/international/bidi-innertext-expected.txt: * platform/mac/fast/text/international/bidi-linebreak-001-expected.checksum: * platform/mac/fast/text/international/bidi-linebreak-001-expected.png: * platform/mac/fast/text/international/bidi-linebreak-001-expected.txt: * platform/mac/fast/text/international/bidi-linebreak-002-expected.checksum: * platform/mac/fast/text/international/bidi-linebreak-002-expected.png: * platform/mac/fast/text/international/bidi-linebreak-002-expected.txt: * platform/mac/fast/text/international/bidi-linebreak-003-expected.checksum: * platform/mac/fast/text/international/bidi-linebreak-003-expected.png: * platform/mac/fast/text/international/bidi-linebreak-003-expected.txt: * platform/mac/fast/text/international/bidi-listbox-atsui-expected.checksum: * platform/mac/fast/text/international/bidi-listbox-atsui-expected.png: * platform/mac/fast/text/international/bidi-listbox-atsui-expected.txt: * platform/mac/fast/text/international/bidi-listbox-expected.checksum: * platform/mac/fast/text/international/bidi-listbox-expected.png: * platform/mac/fast/text/international/bidi-listbox-expected.txt: * platform/mac/fast/text/international/bidi-menulist-expected.checksum: * platform/mac/fast/text/international/bidi-menulist-expected.png: * platform/mac/fast/text/international/bidi-menulist-expected.txt: * platform/mac/fast/text/international/bidi-neutral-directionality-paragraph-start-expected.checksum: * platform/mac/fast/text/international/bidi-neutral-directionality-paragraph-start-expected.png: * platform/mac/fast/text/international/bidi-neutral-directionality-paragraph-start-expected.txt: * platform/mac/fast/text/international/bidi-override-expected.checksum: * platform/mac/fast/text/international/bidi-override-expected.png: * platform/mac/fast/text/international/bidi-override-expected.txt: * platform/mac/fast/text/international/hindi-spacing-expected.checksum: * platform/mac/fast/text/international/hindi-spacing-expected.png: * platform/mac/fast/text/international/hindi-spacing-expected.txt: * platform/mac/fast/text/international/rtl-caret-expected.checksum: * platform/mac/fast/text/international/rtl-caret-expected.png: * platform/mac/fast/text/international/rtl-caret-expected.txt: * platform/mac/fast/text/international/thai-line-breaks-expected.checksum: * platform/mac/fast/text/international/thai-line-breaks-expected.png: * platform/mac/fast/text/international/thai-line-breaks-expected.txt: * platform/mac/fast/text/international/wrap-CJK-001-expected.checksum: * platform/mac/fast/text/international/wrap-CJK-001-expected.png: * platform/mac/fast/text/international/wrap-CJK-001-expected.txt: * platform/mac/fast/text/wide-zero-width-space-expected.checksum: * platform/mac/fast/text/wide-zero-width-space-expected.png: * platform/mac/fast/text/wide-zero-width-space-expected.txt: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@42379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
aa6ce3d8