Changeset 203150 in webkit


Ignore:
Timestamp:
Jul 12, 2016 9:47:00 PM (8 years ago)
Author:
fred.wang@free.fr
Message:

Move parsing of mpadded attributes to a MathMLPaddedElement class
https://bugs.webkit.org/show_bug.cgi?id=159620

Patch by Frederic Wang <fwang@igalia.com> on 2016-07-12
Reviewed by Brent Fulgham.

No new tests, behavior is unchanged.

  • CMakeLists.txt: Add MathMLPaddedElement files.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • mathml/MathMLAllInOne.cpp: Ditto.
  • mathml/MathMLInlineContainerElement.cpp: Remove handling of mpadded.
  • mathml/MathMLPaddedElement.cpp: Added.

(WebCore::MathMLPaddedElement::MathMLPaddedElement):
(WebCore::MathMLPaddedElement::create):
(WebCore::MathMLPaddedElement::width): Expose width attribute as a MathMLLength until mpadded
pseudo-units are supported.
(WebCore::MathMLPaddedElement::height): Ditto.
(WebCore::MathMLPaddedElement::depth): Ditto
(WebCore::MathMLPaddedElement::lspace): Ditto.
(WebCore::MathMLPaddedElement::voffset): Ditto.
(WebCore::MathMLPaddedElement::parseAttribute): Make length attribute dirty.
(WebCore::MathMLPaddedElement::createElementRenderer): Moved code from MathMLInlineContainerElement.

  • mathml/MathMLPaddedElement.h: Added.
  • mathml/mathtags.in: Map mapdded to MathMLPaddedElement.
  • rendering/mathml/RenderMathMLPadded.cpp:

(WebCore::RenderMathMLPadded::resolveWidth): Helper function to resolve width.
(WebCore::RenderMathMLPadded::resolveAttributes): Helper function to resolve all attributes.
(WebCore::RenderMathMLPadded::computePreferredLogicalWidths): Use resolveWidth.
(WebCore::RenderMathMLPadded::layoutBlock): Use resolveAttributes.

  • rendering/mathml/RenderMathMLPadded.h: Add new helper functions to access attributes from

the MathMLPaddedElement class.

Location:
trunk/Source/WebCore
Files:
1 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r203116 r203150  
    19881988    mathml/MathMLMencloseElement.cpp
    19891989    mathml/MathMLOperatorDictionary.cpp
     1990    mathml/MathMLPaddedElement.cpp
    19901991    mathml/MathMLSelectElement.cpp
    19911992    mathml/MathMLSpaceElement.cpp
  • trunk/Source/WebCore/ChangeLog

    r203149 r203150  
     12016-07-12  Frederic Wang  <fwang@igalia.com>
     2
     3        Move parsing of mpadded attributes to a MathMLPaddedElement class
     4        https://bugs.webkit.org/show_bug.cgi?id=159620
     5
     6        Reviewed by Brent Fulgham.
     7
     8        No new tests, behavior is unchanged.
     9
     10        * CMakeLists.txt: Add MathMLPaddedElement files.
     11        * WebCore.xcodeproj/project.pbxproj: Ditto.
     12        * mathml/MathMLAllInOne.cpp: Ditto.
     13        * mathml/MathMLInlineContainerElement.cpp: Remove handling of mpadded.
     14        * mathml/MathMLPaddedElement.cpp: Added.
     15        (WebCore::MathMLPaddedElement::MathMLPaddedElement):
     16        (WebCore::MathMLPaddedElement::create):
     17        (WebCore::MathMLPaddedElement::width): Expose width attribute as a MathMLLength until mpadded
     18        pseudo-units are supported.
     19        (WebCore::MathMLPaddedElement::height): Ditto.
     20        (WebCore::MathMLPaddedElement::depth): Ditto
     21        (WebCore::MathMLPaddedElement::lspace): Ditto.
     22        (WebCore::MathMLPaddedElement::voffset): Ditto.
     23        (WebCore::MathMLPaddedElement::parseAttribute): Make length attribute dirty.
     24        (WebCore::MathMLPaddedElement::createElementRenderer): Moved code from MathMLInlineContainerElement.
     25        * mathml/MathMLPaddedElement.h: Added.
     26        * mathml/mathtags.in: Map mapdded to MathMLPaddedElement.
     27        * rendering/mathml/RenderMathMLPadded.cpp:
     28        (WebCore::RenderMathMLPadded::resolveWidth): Helper function to resolve width.
     29        (WebCore::RenderMathMLPadded::resolveAttributes): Helper function to resolve all attributes.
     30        (WebCore::RenderMathMLPadded::computePreferredLogicalWidths): Use resolveWidth.
     31        (WebCore::RenderMathMLPadded::layoutBlock): Use resolveAttributes.
     32        * rendering/mathml/RenderMathMLPadded.h: Add new helper functions to access attributes from
     33        the MathMLPaddedElement class.
     34
    1352016-07-12  Andreas Kling  <akling@apple.com>
    236
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r203116 r203150  
    72097209                FED13D400CEA939400D89466 /* IconIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FED13D3F0CEA939400D89466 /* IconIOS.mm */; };
    72107210                FED13D520CEA949700D89466 /* RenderThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = FED13D500CEA949700D89466 /* RenderThemeIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
     7211                B59CA390CED66C3255F72C59 /* MathMLPaddedElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B59CA59AF170D8FAA5B8CABE /* MathMLPaddedElement.cpp */; };
    72117212                FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */; };
    72127213                FEE1811316C319E800084849 /* SQLTransactionBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEE1811116C319E800084849 /* SQLTransactionBackend.cpp */; };
     
    1002610027                5958F1CB1343917C0080B31F /* XMLViewer.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = XMLViewer.css; sourceTree = "<group>"; };
    1002710028                5958F1CC1343917C0080B31F /* XMLViewer.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = XMLViewer.js; sourceTree = "<group>"; };
     10029                B59CA849D41E6F65D81198BC /* MathMLPaddedElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLPaddedElement.h; sourceTree = "<group>"; };
    1002810030                59780849D41E6F65D81198BC /* MathMLSelectElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLSelectElement.h; sourceTree = "<group>"; };
    1002910031                598365DC1355F53C001B185D /* JSPositionCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPositionCallback.h; sourceTree = "<group>"; };
     
    1504715049                F5E0C6591643C42C00D6CB69 /* BaseChooserOnlyDateAndTimeInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseChooserOnlyDateAndTimeInputType.cpp; sourceTree = "<group>"; };
    1504815050                F5E0C65A1643C42C00D6CB69 /* BaseChooserOnlyDateAndTimeInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseChooserOnlyDateAndTimeInputType.h; sourceTree = "<group>"; };
     15051                B59CA59AF170D8FAA5B8CABE /* MathMLPaddedElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLPaddedElement.cpp; sourceTree = "<group>"; };
    1504915052                F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLSelectElement.cpp; sourceTree = "<group>"; };
    1505015053                F8216299029F4FB501000131 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
     
    2486424867                                D4F72C653A64807A83E76FB8 /* MathMLOperatorDictionary.cpp */,
    2486524868                                DF7E9A294C7AACE0AD89B3DD /* MathMLOperatorDictionary.h */,
     24869                                B59CA59AF170D8FAA5B8CABE /* MathMLPaddedElement.cpp */,
     24870                                B59CA849D41E6F65D81198BC /* MathMLPaddedElement.h */,
    2486624871                                F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */,
    2486724872                                59780849D41E6F65D81198BC /* MathMLSelectElement.h */,
     
    3122631231                                FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */,
    3122731232                                439176DF12DA25E17BAF80A2 /* MathMLStyle.cpp in Sources */,
     31233                                B59CA390CED66C3255F72C59 /* MathMLPaddedElement.cpp in Sources */,
    3122831234                                FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */,
    3122931235                                4FA65A6B1108ABED002615E0 /* MathMLSpaceElement.cpp in Sources */,
  • trunk/Source/WebCore/mathml/MathMLAllInOne.cpp

    r203116 r203150  
    3131#include "MathMLMencloseElement.cpp"
    3232#include "MathMLOperatorDictionary.cpp"
     33#include "MathMLPaddedElement.cpp"
    3334#include "MathMLSelectElement.cpp"
    3435#include "MathMLTextElement.cpp"
  • trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp

    r203072 r203150  
    3636#include "RenderMathMLFraction.h"
    3737#include "RenderMathMLMenclose.h"
    38 #include "RenderMathMLPadded.h"
    3938#include "RenderMathMLRoot.h"
    4039#include "RenderMathMLRow.h"
     
    8180    if (hasTagName(mtableTag))
    8281        return createRenderer<RenderMathMLTable>(*this, WTFMove(style));
    83     if (hasTagName(mpaddedTag))
    84         return createRenderer<RenderMathMLPadded>(*this, WTFMove(style));
    8582
    8683    return createRenderer<RenderMathMLBlock>(*this, WTFMove(style));
  • trunk/Source/WebCore/mathml/MathMLPaddedElement.h

    r203149 r203150  
    2424 */
    2525
    26 #ifndef RenderMathMLPadded_h
    27 #define RenderMathMLPadded_h
    28 #pragma once
     26#ifndef MathMLPaddedElement_h
     27#define MathMLPaddedElement_h
    2928
    3029#if ENABLE(MATHML)
    31 
    32 #include "RenderMathMLRow.h"
     30#include "MathMLInlineContainerElement.h"
    3331
    3432namespace WebCore {
    3533
    36 class RenderMathMLPadded final : public RenderMathMLRow {
     34class MathMLPaddedElement final : public MathMLInlineContainerElement {
    3735public:
    38     RenderMathMLPadded(Element&, RenderStyle&&);
     36    static Ref<MathMLPaddedElement> create(const QualifiedName& tagName, Document&);
     37    // FIXME: Pseudo-units are not supported yet (https://bugs.webkit.org/show_bug.cgi?id=85730).
     38    const Length& width();
     39    const Length& height();
     40    const Length& depth();
     41    const Length& lspace();
     42    const Length& voffset();
     43private:
     44    MathMLPaddedElement(const QualifiedName& tagName, Document&);
     45    RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
     46    void parseAttribute(const QualifiedName&, const AtomicString&) final;
    3947
    40 private:
    41     const char* renderName() const final { return "RenderMathMLPadded"; }
    42     bool isRenderMathMLPadded() const final { return true; }
    43 
    44     void computePreferredLogicalWidths() final;
    45     void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
    46     Optional<int> firstLineBaseline() const final;
    47 
    48     void updateFromElement() final;
    49     void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
    50 
    51     LayoutUnit m_ascent;
     48    Length m_width;
     49    Length m_height;
     50    Length m_depth;
     51    Length m_lspace;
     52    Length m_voffset;
    5253};
    5354
    54 } // namespace WebCore
    55 
    56 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLPadded, isRenderMathMLPadded())
     55}
    5756
    5857#endif // ENABLE(MATHML)
    59 #endif // RenderMathMLPadded_h
     58#endif // MathMLPaddedElement_h
  • trunk/Source/WebCore/mathml/mathtags.in

    r203108 r203150  
    1212msubsup interfaceName=MathMLInlineContainerElement
    1313merror interfaceName=MathMLInlineContainerElement
    14 mpadded interfaceName=MathMLInlineContainerElement
     14mpadded interfaceName=MathMLPaddedElement
    1515mphantom interfaceName=MathMLInlineContainerElement
    1616mrow interfaceName=MathMLInlineContainerElement
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLPadded.cpp

    r202962 r203150  
    4141}
    4242
     43void RenderMathMLPadded::resolveWidth(LayoutUnit& width)
     44{
     45    auto& paddedElement = element();
     46    width = toUserUnits(paddedElement.width(), style(), width);
     47    if (width < 0)
     48        width = 0;
     49}
     50
     51void RenderMathMLPadded::resolveAttributes(LayoutUnit& width, LayoutUnit& height, LayoutUnit& depth, LayoutUnit& lspace, LayoutUnit& voffset)
     52{
     53    resolveWidth(width);
     54    auto& paddedElement = element();
     55    height = toUserUnits(paddedElement.height(), style(), height);
     56    depth = toUserUnits(paddedElement.depth(), style(), depth);
     57    lspace = toUserUnits(paddedElement.lspace(), style(), lspace);
     58    voffset = toUserUnits(paddedElement.voffset(), style(), voffset);
     59    if (height < 0)
     60        height = 0;
     61    if (depth < 0)
     62        depth = 0;
     63    // FIXME: Negative lspace values are not supported yet (https://bugs.webkit.org/show_bug.cgi?id=85730).
     64    if (lspace < 0)
     65        lspace = 0;
     66}
     67
    4368void RenderMathMLPadded::computePreferredLogicalWidths()
    4469{
     
    5176    // We parse it using the preferred width of the content as its default value.
    5277    LayoutUnit width = m_maxPreferredLogicalWidth;
    53     parseMathMLLength(element()->fastGetAttribute(MathMLNames::widthAttr), width, &style(), false);
    54 
     78    resolveWidth(width);
    5579    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = width;
    5680
     
    7397
    7498    // We parse the mpadded attributes using the content metrics as the default value.
    75     // FIXME: We should also accept pseudo-units and (some) negative values.
    76     // See https://bugs.webkit.org/show_bug.cgi?id=85730
    7799    LayoutUnit width = contentWidth;
    78100    LayoutUnit ascent = contentAscent;
     
    80102    LayoutUnit lspace = 0;
    81103    LayoutUnit voffset = 0;
    82     parseMathMLLength(element()->fastGetAttribute(MathMLNames::widthAttr), width, &style());
    83     parseMathMLLength(element()->fastGetAttribute(MathMLNames::heightAttr), ascent, &style());
    84     parseMathMLLength(element()->fastGetAttribute(MathMLNames::depthAttr), descent, &style());
    85     parseMathMLLength(element()->fastGetAttribute(MathMLNames::lspaceAttr), lspace, &style());
    86     parseMathMLLength(element()->fastGetAttribute(MathMLNames::voffsetAttr), voffset, &style());
    87     if (width < 0)
    88         width = 0;
    89     if (ascent < 0)
    90         ascent = 0;
    91     if (descent < 0)
    92         descent = 0;
    93     if (lspace < 0)
    94         lspace = 0;
     104    resolveAttributes(width, ascent, descent, lspace, voffset);
    95105
    96106    // Align children on the new baseline and shift them by (lspace, -voffset)
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLPadded.h

    r202962 r203150  
    3030#if ENABLE(MATHML)
    3131
     32#include "MathMLPaddedElement.h"
    3233#include "RenderMathMLRow.h"
    3334
     
    4950    void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
    5051
     52    MathMLPaddedElement& element() const { return static_cast<MathMLPaddedElement&>(nodeForNonAnonymous()); }
     53    void resolveWidth(LayoutUnit& width);
     54    void resolveAttributes(LayoutUnit& width, LayoutUnit& height, LayoutUnit& depth, LayoutUnit& lspace, LayoutUnit& voffset);
     55
    5156    LayoutUnit m_ascent;
    5257};
Note: See TracChangeset for help on using the changeset viewer.