Changeset 108136 in webkit


Ignore:
Timestamp:
Feb 17, 2012 3:33:05 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

MathML internals - embellished operators, getBase() accessor functions
https://bugs.webkit.org/show_bug.cgi?id=78617

Patch by David Barton <Dave Barton> on 2012-02-17
Reviewed by Eric Seidel.

Define functions that return an unembellished "base", by omitting
subscripts/superscripts, underscripts/overscripts, or denominators. This is needed in
subsequent patches both for correct operator stretching and simple code factoring.

No new tests.

  • rendering/mathml/RenderMathMLBlock.h:

(WebCore):
(RenderMathMLBlock):
(WebCore::RenderMathMLBlock::unembellishedOperator):

  • rendering/mathml/RenderMathMLFraction.cpp:

(WebCore::RenderMathMLFraction::unembellishedOperator):
(WebCore):

  • rendering/mathml/RenderMathMLFraction.h:

(RenderMathMLFraction):

  • rendering/mathml/RenderMathMLOperator.h:

(WebCore::RenderMathMLOperator::unembellishedOperator):

  • rendering/mathml/RenderMathMLSubSup.cpp:

(WebCore::RenderMathMLSubSup::base):
(WebCore):
(WebCore::RenderMathMLSubSup::unembellishedOperator):
(WebCore::RenderMathMLSubSup::stretchToHeight):

  • renamed a variable for clarity, especially in later patches

(WebCore::RenderMathMLSubSup::layout):

  • renamed a variable for clarity, especially in later patches
  • rendering/mathml/RenderMathMLSubSup.h:

(RenderMathMLSubSup):

  • rendering/mathml/RenderMathMLUnderOver.cpp:

(WebCore::RenderMathMLUnderOver::base):
(WebCore):
(WebCore::RenderMathMLUnderOver::unembellishedOperator):
(WebCore::RenderMathMLUnderOver::stretchToHeight):

  • rendering/mathml/RenderMathMLUnderOver.h:

(RenderMathMLUnderOver):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r108135 r108136  
     12012-02-17  David Barton  <dbarton@mathscribe.com>
     2
     3        MathML internals - embellished operators, getBase() accessor functions
     4        https://bugs.webkit.org/show_bug.cgi?id=78617
     5
     6        Reviewed by Eric Seidel.
     7
     8        Define functions that return an unembellished "base", by omitting
     9        subscripts/superscripts, underscripts/overscripts, or denominators. This is needed in
     10        subsequent patches both for correct operator stretching and simple code factoring.
     11
     12        No new tests.
     13
     14        * rendering/mathml/RenderMathMLBlock.h:
     15        (WebCore):
     16        (RenderMathMLBlock):
     17        (WebCore::RenderMathMLBlock::unembellishedOperator):
     18        * rendering/mathml/RenderMathMLFraction.cpp:
     19        (WebCore::RenderMathMLFraction::unembellishedOperator):
     20        (WebCore):
     21        * rendering/mathml/RenderMathMLFraction.h:
     22        (RenderMathMLFraction):
     23        * rendering/mathml/RenderMathMLOperator.h:
     24        (WebCore::RenderMathMLOperator::unembellishedOperator):
     25        * rendering/mathml/RenderMathMLSubSup.cpp:
     26        (WebCore::RenderMathMLSubSup::base):
     27        (WebCore):
     28        (WebCore::RenderMathMLSubSup::unembellishedOperator):
     29        (WebCore::RenderMathMLSubSup::stretchToHeight):
     30            - renamed a variable for clarity, especially in later patches
     31        (WebCore::RenderMathMLSubSup::layout):
     32            - renamed a variable for clarity, especially in later patches
     33        * rendering/mathml/RenderMathMLSubSup.h:
     34        (RenderMathMLSubSup):
     35        * rendering/mathml/RenderMathMLUnderOver.cpp:
     36        (WebCore::RenderMathMLUnderOver::base):
     37        (WebCore):
     38        (WebCore::RenderMathMLUnderOver::unembellishedOperator):
     39        (WebCore::RenderMathMLUnderOver::stretchToHeight):
     40        * rendering/mathml/RenderMathMLUnderOver.h:
     41        (RenderMathMLUnderOver):
     42
    1432012-02-17  No'am Rosenthal  <noam.rosenthal@nokia.com>
    244
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h

    r107473 r108136  
    3535namespace WebCore {
    3636   
     37class RenderMathMLOperator;
     38
    3739class RenderMathMLBlock : public RenderBlock {
    3840public:
     
    4446    virtual bool isRenderMathMLRow() const { return false; }
    4547    virtual bool isRenderMathMLMath() const { return false; }
     48   
     49    // MathML defines an "embellished operator" as roughly an <mo> that may have subscripts,
     50    // superscripts, underscripts, overscripts, or a denominator (as in d/dx, where "d" is some
     51    // differential operator). The padding, precedence, and stretchiness of the base <mo> should
     52    // apply to the embellished operator as a whole. unembellishedOperator() checks for being an
     53    // embellished operator, and omits any embellishments.
     54    // FIXME: We don't yet handle all the cases in the MathML spec. See
     55    // https://bugs.webkit.org/show_bug.cgi?id=78617.
     56    virtual RenderMathMLOperator* unembellishedOperator() { return 0; }
    4657    virtual bool hasBase() const { return false; }
    4758    virtual int nonOperatorHeight() const;
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp

    r107473 r108136  
    120120}
    121121
     122RenderMathMLOperator* RenderMathMLFraction::unembellishedOperator()
     123{
     124    RenderObject* numeratorWrapper = firstChild();
     125    if (!numeratorWrapper)
     126        return 0;
     127    RenderObject* numerator = numeratorWrapper->firstChild();
     128    if (!numerator || !numerator->isRenderMathMLBlock())
     129        return 0;
     130    return toRenderMathMLBlock(numerator)->unembellishedOperator();
     131}
     132
    122133void RenderMathMLFraction::layout()
    123134{
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h

    r107263 r108136  
    3939    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
    4040    virtual void updateFromElement();
     41   
     42    virtual RenderMathMLOperator* unembellishedOperator();
     43   
    4144    virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
    4245    virtual void paint(PaintInfo&, const LayoutPoint&);
    4346protected:
    4447    virtual void layout();
     48   
    4549private:
    4650    virtual const char* renderName() const { return "RenderMathMLFraction"; }
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h

    r107263 r108136  
    3939    RenderMathMLOperator(Node*, UChar operatorChar);
    4040    virtual bool isRenderMathMLOperator() const { return true; }
     41    virtual RenderMathMLOperator* unembellishedOperator() { return this; }
    4142    virtual void stretchToHeight(int pixelHeight);
    4243    virtual void updateFromElement();
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp

    r107880 r108136  
    5555}
    5656
     57RenderBoxModelObject* RenderMathMLSubSup::base() const
     58{
     59    RenderObject* baseWrapper = firstChild();
     60    if (!baseWrapper)
     61        return 0;
     62    RenderObject* base = baseWrapper->firstChild();
     63    if (!base || !base->isBoxModelObject())
     64        return 0;
     65    return toRenderBoxModelObject(base);
     66}
     67
    5768void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild)
    5869{
     
    105116}
    106117
     118RenderMathMLOperator* RenderMathMLSubSup::unembellishedOperator()
     119{
     120    RenderBoxModelObject* base = this->base();
     121    if (!base || !base->isRenderMathMLBlock())
     122        return 0;
     123    return toRenderMathMLBlock(base)->unembellishedOperator();
     124}
     125
    107126void RenderMathMLSubSup::stretchToHeight(int height)
    108127{
    109     RenderObject* base = firstChild();
    110     if (!base || !base->firstChild())
     128    RenderObject* baseWrapper = firstChild();
     129    if (!baseWrapper || !baseWrapper->firstChild())
    111130        return;
    112131   
    113     if (base->firstChild() && base->firstChild()->isRenderMathMLBlock()) {
    114         RenderMathMLBlock* block = toRenderMathMLBlock(base->firstChild());
     132    if (baseWrapper->firstChild() && baseWrapper->firstChild()->isRenderMathMLBlock()) {
     133        RenderMathMLBlock* block = toRenderMathMLBlock(baseWrapper->firstChild());
    115134        block->stretchToHeight(static_cast<int>(gSubSupStretch * height));
    116135       
     
    154173   
    155174    if (m_kind == SubSup) {
    156         if (RenderObject* base = firstChild()) {
     175        if (RenderObject* baseWrapper = firstChild()) {
    157176            LayoutUnit maxHeight = 0;
    158             RenderObject* current = base->firstChild();
     177            RenderObject* current = baseWrapper->firstChild();
    159178            while (current) {
    160179                LayoutUnit height = getBoxModelObjectHeight(current);
     
    166185            if (heightDiff < 0)
    167186                heightDiff = 0;
    168             base->style()->setPaddingTop(Length(heightDiff, Fixed));
    169             base->setNeedsLayout(true);
     187            baseWrapper->style()->setPaddingTop(Length(heightDiff, Fixed));
     188            baseWrapper->setNeedsLayout(true);
    170189        }
    171190        setNeedsLayout(true);
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h

    r107263 r108136  
    3737    RenderMathMLSubSup(Element*);
    3838    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
     39   
     40    virtual RenderMathMLOperator* unembellishedOperator();
    3941    virtual bool hasBase() const { return true; }
    4042    virtual int nonOperatorHeight() const;
     
    4850    virtual const char* renderName() const { return "RenderMathMLSubSup"; }
    4951
     52    // Omit our subscript and/or superscript. This may return 0 for a non-MathML base (which
     53    // won't occur in valid MathML).
     54    RenderBoxModelObject* base() const;
     55   
    5056    enum SubSupType { Sub, Sup, SubSup };
    5157    SubSupType m_kind;
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp

    r107473 r108136  
    5353}
    5454
     55RenderBoxModelObject* RenderMathMLUnderOver::base() const
     56{
     57    RenderObject* baseWrapper = firstChild();
     58    if ((m_kind == Over || m_kind == UnderOver) && baseWrapper)
     59        baseWrapper = baseWrapper->nextSibling();
     60    if (!baseWrapper)
     61        return 0;
     62    RenderObject* base = baseWrapper->firstChild();
     63    if (!base || !base->isBoxModelObject())
     64        return 0;
     65    return toRenderBoxModelObject(base);
     66}
     67
    5568void RenderMathMLUnderOver::addChild(RenderObject* child, RenderObject* beforeChild)
    5669{   
     
    107120}
    108121
     122RenderMathMLOperator* RenderMathMLUnderOver::unembellishedOperator()
     123{
     124    RenderBoxModelObject* base = this->base();
     125    if (!base || !base->isRenderMathMLBlock())
     126        return 0;
     127    return toRenderMathMLBlock(base)->unembellishedOperator();
     128}
     129
    109130inline int getOffsetHeight(RenderObject* obj)
    110131{
     
    119140void RenderMathMLUnderOver::stretchToHeight(int height)
    120141{
    121 
    122     RenderObject* base = firstChild();
    123     if (!base)
    124         return;
    125        
    126     // For over or underover, the base is the sibling of the first child
    127     if (m_kind != Under)
    128         base = base->nextSibling();
    129        
    130     if (!base)
    131         return;
    132        
    133     // use the child of the row which is the actual base
    134     base = base->firstChild();
    135    
     142    RenderBoxModelObject* base = this->base();
    136143    if (base && base->isRenderMathMLBlock()) {
    137144        RenderMathMLBlock* block = toRenderMathMLBlock(base);
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h

    r107263 r108136  
    3737    RenderMathMLUnderOver(Element*);
    3838    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
     39   
     40    virtual RenderMathMLOperator* unembellishedOperator();
    3941    virtual void layout();
    4042    virtual bool hasBase() const { return true; }
     
    4244    virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
    4345    virtual void stretchToHeight(int pixelHeight);
     46   
    4447private:
    4548    virtual const char* renderName() const { return "RenderMathMLUnderOver"; }
    4649
     50    // Omit our underscript and/or overscript. This may return 0 for a non-MathML base (which
     51    // won't occur in valid MathML).
     52    RenderBoxModelObject* base() const;
     53   
    4754    enum UnderOverType { Under, Over, UnderOver };
    4855    UnderOverType m_kind;
Note: See TracChangeset for help on using the changeset viewer.