Changeset 203108 in webkit
- Timestamp:
- Jul 11, 2016, 10:59:55 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 9 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r203038 r203108 1988 1988 mathml/MathMLMencloseElement.cpp 1989 1989 mathml/MathMLSelectElement.cpp 1990 mathml/MathMLSpaceElement.cpp 1990 1991 mathml/MathMLTextElement.cpp 1991 1992 -
trunk/Source/WebCore/ChangeLog
r203106 r203108 1 2016-07-11 Frederic Wang <fwang@igalia.org> 2 3 Move parsing of mspace attributes to a MathMLSpaceElement class 4 https://bugs.webkit.org/show_bug.cgi?id=156795 5 6 Reviewed by Brent Fulgham. 7 8 No new tests, already covered by existing tests. 9 10 * CMakeLists.txt: Add MathMLSpaceElement to the build system. 11 * WebCore.xcodeproj/project.pbxproj: Ditto. 12 * mathml/MathMLElement.cpp: 13 (WebCore::MathMLElement::cachedMathMLLength): Helper function to returned the cached parsed 14 value of a MathML length and parsing the corresponding attribute value if the cache is dirty. 15 * mathml/MathMLElement.h: Add a dirty boolean to MathML Length structure. Declare cachedMathMLLength. 16 * mathml/MathMLSpaceElement.cpp: New class for the <mspace> element. 17 (WebCore::MathMLSpaceElement::MathMLSpaceElement): 18 (WebCore::MathMLSpaceElement::create): 19 (WebCore::MathMLSpaceElement::parseAttribute): Make width, height, depth attributes dirty. 20 (WebCore::MathMLSpaceElement::createElementRenderer): 21 * mathml/MathMLSpaceElement.h: New class for the <mspace> element. 22 We define MathML lengths for width, height and depth attributes are on the class and expose 23 with the corresponding helper functions via memoization. 24 * mathml/MathMLTextElement.cpp: Remove handling of mspace from this class. 25 (WebCore::MathMLTextElement::createElementRenderer): 26 * mathml/mathtags.in: Change the interface for mspace to use the new class. 27 * rendering/mathml/RenderMathMLSpace.cpp: Do not store width/height/depth values on the 28 renderer and instead just use the corresponding MathML lengths on the element class. 29 (WebCore::RenderMathMLSpace::RenderMathMLSpace): Use MathMLSpaceElement and remove member 30 initialization. 31 (WebCore::RenderMathMLSpace::computePreferredLogicalWidths): Use spaceWidth(). 32 (WebCore::RenderMathMLSpace::spaceWidth): Helper function to resolve the width attribute value. 33 (WebCore::RenderMathMLSpace::getSpaceHeightAndDepth): Ditto for height and depth. 34 (WebCore::RenderMathMLSpace::layoutBlock): Use the helper functions to get the mspace metrics. 35 (WebCore::RenderMathMLSpace::firstLineBaseline): Ditto. 36 (WebCore::RenderMathMLSpace::updateFromElement): Deleted. 37 (WebCore::RenderMathMLSpace::styleDidChange): Deleted. 38 * rendering/mathml/RenderMathMLSpace.h: Use MathMLSpaceElement, replace members with helper 39 functions and and make element() usable from a const instance. 40 1 41 2016-07-11 Frederic Wang <fwang@igalia.org> 2 42 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r203038 r203108 6894 6894 F98FFF4511A2676200F548E8 /* CSSOMUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = F98FFF4311A2676200F548E8 /* CSSOMUtils.h */; }; 6895 6895 F9F0ED7A0DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F9F0ED770DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h */; }; 6896 4FA65A6B1108ABED002615E0 /* MathMLSpaceElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FA65A691108ABED002615E0 /* MathMLSpaceElement.cpp */; }; 6897 4FA65A6C1108ABED002615E0 /* MathMLSpaceElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FA65A6A1108ABED002615E0 /* MathMLSpaceElement.h */; }; 6896 6898 FA654A6B1108ABED002615E0 /* MathMLTextElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA654A691108ABED002615E0 /* MathMLTextElement.cpp */; }; 6897 6899 FA654A6C1108ABED002615E0 /* MathMLTextElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FA654A6A1108ABED002615E0 /* MathMLTextElement.h */; }; … … 15056 15058 FA654A631108ABB7002615E0 /* mathml.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = mathml.css; sourceTree = "<group>"; }; 15057 15059 FA654A671108ABE2002615E0 /* mathattrs.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mathattrs.in; sourceTree = "<group>"; }; 15060 4FA65A691108ABED002615E0 /* MathMLSpaceElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLSpaceElement.cpp; sourceTree = "<group>"; }; 15061 4FA65A6A1108ABED002615E0 /* MathMLSpaceElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLSpaceElement.h; sourceTree = "<group>"; }; 15058 15062 FA654A691108ABED002615E0 /* MathMLTextElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLTextElement.cpp; sourceTree = "<group>"; }; 15059 15063 FA654A6A1108ABED002615E0 /* MathMLTextElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLTextElement.h; sourceTree = "<group>"; }; … … 24863 24867 F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */, 24864 24868 59780849D41E6F65D81198BC /* MathMLSelectElement.h */, 24869 4FA65A691108ABED002615E0 /* MathMLSpaceElement.cpp */, 24870 4FA65A6A1108ABED002615E0 /* MathMLSpaceElement.h */, 24865 24871 FA654A691108ABED002615E0 /* MathMLTextElement.cpp */, 24866 24872 FA654A6A1108ABED002615E0 /* MathMLTextElement.h */, … … 27399 27405 439046E012DA25E17BAF80A2 /* MathMLOperatorDictionary.h in Headers */, 27400 27406 439176E012DA25E17BAF80A2 /* MathMLStyle.h in Headers */, 27407 4FA65A6C1108ABED002615E0 /* MathMLSpaceElement.h in Headers */, 27401 27408 FA654A6C1108ABED002615E0 /* MathMLTextElement.h in Headers */, 27402 27409 439046EA12DA25E812AF80AC /* MathOperator.h in Headers */, … … 31222 31229 439176DF12DA25E17BAF80A2 /* MathMLStyle.cpp in Sources */, 31223 31230 FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */, 31231 4FA65A6B1108ABED002615E0 /* MathMLSpaceElement.cpp in Sources */, 31224 31232 FA654A6B1108ABED002615E0 /* MathMLTextElement.cpp in Sources */, 31225 31233 439046E912DA25E812AF80AC /* MathOperator.cpp in Sources */, -
trunk/Source/WebCore/mathml/MathMLElement.cpp
r203106 r203108 517 517 } 518 518 519 const MathMLElement::Length& MathMLElement::cachedMathMLLength(const QualifiedName& name, Length& length) 520 { 521 if (length.dirty) { 522 length = parseMathMLLength(fastGetAttribute(name)); 523 length.dirty = false; 524 } 525 return length; 526 } 527 519 528 } 520 529 -
trunk/Source/WebCore/mathml/MathMLElement.h
r203106 r203108 64 64 LengthType type { LengthType::ParsingFailed }; 65 65 float value { 0 }; 66 bool dirty { true }; 66 67 }; 67 68 static Length parseMathMLLength(const String&); … … 82 83 bool willRespondToMouseClickEvents() override; 83 84 void defaultEventHandler(Event*) override; 85 86 const Length& cachedMathMLLength(const QualifiedName&, Length&); 84 87 85 88 private: -
trunk/Source/WebCore/mathml/MathMLSpaceElement.h
r203107 r203108 1 1 /* 2 * Copyright (C) 201 3 The MathJax Consortium. All rights reserved.2 * Copyright (C) 2016 Igalia S.L. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef RenderMathMLSpace_h27 #define RenderMathMLSpace_h26 #ifndef MathMLSpaceElement_h 27 #define MathMLSpaceElement_h 28 28 29 29 #if ENABLE(MATHML) 30 31 #include "MathMLTextElement.h" 32 #include "RenderMathMLBlock.h" 30 #include "MathMLElement.h" 33 31 34 32 namespace WebCore { 35 33 36 class RenderMathMLSpace final : public RenderMathMLBlock{34 class MathMLSpaceElement final : public MathMLElement { 37 35 public: 38 RenderMathMLSpace(MathMLTextElement&, RenderStyle&&); 39 MathMLTextElement& element() { return static_cast<MathMLTextElement&>(nodeForNonAnonymous()); } 36 static Ref<MathMLSpaceElement> create(const QualifiedName& tagName, Document&); 37 const Length& width(); 38 const Length& height(); 39 const Length& depth(); 40 private: 41 MathMLSpaceElement(const QualifiedName& tagName, Document&); 42 bool isPresentationMathML() const final { return true; } 43 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final; 44 void parseAttribute(const QualifiedName&, const AtomicString&) final; 40 45 41 private: 42 const char* renderName() const final { return "RenderMathMLSpace"; } 43 bool isRenderMathMLSpace() const final { return true; } 44 void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final; 45 bool isChildAllowed(const RenderObject&, const RenderStyle&) const final { return false; } 46 void updateFromElement() final; 47 void computePreferredLogicalWidths() final; 48 void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final; 49 Optional<int> firstLineBaseline() const final; 50 51 LayoutUnit m_width; 52 LayoutUnit m_height; 53 LayoutUnit m_depth; 46 Length m_width; 47 Length m_height; 48 Length m_depth; 54 49 }; 55 50 56 } // namespace WebCore 57 58 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLSpace, isRenderMathMLSpace()) 51 } 59 52 60 53 #endif // ENABLE(MATHML) 61 #endif // RenderMathMLSpace_h54 #endif // MathMLSpaceElement_h -
trunk/Source/WebCore/mathml/MathMLTextElement.cpp
r203072 r203108 33 33 #include "MathMLNames.h" 34 34 #include "RenderMathMLOperator.h" 35 #include "RenderMathMLSpace.h"36 35 #include "RenderMathMLToken.h" 37 36 … … 83 82 if (hasTagName(MathMLNames::moTag)) 84 83 return createRenderer<RenderMathMLOperator>(*this, WTFMove(style)); 85 if (hasTagName(MathMLNames::mspaceTag))86 return createRenderer<RenderMathMLSpace>(*this, WTFMove(style));87 84 if (hasTagName(MathMLNames::annotationTag)) 88 85 return MathMLElement::createElementRenderer(WTFMove(style), insertionPosition); -
trunk/Source/WebCore/mathml/mathtags.in
r202962 r203108 26 26 mtext interfaceName=MathMLTextElement 27 27 ms interfaceName=MathMLTextElement 28 mspace interfaceName=MathML TextElement28 mspace interfaceName=MathMLSpaceElement 29 29 msub interfaceName=MathMLInlineContainerElement 30 30 msup interfaceName=MathMLInlineContainerElement -
trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp
r202727 r203108 37 37 using namespace MathMLNames; 38 38 39 RenderMathMLSpace::RenderMathMLSpace(MathML TextElement& element, RenderStyle&& style)39 RenderMathMLSpace::RenderMathMLSpace(MathMLSpaceElement& element, RenderStyle&& style) 40 40 : RenderMathMLBlock(element, WTFMove(style)) 41 , m_width(0)42 , m_height(0)43 , m_depth(0)44 41 { 45 42 } … … 49 46 ASSERT(preferredLogicalWidthsDirty()); 50 47 51 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = m_width;48 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = spaceWidth(); 52 49 53 50 setPreferredLogicalWidthsDirty(false); 54 51 } 55 52 56 void RenderMathMLSpace::updateFromElement() 53 LayoutUnit RenderMathMLSpace::spaceWidth() const 57 54 { 58 const auto& spaceElement = element(); 55 auto& spaceElement = element(); 56 // FIXME: Negative width values are not supported yet. 57 return std::max<LayoutUnit>(0, toUserUnits(spaceElement.width(), style(), 0)); 58 } 59 59 60 // This parses the mspace attributes, using 0 as the default values. 61 m_width = 0; 62 m_height = 0; 63 m_depth = 0; 64 parseMathMLLength(spaceElement.getAttribute(MathMLNames::widthAttr), m_width, &style()); 65 parseMathMLLength(spaceElement.getAttribute(MathMLNames::heightAttr), m_height, &style()); 66 parseMathMLLength(spaceElement.getAttribute(MathMLNames::depthAttr), m_depth, &style()); 67 68 // FIXME: Negative width values should be accepted. 69 if (m_width < 0) 70 m_width = 0; 60 void RenderMathMLSpace::getSpaceHeightAndDepth(LayoutUnit& height, LayoutUnit& depth) const 61 { 62 auto& spaceElement = element(); 63 height = toUserUnits(spaceElement.height(), style(), 0); 64 depth = toUserUnits(spaceElement.depth(), style(), 0); 71 65 72 66 // If the total height is negative, set vertical dimensions to 0. 73 if ( m_height + m_depth < 0) {74 m_height = 0;75 m_depth = 0;67 if (height + depth < 0) { 68 height = 0; 69 depth = 0; 76 70 } 77 78 setNeedsLayoutAndPrefWidthsRecalc();79 71 } 80 72 … … 86 78 return; 87 79 88 setLogicalWidth(m_width); 89 setLogicalHeight(m_height + m_depth); 80 setLogicalWidth(spaceWidth()); 81 LayoutUnit height, depth; 82 getSpaceHeightAndDepth(height, depth); 83 setLogicalHeight(height + depth); 90 84 91 85 clearNeedsLayout(); 92 86 } 93 87 94 void RenderMathMLSpace::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)95 {96 RenderMathMLBlock::styleDidChange(diff, oldStyle);97 updateFromElement();98 }99 100 88 Optional<int> RenderMathMLSpace::firstLineBaseline() const 101 89 { 102 return Optional<int>(m_height); 90 LayoutUnit height, depth; 91 getSpaceHeightAndDepth(height, depth); 92 return Optional<int>(height); 103 93 } 104 94 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h
r202727 r203108 29 29 #if ENABLE(MATHML) 30 30 31 #include "MathML TextElement.h"31 #include "MathMLSpaceElement.h" 32 32 #include "RenderMathMLBlock.h" 33 33 … … 36 36 class RenderMathMLSpace final : public RenderMathMLBlock { 37 37 public: 38 RenderMathMLSpace(MathML TextElement&, RenderStyle&&);39 MathML TextElement& element() { return static_cast<MathMLTextElement&>(nodeForNonAnonymous()); }38 RenderMathMLSpace(MathMLSpaceElement&, RenderStyle&&); 39 MathMLSpaceElement& element() const { return static_cast<MathMLSpaceElement&>(nodeForNonAnonymous()); } 40 40 41 41 private: 42 42 const char* renderName() const final { return "RenderMathMLSpace"; } 43 43 bool isRenderMathMLSpace() const final { return true; } 44 void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;45 44 bool isChildAllowed(const RenderObject&, const RenderStyle&) const final { return false; } 46 void updateFromElement() final;47 45 void computePreferredLogicalWidths() final; 48 46 void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final; 49 47 Optional<int> firstLineBaseline() const final; 50 48 51 LayoutUnit m_width; 52 LayoutUnit m_height; 53 LayoutUnit m_depth; 49 LayoutUnit spaceWidth() const; 50 void getSpaceHeightAndDepth(LayoutUnit& height, LayoutUnit& depth) const; 54 51 }; 55 52
Note:
See TracChangeset
for help on using the changeset viewer.