Changeset 207271 in webkit
- Timestamp:
- Oct 12, 2016 7:28:46 PM (8 years ago)
- Location:
- branches/safari-602-branch/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-602-branch/Source/WebCore/ChangeLog
r207212 r207271 1 2016-08-25 Brent Fulgham <bfulgham@apple.com> 2 3 Merge r205031. rdar://problem/28216249 4 5 2016-08-25 Brent Fulgham <bfulgham@apple.com> 6 7 Crash when getting font bounding rect 8 https://bugs.webkit.org/show_bug.cgi?id=161202 9 <rdar://problem/27986981> 10 11 Reviewed by Myles C. Maxfield. 12 13 We should never store GlyphData objects for later use, because they contain raw pointers to Font elements 14 contained in caches, and those font caches get periodically purged. 15 16 Instead, we should hold onto the ‘key’ representing the GlyphData, and simply ask the system for the 17 GlyphData the next time it is needed. 18 19 Tested by existing MathML tests under ASAN and GuardMalloc. 20 21 * rendering/mathml/RenderMathMLToken.cpp: 22 (WebCore::RenderMathMLToken::RenderMathMLToken): Clean up constructors. 23 (WebCore::RenderMathMLToken::computePreferredLogicalWidths): Use keys to get correct GlyphData when needed. 24 (WebCore::RenderMathMLToken::updateMathVariantGlyph): Ditto. 25 (WebCore::RenderMathMLToken::firstLineBaseline): Ditto. 26 (WebCore::RenderMathMLToken::layoutBlock): Ditto. 27 (WebCore::RenderMathMLToken::paint): Ditto. 28 (WebCore::RenderMathMLToken::paintChildren): Ditto. 29 * rendering/mathml/RenderMathMLToken.h: 30 1 31 2016-10-12 Matthew Hanson <matthew_hanson@apple.com> 2 32 -
branches/safari-602-branch/Source/WebCore/rendering/mathml/RenderMathMLToken.cpp
r203280 r207271 2 2 * Copyright (C) 2014 Frédéric Wang (fred.wang@free.fr). All rights reserved. 3 3 * Copyright (C) 2016 Igalia S.L. 4 * Copyright (C) 2016 Apple Inc. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 41 42 RenderMathMLToken::RenderMathMLToken(Element& element, RenderStyle&& style) 42 43 : RenderMathMLBlock(element, WTFMove(style)) 43 , m_mathVariantGlyph()44 , m_mathVariantGlyphDirty(false)45 44 { 46 45 } … … 48 47 RenderMathMLToken::RenderMathMLToken(Document& document, RenderStyle&& style) 49 48 : RenderMathMLBlock(document, WTFMove(style)) 50 , m_mathVariantGlyph()51 , m_mathVariantGlyphDirty(false)52 49 { 53 50 } … … 497 494 updateMathVariantGlyph(); 498 495 499 if (m_mathVariantGlyph.font) { 500 m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = m_mathVariantGlyph.font->widthForGlyph(m_mathVariantGlyph.glyph); 501 setPreferredLogicalWidthsDirty(false); 502 return; 496 if (m_mathVariantCodePoint) { 497 auto mathVariantGlyph = style().fontCascade().glyphDataForCharacter(m_mathVariantCodePoint.value(), m_mathVariantIsMirrored); 498 if (mathVariantGlyph.font) { 499 m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = mathVariantGlyph.font->widthForGlyph(mathVariantGlyph.glyph); 500 setPreferredLogicalWidthsDirty(false); 501 return; 502 } 503 503 } 504 504 … … 510 510 ASSERT(m_mathVariantGlyphDirty); 511 511 512 m_mathVariant Glyph = GlyphData();512 m_mathVariantCodePoint = Nullopt; 513 513 m_mathVariantGlyphDirty = false; 514 514 … … 528 528 mathvariant = tokenElement.hasTagName(MathMLNames::miTag) ? MathMLStyle::Italic : MathMLStyle::Normal; 529 529 UChar32 transformedCodePoint = mathVariant(codePoint, mathvariant); 530 if (transformedCodePoint != codePoint) 531 m_mathVariantGlyph = style().fontCascade().glyphDataForCharacter(transformedCodePoint, !style().isLeftToRightDirection()); 530 if (transformedCodePoint != codePoint) { 531 m_mathVariantCodePoint = mathVariant(codePoint, mathvariant); 532 m_mathVariantIsMirrored = !style().isLeftToRightDirection(); 533 } 532 534 } 533 535 } … … 547 549 Optional<int> RenderMathMLToken::firstLineBaseline() const 548 550 { 549 if (m_mathVariantGlyph.font) 550 return Optional<int>(static_cast<int>(lroundf(-m_mathVariantGlyph.font->boundsForGlyph(m_mathVariantGlyph.glyph).y()))); 551 if (m_mathVariantCodePoint) { 552 auto mathVariantGlyph = style().fontCascade().glyphDataForCharacter(m_mathVariantCodePoint.value(), m_mathVariantIsMirrored); 553 if (mathVariantGlyph.font) 554 return Optional<int>(static_cast<int>(lroundf(-mathVariantGlyph.font->boundsForGlyph(mathVariantGlyph.glyph).y()))); 555 } 551 556 return RenderMathMLBlock::firstLineBaseline(); 552 557 } … … 559 564 return; 560 565 561 if (!m_mathVariantGlyph.font) { 566 GlyphData mathVariantGlyph; 567 if (m_mathVariantCodePoint) 568 mathVariantGlyph = style().fontCascade().glyphDataForCharacter(m_mathVariantCodePoint.value(), m_mathVariantIsMirrored); 569 570 if (!mathVariantGlyph.font) { 562 571 RenderMathMLBlock::layoutBlock(relayoutChildren, pageLogicalHeight); 563 572 return; … … 567 576 child->layoutIfNeeded(); 568 577 569 setLogicalWidth(m _mathVariantGlyph.font->widthForGlyph(m_mathVariantGlyph.glyph));570 setLogicalHeight(m _mathVariantGlyph.font->boundsForGlyph(m_mathVariantGlyph.glyph).height());578 setLogicalWidth(mathVariantGlyph.font->widthForGlyph(mathVariantGlyph.glyph)); 579 setLogicalHeight(mathVariantGlyph.font->boundsForGlyph(mathVariantGlyph.glyph).height()); 571 580 572 581 clearNeedsLayout(); … … 578 587 579 588 // FIXME: Instead of using DrawGlyph, we may consider using the more general TextPainter so that we can apply mathvariant to strings with an arbitrary number of characters and preserve advanced CSS effects (text-shadow, etc). 580 if (info.context().paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE || !m_mathVariantGlyph.font) 589 if (info.context().paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE || !m_mathVariantCodePoint) 590 return; 591 592 auto mathVariantGlyph = style().fontCascade().glyphDataForCharacter(m_mathVariantCodePoint.value(), m_mathVariantIsMirrored); 593 if (!mathVariantGlyph.font) 581 594 return; 582 595 … … 585 598 586 599 GlyphBuffer buffer; 587 buffer.add(m _mathVariantGlyph.glyph, m_mathVariantGlyph.font, m_mathVariantGlyph.font->widthForGlyph(m_mathVariantGlyph.glyph));588 LayoutUnit glyphAscent = static_cast<int>(lroundf(-m _mathVariantGlyph.font->boundsForGlyph(m_mathVariantGlyph.glyph).y()));589 info.context().drawGlyphs(style().fontCascade(), *m _mathVariantGlyph.font, buffer, 0, 1, paintOffset + location() + LayoutPoint(0, glyphAscent));600 buffer.add(mathVariantGlyph.glyph, mathVariantGlyph.font, mathVariantGlyph.font->widthForGlyph(mathVariantGlyph.glyph)); 601 LayoutUnit glyphAscent = static_cast<int>(lroundf(-mathVariantGlyph.font->boundsForGlyph(mathVariantGlyph.glyph).y())); 602 info.context().drawGlyphs(style().fontCascade(), *mathVariantGlyph.font, buffer, 0, 1, paintOffset + location() + LayoutPoint(0, glyphAscent)); 590 603 } 591 604 592 605 void RenderMathMLToken::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& paintInfoForChild, bool usePrintRect) 593 606 { 594 if (m_mathVariantGlyph.font) 595 return; 607 if (m_mathVariantCodePoint) { 608 auto mathVariantGlyph = style().fontCascade().glyphDataForCharacter(m_mathVariantCodePoint.value(), m_mathVariantIsMirrored); 609 if (mathVariantGlyph.font) 610 return; 611 } 612 596 613 RenderMathMLBlock::paintChildren(paintInfo, paintOffset, paintInfoForChild, usePrintRect); 597 614 } -
branches/safari-602-branch/Source/WebCore/rendering/mathml/RenderMathMLToken.h
r203228 r207271 2 2 * Copyright (C) 2014 Frédéric Wang (fred.wang@free.fr). All rights reserved. 3 3 * Copyright (C) 2016 Igalia S.L. 4 * Copyright (C) 2016 Apple Inc. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 62 63 setNeedsLayoutAndPrefWidthsRecalc(); 63 64 } 64 GlyphData m_mathVariantGlyph; 65 bool m_mathVariantGlyphDirty; 65 Optional<UChar32> m_mathVariantCodePoint { Nullopt }; 66 bool m_mathVariantIsMirrored { false }; 67 bool m_mathVariantGlyphDirty { false }; 66 68 }; 67 69
Note: See TracChangeset
for help on using the changeset viewer.