Changeset 203396 in webkit
- Timestamp:
- Jul 18, 2016 10:42:46 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r203285 r203396 1992 1992 mathml/MathMLOperatorDictionary.cpp 1993 1993 mathml/MathMLPaddedElement.cpp 1994 mathml/MathMLScriptsElement.cpp 1994 1995 mathml/MathMLSelectElement.cpp 1995 1996 mathml/MathMLSpaceElement.cpp -
trunk/Source/WebCore/ChangeLog
r203395 r203396 1 2016-07-18 Frederic Wang <fwang@igalia.com> 2 3 Move parsing of subscriptshift and superscriptshift from rendering to element classes 4 https://bugs.webkit.org/show_bug.cgi?id=159622 5 6 Reviewed by Darin Adler. 7 8 We introduce a new MathMLScriptsElement that is used for elements msub, msup, msubsup and 9 mmultiscripts in order to create RenderMathMLScripts and parse and expose the values of the 10 subscriptshift and superscriptshift attributes. This is one more step toward moving MathML 11 attribute parsing to the DOM (bug 156536). 12 13 No new tests, rendering is unchanged. 14 15 * CMakeLists.txt: Add MathMLScriptsElement files. 16 * WebCore.xcodeproj/project.pbxproj: Ditto. 17 * mathml/MathMLAllInOne.cpp: Ditto. 18 * mathml/MathMLInlineContainerElement.cpp: Remove handling of scripts. 19 (WebCore::MathMLInlineContainerElement::createElementRenderer): Deleted. 20 * mathml/MathMLScriptsElement.cpp: Added. New class to handle scripted elements supporting 21 parsing for the subscriptshift and superscriptshift MathML lengths. 22 (WebCore::MathMLScriptsElement::MathMLScriptsElement): 23 (WebCore::MathMLScriptsElement::create): 24 (WebCore::MathMLScriptsElement::subscriptShift): Expose the cached length for the shift, 25 parsing the attribute again if necessary. 26 (WebCore::MathMLScriptsElement::superscriptShift): Ditto. 27 (WebCore::MathMLScriptsElement::parseAttribute): Mark attributes dirty. 28 (WebCore::MathMLScriptsElement::createElementRenderer): Create RenderMathMLScripts. 29 * mathml/MathMLScriptsElement.h: Ditto. 30 * mathml/mathtags.in: Map msub, msup, msubsup and mmultiscripts to MathMLScriptsElement. 31 * rendering/mathml/RenderMathMLScripts.cpp: 32 (WebCore::RenderMathMLScripts::scriptsElement): Helper function to cast the node to a 33 MathMLScriptsElement. 34 (WebCore::RenderMathMLScripts::getScriptMetricsAndLayoutIfNeeded): Resolve the attributes 35 using the functions from the MathMLScriptsElement class. 36 * rendering/mathml/RenderMathMLScripts.h: Declare scriptsElement. 37 1 38 2016-07-18 Frederic Wang <fwang@igalia.com> 2 39 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r203381 r203396 5405 5405 B57CB52E182A3EFC0079A647 /* InlineElementBox.h in Headers */ = {isa = PBXBuildFile; fileRef = B57CB52B182A37F60079A647 /* InlineElementBox.h */; }; 5406 5406 B595FF471824CEE300FF51CD /* RenderIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = B595FF461824CEE300FF51CD /* RenderIterator.h */; }; 5407 B59CA390CED66C3255F72B48 /* MathMLScriptsElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B59CA59AF170D8FAA5B8C9AD /* MathMLScriptsElement.cpp */; }; 5407 5408 B59CA390CED66C3255F72C59 /* MathMLPaddedElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B59CA59AF170D8FAA5B8CABE /* MathMLPaddedElement.cpp */; }; 5408 5409 B59DD699119029E5007E9684 /* JSDatabaseCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = B59DD697119029E5007E9684 /* JSDatabaseCallback.h */; }; … … 13404 13405 B57CB52C182A3EED0079A647 /* InlineElementBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineElementBox.cpp; sourceTree = "<group>"; }; 13405 13406 B595FF461824CEE300FF51CD /* RenderIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderIterator.h; sourceTree = "<group>"; }; 13407 B59CA59AF170D8FAA5B8C9AD /* MathMLScriptsElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLScriptsElement.cpp; sourceTree = "<group>"; }; 13408 B59CA849D41E6F65D81197AB /* MathMLScriptsElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLScriptsElement.h; sourceTree = "<group>"; }; 13406 13409 B59CA59AF170D8FAA5B8CABE /* MathMLPaddedElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLPaddedElement.cpp; sourceTree = "<group>"; }; 13407 13410 B59CA849D41E6F65D81198BC /* MathMLPaddedElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLPaddedElement.h; sourceTree = "<group>"; }; … … 24894 24897 D4F72C653A64807A83E76FB8 /* MathMLOperatorDictionary.cpp */, 24895 24898 DF7E9A294C7AACE0AD89B3DD /* MathMLOperatorDictionary.h */, 24899 B59CA59AF170D8FAA5B8C9AD /* MathMLScriptsElement.cpp */, 24900 B59CA849D41E6F65D81197AB /* MathMLScriptsElement.h */, 24896 24901 B59CA59AF170D8FAA5B8CABE /* MathMLPaddedElement.cpp */, 24897 24902 B59CA849D41E6F65D81198BC /* MathMLPaddedElement.h */, … … 31267 31272 FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */, 31268 31273 439176DF12DA25E17BAF80A2 /* MathMLStyle.cpp in Sources */, 31274 B59CA390CED66C3255F72B48 /* MathMLScriptsElement.cpp in Sources */, 31269 31275 B59CA390CED66C3255F72C59 /* MathMLPaddedElement.cpp in Sources */, 31270 31276 FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */, -
trunk/Source/WebCore/mathml/MathMLAllInOne.cpp
r203285 r203396 33 33 #include "MathMLOperatorDictionary.cpp" 34 34 #include "MathMLPaddedElement.cpp" 35 #include "MathMLScriptsElement.cpp" 35 36 #include "MathMLSelectElement.cpp" 36 37 #include "MathMLTextElement.cpp" -
trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp
r203285 r203396 37 37 #include "RenderMathMLRoot.h" 38 38 #include "RenderMathMLRow.h" 39 #include "RenderMathMLScripts.h"40 39 #include "RenderMathMLUnderOver.h" 41 40 … … 67 66 if (hasTagName(annotation_xmlTag) || hasTagName(merrorTag) || hasTagName(mphantomTag) || hasTagName(mrowTag) || hasTagName(mstyleTag)) 68 67 return createRenderer<RenderMathMLRow>(*this, WTFMove(style)); 69 if (hasTagName(msubTag) || hasTagName(msupTag) || hasTagName(msubsupTag) || hasTagName(mmultiscriptsTag))70 return createRenderer<RenderMathMLScripts>(*this, WTFMove(style));71 68 if (hasTagName(moverTag) || hasTagName(munderTag) || hasTagName(munderoverTag)) 72 69 return createRenderer<RenderMathMLUnderOver>(*this, WTFMove(style)); -
trunk/Source/WebCore/mathml/MathMLScriptsElement.h
r203395 r203396 1 1 /* 2 * Copyright (C) 2010 Alex Milowski (alex@milowski.com). All rights reserved. 3 * Copyright (C) 2013 The MathJax Consortium. 4 * Copyright (C) 2016 Igalia S.L. 2 * Copyright (C) 2016 Igalia S.L. All rights reserved. 5 3 * 6 4 * Redistribution and use in source and binary forms, with or without … … 29 27 30 28 #if ENABLE(MATHML) 31 32 #include "RenderMathMLBlock.h" 29 #include "MathMLInlineContainerElement.h" 33 30 34 31 namespace WebCore { 35 // Render a base with scripts. 36 class RenderMathMLScripts : public RenderMathMLBlock{32 33 class MathMLScriptsElement final : public MathMLInlineContainerElement { 37 34 public: 38 RenderMathMLScripts(Element&, RenderStyle&&); 39 RenderMathMLOperator* unembellishedOperator() final; 40 41 protected: 42 bool isRenderMathMLScripts() const override { return true; } 43 const char* renderName() const override { return "RenderMathMLScripts"; } 44 void computePreferredLogicalWidths() override; 45 void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) override; 46 47 enum ScriptsType { Sub, Super, SubSup, Multiscripts, Under, Over, UnderOver }; 48 ScriptsType m_scriptType; 35 static Ref<MathMLScriptsElement> create(const QualifiedName& tagName, Document&); 36 const Length& subscriptShift(); 37 const Length& superscriptShift(); 49 38 50 39 private: 51 Optional<int> firstLineBaseline() const final; 52 bool getBaseAndScripts(RenderBox*& base, RenderBox*& firstPostScript, RenderBox*& firstPreScript); 53 LayoutUnit spaceAfterScript(); 54 LayoutUnit italicCorrection(RenderBox* base); 55 void getScriptMetricsAndLayoutIfNeeded(RenderBox* base, RenderBox* script, LayoutUnit& minSubScriptShift, LayoutUnit& minSupScriptShift, LayoutUnit& maxScriptDescent, LayoutUnit& maxScriptAscent); 40 MathMLScriptsElement(const QualifiedName& tagName, Document&); 41 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final; 42 void parseAttribute(const QualifiedName&, const AtomicString&) final; 43 44 Length m_subscriptShift; 45 Length m_superscriptShift; 56 46 }; 57 47 58 } // namespace WebCore 59 60 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLScripts, isRenderMathMLScripts()) 48 } 61 49 62 50 #endif // ENABLE(MATHML) -
trunk/Source/WebCore/mathml/mathtags.in
r203285 r203396 10 10 mfrac interfaceName=MathMLFractionElement 11 11 mfenced interfaceName=MathMLInlineContainerElement 12 msubsup interfaceName=MathML InlineContainerElement12 msubsup interfaceName=MathMLScriptsElement 13 13 merror interfaceName=MathMLInlineContainerElement 14 14 mpadded interfaceName=MathMLPaddedElement … … 27 27 ms interfaceName=MathMLTextElement 28 28 mspace interfaceName=MathMLSpaceElement 29 msub interfaceName=MathML InlineContainerElement30 msup interfaceName=MathML InlineContainerElement29 msub interfaceName=MathMLScriptsElement 30 msup interfaceName=MathMLScriptsElement 31 31 mtable interfaceName=MathMLInlineContainerElement 32 32 mtr interfaceName=MathMLElement 33 33 mtd interfaceName=MathMLElement 34 mmultiscripts interfaceName=MathML InlineContainerElement34 mmultiscripts interfaceName=MathMLScriptsElement 35 35 mprescripts interfaceName=MathMLInlineContainerElement 36 36 menclose interfaceName=MathMLMencloseElement -
trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.cpp
r203324 r203396 33 33 34 34 #include "MathMLElement.h" 35 #include "MathMLScriptsElement.h" 35 36 #include "RenderMathMLOperator.h" 36 37 … … 64 65 m_scriptType = Multiscripts; 65 66 } 67 } 68 69 MathMLScriptsElement& RenderMathMLScripts::scriptsElement() const 70 { 71 ASSERT(!isRenderMathMLUnderOver()); 72 return static_cast<MathMLScriptsElement&>(nodeForNonAnonymous()); 66 73 } 67 74 … … 252 259 minSubScriptShift = std::max(subscriptShiftDown, baseDescent + subscriptBaselineDropMin); 253 260 if (!isRenderMathMLUnderOver()) { 254 LayoutUnit specifiedMinSubShift = 0; 255 parseMathMLLength(element()->attributeWithoutSynchronization(MathMLNames::subscriptshiftAttr), specifiedMinSubShift, &style(), false); 261 // It is not clear how to interpret the default shift and it is not available yet anyway. 262 // Hence we just pass 0 as the default value used by toUserUnits. 263 LayoutUnit specifiedMinSubShift = toUserUnits(scriptsElement().subscriptShift(), style(), 0); 256 264 minSubScriptShift = std::max(minSubScriptShift, specifiedMinSubShift); 257 265 } … … 260 268 minSupScriptShift = std::max(superscriptShiftUp, baseAscent - superScriptBaselineDropMax); 261 269 if (!isRenderMathMLUnderOver()) { 262 LayoutUnit specifiedMinSupShift = 0; 263 parseMathMLLength(element()->attributeWithoutSynchronization(MathMLNames::superscriptshiftAttr), specifiedMinSupShift, &style(), false); 270 // It is not clear how to interpret the default shift and it is not available yet anyway. 271 // Hence we just pass 0 as the default value used by toUserUnits. 272 LayoutUnit specifiedMinSupShift = toUserUnits(scriptsElement().superscriptShift(), style(), 0); 264 273 minSupScriptShift = std::max(minSupScriptShift, specifiedMinSupShift); 265 274 } -
trunk/Source/WebCore/rendering/mathml/RenderMathMLScripts.h
r203228 r203396 33 33 34 34 namespace WebCore { 35 36 class MathMLScriptsElement; 37 35 38 // Render a base with scripts. 36 39 class RenderMathMLScripts : public RenderMathMLBlock { … … 49 52 50 53 private: 54 MathMLScriptsElement& scriptsElement() const; 51 55 Optional<int> firstLineBaseline() const final; 52 56 bool getBaseAndScripts(RenderBox*& base, RenderBox*& firstPostScript, RenderBox*& firstPreScript);
Note: See TracChangeset
for help on using the changeset viewer.