Changeset 203973 in webkit
- Timestamp:
- Aug 1, 2016 12:44:20 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r203935 r203973 2533 2533 rendering/mathml/RenderMathMLBlock.cpp 2534 2534 rendering/mathml/RenderMathMLFenced.cpp 2535 rendering/mathml/RenderMathMLFencedOperator.cpp 2535 2536 rendering/mathml/RenderMathMLFraction.cpp 2536 2537 rendering/mathml/RenderMathMLMath.cpp -
trunk/Source/WebCore/ChangeLog
r203971 r203973 1 2016-08-01 Frederic Wang <fwang@igalia.com> 2 3 Introduce a RenderMathMLFencedOperator class 4 https://bugs.webkit.org/show_bug.cgi?id=160245 5 6 Reviewed by Darin Adler. 7 8 We introduce a class to handle all the code specific to anonymous mfenced operators. In 9 particular many members of the RenderMathMLOperator class are going to be removed while 10 fixing bug 156537 but they may still need to stored and exposed in some way by mfenced 11 operators. 12 13 No new tests, behavior is unchanged. 14 15 * CMakeLists.txt: Add RenderMathMLFencedOperator. 16 * WebCore.xcodeproj/project.pbxproj: Ditto. 17 * rendering/RenderObject.h: 18 (WebCore::RenderObject::isRenderMathMLFencedOperator): Function to allow casting to 19 RenderMathMLFencedOperator. 20 * rendering/mathml/RenderMathMLFenced.cpp: Use RenderMathMLFencedOperator instead of 21 RenderMathMLOperator and use the new name updateOperatorContent. 22 (WebCore::RenderMathMLFenced::updateFromElement): 23 (WebCore::RenderMathMLFenced::createMathMLOperator): 24 (WebCore::RenderMathMLFenced::makeFences): 25 (WebCore::RenderMathMLFenced::addChild): 26 * rendering/mathml/RenderMathMLFenced.h: Use RenderMathMLFencedOperator instead of 27 RenderMathMLOperator. 28 * rendering/mathml/RenderMathMLFencedOperator.cpp: New class derived from RenderMathMLOperator 29 (WebCore::RenderMathMLFencedOperator::RenderMathMLFencedOperator): Init form and operator 30 flags with the specified parameters and init the text content. 31 (WebCore::RenderMathMLFencedOperator::updateOperatorContent): We move the 32 RenderMathMLOperator::updateTokenContent function used by anonymous operators here. It is 33 renamed to avoid build errors due to conflicts with the other 34 RenderMathMLOperator::updateTokenContent function. 35 * rendering/mathml/RenderMathMLFencedOperator.h: New class for anonymous mfenced operators 36 with getter and setter for the m_textContent. Also override RenderMathMLFencedOperator to 37 allow casting to RenderMathMLFencedOperator. 38 * rendering/mathml/RenderMathMLOperator.cpp: 39 (WebCore::RenderMathMLOperator::RenderMathMLOperator): Simplify the constructors. Some 40 initializations is moved in RenderMathMLOperator.h while other code is moved to 41 RenderMathMLFencedOperator. 42 (WebCore::RenderMathMLOperator::textContent): No need to handle the anonymous case here since 43 it is handled in RenderMathMLFencedOperator. 44 (WebCore::RenderMathMLOperator::updateTokenContent): We delete the version used for anonymous 45 operators and move it into RenderMathMLFencedOperator. 46 * rendering/mathml/RenderMathMLOperator.h: Make the class and some members overridable and 47 exposed to the derived RenderMathMLFencedOperator class. We also move initialization of some 48 members here. 49 1 50 2016-08-01 Youenn Fablet <youennf@gmail.com> 2 51 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r203935 r203973 1701 1701 439046D912DA25E800AF80A2 /* RenderMathMLFenced.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046C512DA25E800AF80A2 /* RenderMathMLFenced.cpp */; }; 1702 1702 439046DA12DA25E800AF80A2 /* RenderMathMLFenced.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046C612DA25E800AF80A2 /* RenderMathMLFenced.h */; }; 1703 439046D912DA25E800AF81B3 /* RenderMathMLFencedOperator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046C512DA25E800AF81B3 /* RenderMathMLFencedOperator.cpp */; }; 1704 439046DA12DA25E800AF81B3 /* RenderMathMLFencedOperator.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046C612DA25E800AF81B3 /* RenderMathMLFencedOperator.h */; }; 1703 1705 439046DB12DA25E800AF80A2 /* RenderMathMLFraction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 439046C712DA25E800AF80A2 /* RenderMathMLFraction.cpp */; }; 1704 1706 439046DC12DA25E800AF80A2 /* RenderMathMLFraction.h in Headers */ = {isa = PBXBuildFile; fileRef = 439046C812DA25E800AF80A2 /* RenderMathMLFraction.h */; }; … … 9330 9332 439046C512DA25E800AF80A2 /* RenderMathMLFenced.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLFenced.cpp; sourceTree = "<group>"; }; 9331 9333 439046C612DA25E800AF80A2 /* RenderMathMLFenced.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLFenced.h; sourceTree = "<group>"; }; 9334 439046C512DA25E800AF81B3 /* RenderMathMLFencedOperator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLFencedOperator.cpp; sourceTree = "<group>"; }; 9335 439046C612DA25E800AF81B3 /* RenderMathMLFencedOperator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLFencedOperator.h; sourceTree = "<group>"; }; 9332 9336 439046C712DA25E800AF80A2 /* RenderMathMLFraction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLFraction.cpp; sourceTree = "<group>"; }; 9333 9337 439046C812DA25E800AF80A2 /* RenderMathMLFraction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLFraction.h; sourceTree = "<group>"; }; … … 17168 17172 439046C512DA25E800AF80A2 /* RenderMathMLFenced.cpp */, 17169 17173 439046C612DA25E800AF80A2 /* RenderMathMLFenced.h */, 17174 439046C512DA25E800AF81B3 /* RenderMathMLFencedOperator.cpp */, 17175 439046C612DA25E800AF81B3 /* RenderMathMLFencedOperator.h */, 17170 17176 439046C712DA25E800AF80A2 /* RenderMathMLFraction.cpp */, 17171 17177 439046C812DA25E800AF80A2 /* RenderMathMLFraction.h */, … … 27967 27973 439046D812DA25E800AF80A2 /* RenderMathMLBlock.h in Headers */, 27968 27974 439046DA12DA25E800AF80A2 /* RenderMathMLFenced.h in Headers */, 27975 439046DA12DA25E800AF81B3 /* RenderMathMLFencedOperator.h in Headers */, 27969 27976 439046DC12DA25E800AF80A2 /* RenderMathMLFraction.h in Headers */, 27970 27977 439046DE12DA25E800AF80A2 /* RenderMathMLMath.h in Headers */, … … 31680 31687 439046D712DA25E800AF80A2 /* RenderMathMLBlock.cpp in Sources */, 31681 31688 439046D912DA25E800AF80A2 /* RenderMathMLFenced.cpp in Sources */, 31689 439046D912DA25E800AF81B3 /* RenderMathMLFencedOperator.cpp in Sources */, 31682 31690 439046DB12DA25E800AF80A2 /* RenderMathMLFraction.cpp in Sources */, 31683 31691 439046DD12DA25E800AF80A2 /* RenderMathMLMath.cpp in Sources */, -
trunk/Source/WebCore/rendering/RenderObject.h
r203660 r203973 339 339 virtual bool isRenderMathMLMenclose() const { return false; } 340 340 virtual bool isRenderMathMLFenced() const { return false; } 341 virtual bool isRenderMathMLFencedOperator() const { return false; } 341 342 virtual bool isRenderMathMLFraction() const { return false; } 342 343 virtual bool isRenderMathMLPadded() const { return false; } -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp
r203660 r203973 33 33 #include "MathMLNames.h" 34 34 #include "RenderInline.h" 35 #include "RenderMathML Operator.h"35 #include "RenderMathMLFencedOperator.h" 36 36 #include "RenderText.h" 37 37 #include <wtf/text/StringBuilder.h> … … 79 79 else { 80 80 // FIXME: The mfenced element fails to update dynamically when its open, close and separators attributes are changed (https://bugs.webkit.org/show_bug.cgi?id=57696). 81 downcast<RenderMathMLOperator>(*firstChild()).updateTokenContent(m_open); 82 m_closeFenceRenderer->updateTokenContent(m_close); 81 if (is<RenderMathMLFencedOperator>(*firstChild())) 82 downcast<RenderMathMLFencedOperator>(*firstChild()).updateOperatorContent(m_open); 83 m_closeFenceRenderer->updateOperatorContent(m_close); 83 84 } 84 85 } 85 86 86 RenderPtr<RenderMathML Operator> RenderMathMLFenced::createMathMLOperator(const String& operatorString, MathMLOperatorDictionary::Form form, MathMLOperatorDictionary::Flag flag)87 RenderPtr<RenderMathMLFencedOperator> RenderMathMLFenced::createMathMLOperator(const String& operatorString, MathMLOperatorDictionary::Form form, MathMLOperatorDictionary::Flag flag) 87 88 { 88 RenderPtr<RenderMathML Operator> newOperator = createRenderer<RenderMathMLOperator>(document(), RenderStyle::createAnonymousStyleWithDisplay(style(), BLOCK), operatorString, form, flag);89 RenderPtr<RenderMathMLFencedOperator> newOperator = createRenderer<RenderMathMLFencedOperator>(document(), RenderStyle::createAnonymousStyleWithDisplay(style(), BLOCK), operatorString, form, flag); 89 90 newOperator->initializeStyle(); 90 91 return newOperator; … … 93 94 void RenderMathMLFenced::makeFences() 94 95 { 95 RenderPtr<RenderMathML Operator> openFence = createMathMLOperator(m_open, MathMLOperatorDictionary::Prefix, MathMLOperatorDictionary::Fence);96 RenderPtr<RenderMathMLFencedOperator> openFence = createMathMLOperator(m_open, MathMLOperatorDictionary::Prefix, MathMLOperatorDictionary::Fence); 96 97 RenderMathMLRow::addChild(openFence.leakPtr(), firstChild()); 97 98 98 RenderPtr<RenderMathML Operator> closeFence = createMathMLOperator(m_close, MathMLOperatorDictionary::Postfix, MathMLOperatorDictionary::Fence);99 RenderPtr<RenderMathMLFencedOperator> closeFence = createMathMLOperator(m_close, MathMLOperatorDictionary::Postfix, MathMLOperatorDictionary::Fence); 99 100 m_closeFenceRenderer = closeFence.get(); 100 101 RenderMathMLRow::addChild(closeFence.leakPtr()); … … 109 110 // FIXME: Adding or removing a child should possibly cause all later separators to shift places if they're different, as later child positions change by +1 or -1. This should also handle surrogate pairs. See https://bugs.webkit.org/show_bug.cgi?id=125938. 110 111 111 RenderPtr<RenderMathML Operator> separatorRenderer;112 RenderPtr<RenderMathMLFencedOperator> separatorRenderer; 112 113 if (m_separators.get()) { 113 114 unsigned int count = 0; -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.h
r203228 r203973 29 29 30 30 #include "MathMLInlineContainerElement.h" 31 #include "RenderMathML Operator.h"31 #include "RenderMathMLFencedOperator.h" 32 32 #include "RenderMathMLRow.h" 33 33 … … 45 45 void updateFromElement() final; 46 46 47 RenderPtr<RenderMathML Operator> createMathMLOperator(const String& operatorString, MathMLOperatorDictionary::Form, MathMLOperatorDictionary::Flag);47 RenderPtr<RenderMathMLFencedOperator> createMathMLOperator(const String& operatorString, MathMLOperatorDictionary::Form, MathMLOperatorDictionary::Flag); 48 48 void makeFences(); 49 49 … … 52 52 RefPtr<StringImpl> m_separators; 53 53 54 RenderMathML Operator* m_closeFenceRenderer;54 RenderMathMLFencedOperator* m_closeFenceRenderer; 55 55 }; 56 56 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp
r203972 r203973 1 1 /* 2 * Copyright (C) 20 09 Alex Milowski (alex@milowski.com). 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 # pragma once26 #include "config.h" 27 27 28 28 #if ENABLE(MATHML) 29 #include "RenderMathMLFencedOperator.h" 29 30 30 #include "MathMLInlineContainerElement.h" 31 #include "RenderMathMLOperator.h" 32 #include "RenderMathMLRow.h" 31 #include "MathMLOperatorElement.h" 33 32 34 33 namespace WebCore { 35 34 36 class RenderMathMLFenced final : public RenderMathMLRow { 37 public: 38 RenderMathMLFenced(MathMLInlineContainerElement&, RenderStyle&&); 39 MathMLInlineContainerElement& element() { return static_cast<MathMLInlineContainerElement&>(nodeForNonAnonymous()); } 35 RenderMathMLFencedOperator::RenderMathMLFencedOperator(Document& document, RenderStyle&& style, const String& operatorString, MathMLOperatorDictionary::Form form, unsigned short flags) 36 : RenderMathMLOperator(document, WTFMove(style), form, flags) 37 { 38 updateOperatorContent(operatorString); 39 } 40 40 41 private: 42 bool isRenderMathMLFenced() const final { return true; } 43 const char* renderName() const final { return "RenderMathMLFenced"; } 44 void addChild(RenderObject* child, RenderObject* beforeChild) final; 45 void updateFromElement() final; 46 47 RenderPtr<RenderMathMLOperator> createMathMLOperator(const String& operatorString, MathMLOperatorDictionary::Form, MathMLOperatorDictionary::Flag); 48 void makeFences(); 49 50 String m_open; 51 String m_close; 52 RefPtr<StringImpl> m_separators; 53 54 RenderMathMLOperator* m_closeFenceRenderer; 55 }; 41 void RenderMathMLFencedOperator::updateOperatorContent(const String& operatorString) 42 { 43 m_textContent = MathMLOperatorElement::parseOperatorText(operatorString); 44 rebuildTokenContent(); 45 } 56 46 57 47 } 58 48 59 #endif // ENABLE(MATHML)49 #endif -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.h
r203972 r203973 1 1 /* 2 * Copyright (C) 20 09 Alex Milowski (alex@milowski.com). 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 … … 28 28 #if ENABLE(MATHML) 29 29 30 #include "MathML InlineContainerElement.h"30 #include "MathMLOperatorDictionary.h" 31 31 #include "RenderMathMLOperator.h" 32 #include "RenderMathMLRow.h"33 32 34 33 namespace WebCore { 35 34 36 class RenderMathMLFenced final : public RenderMathMLRow{35 class RenderMathMLFencedOperator final : public RenderMathMLOperator { 37 36 public: 38 RenderMathMLFenced (MathMLInlineContainerElement&, RenderStyle&&);39 MathMLInlineContainerElement& element() { return static_cast<MathMLInlineContainerElement&>(nodeForNonAnonymous()); }37 RenderMathMLFencedOperator(Document&, RenderStyle&&, const String& operatorString, MathMLOperatorDictionary::Form, unsigned short flags = 0); 38 void updateOperatorContent(const String&); 40 39 41 40 private: 42 bool isRenderMathMLFenced() const final { return true; } 43 const char* renderName() const final { return "RenderMathMLFenced"; } 44 void addChild(RenderObject* child, RenderObject* beforeChild) final; 45 void updateFromElement() final; 41 bool isRenderMathMLFencedOperator() const final { return true; } 42 UChar textContent() const final { return m_textContent; } 46 43 47 RenderPtr<RenderMathMLOperator> createMathMLOperator(const String& operatorString, MathMLOperatorDictionary::Form, MathMLOperatorDictionary::Flag); 48 void makeFences(); 49 50 String m_open; 51 String m_close; 52 RefPtr<StringImpl> m_separators; 53 54 RenderMathMLOperator* m_closeFenceRenderer; 44 UChar m_textContent { 0 }; 55 45 }; 56 46 57 } 47 }; // namespace WebCore 48 49 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLFencedOperator, isRenderMathMLFencedOperator()) 58 50 59 51 #endif // ENABLE(MATHML) -
trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
r203896 r203973 50 50 RenderMathMLOperator::RenderMathMLOperator(MathMLOperatorElement& element, RenderStyle&& style) 51 51 : RenderMathMLToken(element, WTFMove(style)) 52 , m_stretchHeightAboveBaseline(0)53 , m_stretchDepthBelowBaseline(0)54 , m_isVertical(true)55 52 { 56 53 updateTokenContent(); 57 54 } 58 55 59 RenderMathMLOperator::RenderMathMLOperator(Document& document, RenderStyle&& style, const String& operatorString,MathMLOperatorDictionary::Form form, unsigned short flags)56 RenderMathMLOperator::RenderMathMLOperator(Document& document, RenderStyle&& style, MathMLOperatorDictionary::Form form, unsigned short flags) 60 57 : RenderMathMLToken(document, WTFMove(style)) 61 , m_stretchHeightAboveBaseline(0)62 , m_stretchDepthBelowBaseline(0)63 , m_textContent(0)64 , m_isVertical(true)65 58 , m_operatorForm(form) 66 59 , m_operatorFlags(flags) 67 60 { 68 updateTokenContent(operatorString);69 61 } 70 62 … … 76 68 UChar RenderMathMLOperator::textContent() const 77 69 { 78 return isAnonymous() ? m_textContent : element().operatorText(); 70 ASSERT(!isAnonymous()); 71 return element().operatorText(); 79 72 } 80 73 … … 320 313 } 321 314 322 void RenderMathMLOperator::updateTokenContent(const String& operatorString)323 {324 ASSERT(isAnonymous());325 m_textContent = MathMLOperatorElement::parseOperatorText(operatorString);326 rebuildTokenContent();327 }328 329 315 void RenderMathMLOperator::updateTokenContent() 330 316 { -
trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h
r203896 r203973 37 37 class MathMLOperatorElement; 38 38 39 class RenderMathMLOperator final: public RenderMathMLToken {39 class RenderMathMLOperator : public RenderMathMLToken { 40 40 public: 41 41 RenderMathMLOperator(MathMLOperatorElement&, RenderStyle&&); 42 RenderMathMLOperator(Document&, RenderStyle&&, const String& operatorString,MathMLOperatorDictionary::Form, unsigned short flags = 0);42 RenderMathMLOperator(Document&, RenderStyle&&, MathMLOperatorDictionary::Form, unsigned short flags = 0); 43 43 MathMLOperatorElement& element() const; 44 44 … … 54 54 LayoutUnit italicCorrection() const { return m_mathOperator.italicCorrection(); } 55 55 56 void updateTokenContent(const String& operatorString);57 56 void updateTokenContent() final; 58 57 void updateOperatorProperties(); 59 58 void updateFromElement() final; 60 UChar textContent() const; 59 virtual UChar textContent() const; 60 61 protected: 62 void rebuildTokenContent(); 63 64 MathMLOperatorDictionary::Form m_operatorForm; 65 unsigned short m_operatorFlags; 61 66 62 67 private: … … 78 83 Optional<int> firstLineBaseline() const final; 79 84 RenderMathMLOperator* unembellishedOperator() final { return this; } 80 void rebuildTokenContent();81 85 82 86 bool shouldAllowStretching() const; … … 89 93 LayoutUnit verticalStretchedOperatorShift() const; 90 94 91 LayoutUnit m_stretchHeightAboveBaseline ;92 LayoutUnit m_stretchDepthBelowBaseline ;95 LayoutUnit m_stretchHeightAboveBaseline { 0 }; 96 LayoutUnit m_stretchDepthBelowBaseline { 0 }; 93 97 LayoutUnit m_stretchWidth; 94 98 95 UChar m_textContent; 96 bool m_isVertical; 97 MathMLOperatorDictionary::Form m_operatorForm; 98 unsigned short m_operatorFlags; 99 bool m_isVertical { true }; 99 100 LayoutUnit m_leadingSpace; 100 101 LayoutUnit m_trailingSpace;
Note: See TracChangeset
for help on using the changeset viewer.