WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-156910-20160422152704.patch (text/plain), 8.96 KB, created by
Frédéric Wang Nélar
on 2016-04-22 06:26:41 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Frédéric Wang Nélar
Created:
2016-04-22 06:26:41 PDT
Size:
8.96 KB
patch
obsolete
>Subversion Revision: 199869 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 4672504bb85c2f5a0ff4f349b1ae4d4e6dd40257..60f954e4f040e58ab50d4b567beba548f9ce7368 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2016-04-22 Frederic Wang <fred.wang@free.fr> >+ >+ RenderMathMLOperator refactoring: introduce getBaseGlyph and remove parameter from getDisplayStyleLargeOperator >+ https://bugs.webkit.org/show_bug.cgi?id=156910 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests, the behavior is not changed. >+ >+ * rendering/mathml/RenderMathMLOperator.cpp: >+ (WebCore::RenderMathMLOperator::italicCorrection): We do not need to pass m_textContent to getDisplayStyleLargeOperator. >+ (WebCore::RenderMathMLOperator::computePreferredLogicalWidths): We use getBaseGlyph and do not pass m_textContent to getDisplayStyleLargeOperator. >+ (WebCore::RenderMathMLOperator::getBaseGlyph): Introduce a helper function to retrieve the base glyph and do some validity checks. >+ (WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator): We remove the character parameter as it is always m_textContent. >+ We use getBaseGlyph and replace primaryFont with baseGlyph.font. >+ (WebCore::RenderMathMLOperator::findStretchyData): Ditto. >+ (WebCore::RenderMathMLOperator::updateStyle): We do not pass m_textContent to getDisplayStyleLargeOperator. >+ * rendering/mathml/RenderMathMLOperator.h: Declare getBaseGlyph and remove the parameter from getDisplayStyleLargeOperator. >+ > 2016-04-21 Frederic Wang <fwang@igalia.com> > > More improvements and explanations regarding resetting CSS properties on the <math> element >diff --git a/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp b/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp >index 83db352328861c7408fd38f05106265e965329be..1a9e601c4b4e75630910a0816872455a73f6e5f0 100644 >--- a/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp >+++ b/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp >@@ -207,7 +207,7 @@ LayoutUnit RenderMathMLOperator::italicCorrection() const > if (isLargeOperatorInDisplayStyle()) { > const auto& primaryFont = style().fontCascade().primaryFont(); > if (auto* mathData = primaryFont.mathData()) { >- StretchyData largeOperator = getDisplayStyleLargeOperator(m_textContent); >+ StretchyData largeOperator = getDisplayStyleLargeOperator(); > return mathData->getItalicCorrection(primaryFont, largeOperator.variant().glyph); > } > } >@@ -306,8 +306,8 @@ void RenderMathMLOperator::computePreferredLogicalWidths() > return; > } > >- GlyphData data = style().fontCascade().glyphDataForCharacter(m_textContent, !style().isLeftToRightDirection()); >- float maximumGlyphWidth = advanceWidthForGlyph(data); >+ GlyphData baseGlyph; >+ float maximumGlyphWidth = getBaseGlyph(style(), baseGlyph) ? advanceWidthForGlyph(baseGlyph) : 0; > if (!m_isVertical) { > if (maximumGlyphWidth < stretchSize()) > maximumGlyphWidth = stretchSize(); >@@ -317,7 +317,7 @@ void RenderMathMLOperator::computePreferredLogicalWidths() > } > if (isLargeOperatorInDisplayStyle()) { > // Large operators in STIX Word have incorrect advance width, causing misplacement of superscript, so we use the glyph bound instead (http://sourceforge.net/p/stixfonts/tracking/49/). >- StretchyData largeOperator = getDisplayStyleLargeOperator(m_textContent); >+ StretchyData largeOperator = getDisplayStyleLargeOperator(); > if (largeOperator.mode() == DrawSizeVariant) > maximumGlyphWidth = boundsForGlyph(largeOperator.variant()).width(); > } else { >@@ -386,6 +386,12 @@ void RenderMathMLOperator::styleDidChange(StyleDifference diff, const RenderStyl > updateOperatorProperties(); > } > >+bool RenderMathMLOperator::getBaseGlyph(const RenderStyle& style, GlyphData& baseGlyph) const >+{ >+ baseGlyph = style.fontCascade().glyphDataForCharacter(m_textContent, !style.isLeftToRightDirection()); >+ return baseGlyph.isValid() && baseGlyph.font == &style.fontCascade().primaryFont(); >+} >+ > bool RenderMathMLOperator::getGlyphAssemblyFallBack(Vector<OpenTypeMathData::AssemblyPart> assemblyParts, StretchyData& stretchyData) const > { > GlyphData top; >@@ -480,30 +486,29 @@ bool RenderMathMLOperator::getGlyphAssemblyFallBack(Vector<OpenTypeMathData::Ass > return true; > } > >-RenderMathMLOperator::StretchyData RenderMathMLOperator::getDisplayStyleLargeOperator(UChar character) const >+RenderMathMLOperator::StretchyData RenderMathMLOperator::getDisplayStyleLargeOperator() const > { > StretchyData data; > > ASSERT(m_isVertical && isLargeOperatorInDisplayStyle()); > >- const auto& primaryFont = style().fontCascade().primaryFont(); >- GlyphData baseGlyph = style().fontCascade().glyphDataForCharacter(character, !style().isLeftToRightDirection()); >- if (!primaryFont.mathData() || baseGlyph.font != &primaryFont || !baseGlyph.font || !baseGlyph.glyph) >+ GlyphData baseGlyph; >+ if (!getBaseGlyph(style(), baseGlyph) || !baseGlyph.font->mathData()) > return data; > > Vector<Glyph> sizeVariants; > Vector<OpenTypeMathData::AssemblyPart> assemblyParts; > > // The value of displayOperatorMinHeight is sometimes too small, so we ensure that it is at least \sqrt{2} times the size of the base glyph. >- float displayOperatorMinHeight = std::max(baseGlyph.font->boundsForGlyph(baseGlyph.glyph).height() * sqrtOfTwoFloat, primaryFont.mathData()->getMathConstant(primaryFont, OpenTypeMathData::DisplayOperatorMinHeight)); >+ float displayOperatorMinHeight = std::max(baseGlyph.font->boundsForGlyph(baseGlyph.glyph).height() * sqrtOfTwoFloat, baseGlyph.font->mathData()->getMathConstant(*baseGlyph.font, OpenTypeMathData::DisplayOperatorMinHeight)); > >- primaryFont.mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts); >+ baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts); > > // We choose the first size variant that is larger than the expected displayOperatorMinHeight and otherwise fallback to the largest variant. > for (auto& variant : sizeVariants) { > GlyphData sizeVariant; > sizeVariant.glyph = variant; >- sizeVariant.font = &primaryFont; >+ sizeVariant.font = baseGlyph.font; > data.setSizeVariantMode(sizeVariant); > if (boundsForGlyph(sizeVariant).height() >= displayOperatorMinHeight) > return data; >@@ -518,18 +523,19 @@ RenderMathMLOperator::StretchyData RenderMathMLOperator::findStretchyData(UChar > StretchyData data; > StretchyData assemblyData; > >- const auto& primaryFont = style().fontCascade().primaryFont(); >- GlyphData baseGlyph = style().fontCascade().glyphDataForCharacter(character, !style().isLeftToRightDirection()); >+ GlyphData baseGlyph; >+ if (!getBaseGlyph(style(), baseGlyph)) >+ return data; > >- if (primaryFont.mathData() && baseGlyph.font == &primaryFont) { >+ if (baseGlyph.font->mathData()) { > Vector<Glyph> sizeVariants; > Vector<OpenTypeMathData::AssemblyPart> assemblyParts; >- primaryFont.mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts); >+ baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts); > // We verify the size variants. > for (auto& variant : sizeVariants) { > GlyphData sizeVariant; > sizeVariant.glyph = variant; >- sizeVariant.font = &primaryFont; >+ sizeVariant.font = baseGlyph.font; > if (maximumGlyphWidth) > *maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceWidthForGlyph(sizeVariant)); > else { >@@ -625,7 +631,7 @@ void RenderMathMLOperator::updateStyle() > return; > > if (m_isVertical && isLargeOperatorInDisplayStyle()) >- m_stretchyData = getDisplayStyleLargeOperator(m_textContent); >+ m_stretchyData = getDisplayStyleLargeOperator(); > else { > // We do not stretch if the base glyph is large enough. > GlyphData baseGlyph = style().fontCascade().glyphDataForCharacter(m_textContent, !style().isLeftToRightDirection()); >diff --git a/Source/WebCore/rendering/mathml/RenderMathMLOperator.h b/Source/WebCore/rendering/mathml/RenderMathMLOperator.h >index aaee46ad586487349314c71ed7ad2693a7f918f1..bb3f81f2f53e1f3b3f435f82ae73b68931b44fd0 100644 >--- a/Source/WebCore/rendering/mathml/RenderMathMLOperator.h >+++ b/Source/WebCore/rendering/mathml/RenderMathMLOperator.h >@@ -141,8 +141,9 @@ private: > > bool shouldAllowStretching() const; > >+ bool getBaseGlyph(const RenderStyle&, GlyphData&) const; > bool getGlyphAssemblyFallBack(Vector<OpenTypeMathData::AssemblyPart>, StretchyData&) const; >- StretchyData getDisplayStyleLargeOperator(UChar) const; >+ StretchyData getDisplayStyleLargeOperator() const; > StretchyData findStretchyData(UChar, float* maximumGlyphWidth); > > enum GlyphPaintTrimming {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 156910
:
277058
|
277469