Changeset 107263 in webkit


Ignore:
Timestamp:
Feb 9, 2012 11:11:57 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

MathML internals for bug 52444 fix - type checking, PassRefPtr
https://bugs.webkit.org/show_bug.cgi?id=78180

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

static_cast<Element*>(node()) is done in methods in RenderMathMLFenced.cpp and a few
other files. It is more type-safe if the RenderMathMLFenced() or other constructor only
accepts an Element*, not a Node*. Also a couple functions were changed to return a
PassRefPtr instead of a RefPtr.

No new tests.

  • rendering/mathml/RenderMathMLFenced.cpp:

(WebCore::RenderMathMLFenced::RenderMathMLFenced):
(WebCore::RenderMathMLFenced::updateFromElement):
(WebCore::RenderMathMLFenced::makeOperatorStyle):
(WebCore::RenderMathMLFenced::makeFences):
(WebCore::RenderMathMLFenced::addChild):

  • rendering/mathml/RenderMathMLFenced.h:

(RenderMathMLFenced):

  • rendering/mathml/RenderMathMLFraction.cpp:

(WebCore::RenderMathMLFraction::RenderMathMLFraction):

  • rendering/mathml/RenderMathMLFraction.h:

(RenderMathMLFraction):

  • rendering/mathml/RenderMathMLMath.cpp:

(WebCore::RenderMathMLMath::RenderMathMLMath):

  • rendering/mathml/RenderMathMLMath.h:

(RenderMathMLMath):

  • rendering/mathml/RenderMathMLOperator.cpp:

(WebCore::RenderMathMLOperator::RenderMathMLOperator):
(WebCore::RenderMathMLOperator::updateFromElement):
(WebCore::RenderMathMLOperator::createStackableStyle):
(WebCore::RenderMathMLOperator::createGlyph):

  • rendering/mathml/RenderMathMLOperator.h:

(RenderMathMLOperator):

  • rendering/mathml/RenderMathMLRoot.cpp:

(WebCore::RenderMathMLRoot::RenderMathMLRoot):
(WebCore::RenderMathMLRoot::layout):

  • rendering/mathml/RenderMathMLRoot.h:

(RenderMathMLRoot):

  • rendering/mathml/RenderMathMLRow.cpp:

(WebCore::RenderMathMLRow::RenderMathMLRow):

  • rendering/mathml/RenderMathMLRow.h:

(RenderMathMLRow):

  • rendering/mathml/RenderMathMLSquareRoot.cpp:

(WebCore::RenderMathMLSquareRoot::RenderMathMLSquareRoot):

  • rendering/mathml/RenderMathMLSquareRoot.h:

(RenderMathMLSquareRoot):

  • rendering/mathml/RenderMathMLSubSup.cpp:

(WebCore::RenderMathMLSubSup::addChild):

  • rendering/mathml/RenderMathMLSubSup.h:

(RenderMathMLSubSup):

  • rendering/mathml/RenderMathMLUnderOver.cpp:

(WebCore::RenderMathMLUnderOver::RenderMathMLUnderOver):

  • rendering/mathml/RenderMathMLUnderOver.h:

(RenderMathMLUnderOver):

Location:
trunk/Source/WebCore
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r107261 r107263  
     12012-02-09  David Barton  <dbarton@mathscribe.com>
     2
     3        MathML internals for bug 52444 fix - type checking, PassRefPtr
     4        https://bugs.webkit.org/show_bug.cgi?id=78180
     5
     6        Reviewed by Eric Seidel.
     7       
     8        static_cast<Element*>(node()) is done in methods in RenderMathMLFenced.cpp and a few
     9        other files. It is more type-safe if the RenderMathMLFenced() or other constructor only
     10        accepts an Element*, not a Node*. Also a couple functions were changed to return a
     11        PassRefPtr instead of a RefPtr.
     12
     13        No new tests.
     14
     15        * rendering/mathml/RenderMathMLFenced.cpp:
     16        (WebCore::RenderMathMLFenced::RenderMathMLFenced):
     17        (WebCore::RenderMathMLFenced::updateFromElement):
     18        (WebCore::RenderMathMLFenced::makeOperatorStyle):
     19        (WebCore::RenderMathMLFenced::makeFences):
     20        (WebCore::RenderMathMLFenced::addChild):
     21        * rendering/mathml/RenderMathMLFenced.h:
     22        (RenderMathMLFenced):
     23        * rendering/mathml/RenderMathMLFraction.cpp:
     24        (WebCore::RenderMathMLFraction::RenderMathMLFraction):
     25        * rendering/mathml/RenderMathMLFraction.h:
     26        (RenderMathMLFraction):
     27        * rendering/mathml/RenderMathMLMath.cpp:
     28        (WebCore::RenderMathMLMath::RenderMathMLMath):
     29        * rendering/mathml/RenderMathMLMath.h:
     30        (RenderMathMLMath):
     31        * rendering/mathml/RenderMathMLOperator.cpp:
     32        (WebCore::RenderMathMLOperator::RenderMathMLOperator):
     33        (WebCore::RenderMathMLOperator::updateFromElement):
     34        (WebCore::RenderMathMLOperator::createStackableStyle):
     35        (WebCore::RenderMathMLOperator::createGlyph):
     36        * rendering/mathml/RenderMathMLOperator.h:
     37        (RenderMathMLOperator):
     38        * rendering/mathml/RenderMathMLRoot.cpp:
     39        (WebCore::RenderMathMLRoot::RenderMathMLRoot):
     40        (WebCore::RenderMathMLRoot::layout):
     41        * rendering/mathml/RenderMathMLRoot.h:
     42        (RenderMathMLRoot):
     43        * rendering/mathml/RenderMathMLRow.cpp:
     44        (WebCore::RenderMathMLRow::RenderMathMLRow):
     45        * rendering/mathml/RenderMathMLRow.h:
     46        (RenderMathMLRow):
     47        * rendering/mathml/RenderMathMLSquareRoot.cpp:
     48        (WebCore::RenderMathMLSquareRoot::RenderMathMLSquareRoot):
     49        * rendering/mathml/RenderMathMLSquareRoot.h:
     50        (RenderMathMLSquareRoot):
     51        * rendering/mathml/RenderMathMLSubSup.cpp:
     52        (WebCore::RenderMathMLSubSup::addChild):
     53        * rendering/mathml/RenderMathMLSubSup.h:
     54        (RenderMathMLSubSup):
     55        * rendering/mathml/RenderMathMLUnderOver.cpp:
     56        (WebCore::RenderMathMLUnderOver::RenderMathMLUnderOver):
     57        * rendering/mathml/RenderMathMLUnderOver.h:
     58        (RenderMathMLUnderOver):
     59
    1602012-02-09  Andreas Kling  <awesomekling@apple.com>
    261
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp

    r103824 r107263  
    4545static const float gOperatorPadding = 0.1f;
    4646
    47 RenderMathMLFenced::RenderMathMLFenced(Node* fenced)
    48     : RenderMathMLRow(fenced)
     47RenderMathMLFenced::RenderMathMLFenced(Element* element)
     48    : RenderMathMLRow(element)
    4949    , m_open(OpeningBraceChar)
    5050    , m_close(ClosingBraceChar)
     
    6464        m_close = closeValue[0];
    6565   
    66     AtomicString separators = static_cast<Element*>(fenced)->getAttribute(MathMLNames::separatorsAttr);
     66    AtomicString separators = fenced->getAttribute(MathMLNames::separatorsAttr);
    6767    if (!separators.isNull()) {
    6868        StringBuilder characters;
     
    8181}
    8282
    83 RefPtr<RenderStyle> RenderMathMLFenced::makeOperatorStyle()
     83PassRefPtr<RenderStyle> RenderMathMLFenced::makeOperatorStyle()
    8484{
    8585    RefPtr<RenderStyle> newStyle = RenderStyle::create();
     
    8787    newStyle->setDisplay(INLINE_BLOCK);
    8888    newStyle->setPaddingRight(Length(static_cast<int>(gOperatorPadding * style()->fontSize()), Fixed));
    89     return newStyle;
     89    return newStyle.release();
    9090}
    9191
     
    9393{
    9494    RenderObject* openFence = new (renderArena()) RenderMathMLOperator(node(), m_open);
    95     openFence->setStyle(makeOperatorStyle().release());
     95    openFence->setStyle(makeOperatorStyle());
    9696    RenderBlock::addChild(openFence, firstChild());
    9797    RenderObject* closeFence = new (renderArena()) RenderMathMLOperator(node(), m_close);
    98     closeFence->setStyle(makeOperatorStyle().release());
     98    closeFence->setStyle(makeOperatorStyle());
    9999    RenderBlock::addChild(closeFence);
    100100}
     
    123123               
    124124            RenderObject* separatorObj = new (renderArena()) RenderMathMLOperator(node(), separator);
    125             separatorObj->setStyle(makeOperatorStyle().release());
     125            separatorObj->setStyle(makeOperatorStyle());
    126126            RenderBlock::addChild(separatorObj, lastChild());
    127127        }
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.h

    r95901 r107263  
    3535class RenderMathMLFenced : public RenderMathMLRow {
    3636public:
    37     RenderMathMLFenced(Node *fraction);
     37    RenderMathMLFenced(Element*);
    3838    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
    3939    virtual void updateFromElement();
     
    4242    virtual const char* renderName() const { return "RenderMathMLFenced"; }
    4343
     44    PassRefPtr<RenderStyle> makeOperatorStyle();
    4445    void makeFences();
    45     RefPtr<RenderStyle> makeOperatorStyle();
     46   
    4647    UChar m_open;
    4748    UChar m_close;
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp

    r107019 r107263  
    4747static const float gDenominatorPad = 0.1f;
    4848
    49 RenderMathMLFraction::RenderMathMLFraction(Element* fraction)
    50     : RenderMathMLBlock(fraction)
     49RenderMathMLFraction::RenderMathMLFraction(Element* element)
     50    : RenderMathMLBlock(element)
    5151    , m_lineThickness(gLineMedium)
    5252{
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h

    r106900 r107263  
    3636class RenderMathMLFraction : public RenderMathMLBlock {
    3737public:
    38     RenderMathMLFraction(Element* fraction);
     38    RenderMathMLFraction(Element*);
    3939    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
    4040    virtual void updateFromElement();
     
    4545private:
    4646    virtual const char* renderName() const { return "RenderMathMLFraction"; }
     47   
    4748    float m_lineThickness;
    4849};
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLMath.cpp

    r107019 r107263  
    3636using namespace MathMLNames;
    3737
    38 RenderMathMLMath::RenderMathMLMath(Node* math)
    39     : RenderMathMLRow(math)
     38RenderMathMLMath::RenderMathMLMath(Element* element)
     39    : RenderMathMLRow(element)
    4040{
    4141}
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLMath.h

    r107019 r107263  
    3535class RenderMathMLMath : public RenderMathMLRow {
    3636public:
    37     RenderMathMLMath(Node* container);
     37    RenderMathMLMath(Element*);
    3838    virtual bool isRenderMathMLMath() const { return true; }
    3939
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r106900 r107263  
    3939using namespace MathMLNames;
    4040
    41 RenderMathMLOperator::RenderMathMLOperator(Node* container)
    42     : RenderMathMLBlock(container)
     41RenderMathMLOperator::RenderMathMLOperator(Element* element)
     42    : RenderMathMLBlock(element)
    4343    , m_stretchHeight(0)
    4444    , m_operator(0)
     
    4646}
    4747
    48 RenderMathMLOperator::RenderMathMLOperator(Node* container, UChar operatorChar)
    49     : RenderMathMLBlock(container)
     48RenderMathMLOperator::RenderMathMLOperator(Node* node, UChar operatorChar)
     49    : RenderMathMLBlock(node)
    5050    , m_stretchHeight(0)
    5151    , m_operator(convertHyphenMinusToMinusSign(operatorChar))
     
    140140    bool stretchDisabled = false;
    141141   
    142     // We made need the element later if we can't stretch.
     142    // We may need the element later if we can't stretch.
    143143    if (node()->nodeType() == Node::ELEMENT_NODE) {
    144144        if (Element* mo = static_cast<Element*>(node())) {
     
    283283}
    284284
    285 RefPtr<RenderStyle> RenderMathMLOperator::createStackableStyle(int size, int topRelative)
     285PassRefPtr<RenderStyle> RenderMathMLOperator::createStackableStyle(int size, int topRelative)
    286286{
    287287    RefPtr<RenderStyle> newStyle = RenderStyle::create();
     
    308308    }
    309309
    310     return newStyle;
     310    return newStyle.release();
    311311}
    312312
     
    314314{
    315315    RenderBlock* container = new (renderArena()) RenderMathMLBlock(node());
    316     container->setStyle(createStackableStyle(size, topRelative).release());
     316    container->setStyle(createStackableStyle(size, topRelative));
    317317    addChild(container);
    318318    RenderBlock* parent = container;
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h

    r107019 r107263  
    3636class RenderMathMLOperator : public RenderMathMLBlock {
    3737public:
    38     RenderMathMLOperator(Node* container);
    39     RenderMathMLOperator(Node* container, UChar operatorChar);
     38    RenderMathMLOperator(Element*);
     39    RenderMathMLOperator(Node*, UChar operatorChar);
    4040    virtual bool isRenderMathMLOperator() const { return true; }
    4141    virtual void stretchToHeight(int pixelHeight);
     
    4646protected:
    4747    virtual void layout();
    48     virtual RefPtr<RenderStyle> createStackableStyle(int size, int topRelative);
     48    virtual PassRefPtr<RenderStyle> createStackableStyle(int size, int topRelative);
    4949    virtual RenderBlock* createGlyph(UChar glyph, int size = 0, int charRelative = 0, int topRelative = 0);
    5050   
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp

    r107019 r107263  
    6565const float gRadicalThickLineThickness = 0.1f;
    6666   
    67 RenderMathMLRoot::RenderMathMLRoot(Node *expression)
    68 : RenderMathMLBlock(expression)
     67RenderMathMLRoot::RenderMathMLRoot(Element* element)
     68    : RenderMathMLBlock(element)
    6969{
    7070}
     
    233233    LayoutUnit indexShift = indexBox->offsetWidth() + topStartShift;
    234234    LayoutUnit radicalHeight = static_cast<LayoutUnit>((1 - gRadicalTopLeftPointYPos) * maxHeight);
    235     LayoutUnit rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->offsetHeight() - (maxHeight + static_cast<LayoutUnit>(gRootPadding * style()->fontSize()));
     235    LayoutUnit rootMarginTop = radicalHeight + style()->paddingBottom().value() + indexBox->offsetHeight()
     236        - (maxHeight + static_cast<LayoutUnit>(gRootPadding * style()->fontSize()));
    236237   
    237238    style()->setPaddingLeft(Length(indexShift, Fixed));
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRoot.h

    r95901 r107263  
    3535class RenderMathMLRoot : public RenderMathMLBlock {
    3636public:
    37     RenderMathMLRoot(Node* fraction);
     37    RenderMathMLRoot(Element*);
    3838    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
    3939    virtual void paint(PaintInfo&, const LayoutPoint&);
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp

    r107019 r107263  
    3737using namespace MathMLNames;
    3838
    39 RenderMathMLRow::RenderMathMLRow(Node* row)
    40     : RenderMathMLBlock(row)
     39RenderMathMLRow::RenderMathMLRow(Element* element)
     40    : RenderMathMLBlock(element)
    4141{
    4242}
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.h

    r107019 r107263  
    3535class RenderMathMLRow : public RenderMathMLBlock {
    3636public:
    37     RenderMathMLRow(Node* container);
     37    RenderMathMLRow(Element*);
    3838    virtual bool isRenderMathMLRow() const { return true; }
    3939    virtual int nonOperatorHeight() const;
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.cpp

    r107019 r107263  
    6262const float gRadicalThickLineThickness = 0.1f;
    6363   
    64 RenderMathMLSquareRoot::RenderMathMLSquareRoot(Node *expression)
    65     : RenderMathMLBlock(expression)
     64RenderMathMLSquareRoot::RenderMathMLSquareRoot(Element* element)
     65    : RenderMathMLBlock(element)
    6666{
    6767}
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLSquareRoot.h

    r107019 r107263  
    3535class RenderMathMLSquareRoot : public RenderMathMLBlock {
    3636public:
    37     RenderMathMLSquareRoot(Node* fraction);
     37    RenderMathMLSquareRoot(Element*);
    3838    virtual void paint(PaintInfo&, const LayoutPoint&);
    3939protected:
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp

    r107019 r107263  
    5757void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild)
    5858{
    59    
    6059    // Note: The RenderMathMLBlock only allows element children to be added.
    6160    Element* childElement = toElement(child->node());
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.h

    r107019 r107263  
    3535class RenderMathMLSubSup : public RenderMathMLBlock {
    3636public:
    37     RenderMathMLSubSup(Element* fraction);
     37    RenderMathMLSubSup(Element*);
    3838    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
    3939    virtual bool hasBase() const { return true; }
     
    5858
    5959#endif // RenderMathMLSubSup_h
    60 
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.cpp

    r107019 r107263  
    3939static const double gOverSpacingAdjustment = 0.5;
    4040   
    41 RenderMathMLUnderOver::RenderMathMLUnderOver(Node* expression)
    42     : RenderMathMLBlock(expression)
    43 {
    44     Element* element = static_cast<Element*>(expression);
     41RenderMathMLUnderOver::RenderMathMLUnderOver(Element* element)
     42    : RenderMathMLBlock(element)
     43{
    4544    // Determine what kind of under/over expression we have by element name
    4645   
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLUnderOver.h

    r107019 r107263  
    3535class RenderMathMLUnderOver : public RenderMathMLBlock {
    3636public:
    37     RenderMathMLUnderOver(Node* expression);
     37    RenderMathMLUnderOver(Element*);
    3838    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
    3939    virtual void layout();
Note: See TracChangeset for help on using the changeset viewer.