Skip to content
Permalink
Browse files
CTTE: RenderMathMLFenced always has a MathMLInlineContainerElement.
<https://webkit.org/b/122986>

This renderer is never anonymous and always has a corresponding
MathMLInlineContainerElement. Overload element() with a tighter
return type.

Also marked the class FINAL and made most methods private.

Reviewed by Anders Carlsson.


Canonical link: https://commits.webkit.org/141054@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157593 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Oct 17, 2013
1 parent d8f9cdb commit a00a9808411cf697b9db6aae419f15628ef64298
Showing with 30 additions and 17 deletions.
  1. +13 −0 Source/WebCore/ChangeLog
  2. +7 −9 Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp
  3. +10 −8 Source/WebCore/rendering/mathml/RenderMathMLFenced.h
@@ -1,3 +1,16 @@
2013-10-17 Andreas Kling <akling@apple.com>

CTTE: RenderMathMLFenced always has a MathMLInlineContainerElement.
<https://webkit.org/b/122986>

This renderer is never anonymous and always has a corresponding
MathMLInlineContainerElement. Overload element() with a tighter
return type.

Also marked the class FINAL and made most methods private.

Reviewed by Anders Carlsson.

2013-10-17 Myles C. Maxfield <mmaxfield@apple.com>

Comment AffineTransform::xScale() and yScale() to make their meanings clearer
@@ -45,7 +45,7 @@ enum Braces { OpeningBraceChar = 0x28, ClosingBraceChar = 0x29 };
static const float gSeparatorMarginEndEms = 0.25f;
static const float gFenceMarginEms = 0.1f;

RenderMathMLFenced::RenderMathMLFenced(Element& element)
RenderMathMLFenced::RenderMathMLFenced(MathMLInlineContainerElement& element)
: RenderMathMLRow(element)
, m_open(OpeningBraceChar)
, m_close(ClosingBraceChar)
@@ -55,17 +55,17 @@ RenderMathMLFenced::RenderMathMLFenced(Element& element)

void RenderMathMLFenced::updateFromElement()
{
Element* fenced = element();
const auto& fenced = element();

// FIXME: Handle open/close values with more than one character (they should be treated like text).
AtomicString openValue = fenced->getAttribute(MathMLNames::openAttr);
AtomicString openValue = fenced.getAttribute(MathMLNames::openAttr);
if (openValue.length() > 0)
m_open = openValue[0];
AtomicString closeValue = fenced->getAttribute(MathMLNames::closeAttr);
AtomicString closeValue = fenced.getAttribute(MathMLNames::closeAttr);
if (closeValue.length() > 0)
m_close = closeValue[0];

AtomicString separators = fenced->getAttribute(MathMLNames::separatorsAttr);
AtomicString separators = fenced.getAttribute(MathMLNames::separatorsAttr);
if (!separators.isNull()) {
StringBuilder characters;
for (unsigned int i = 0; i < separators.length(); i++) {
@@ -89,7 +89,7 @@ RenderMathMLOperator* RenderMathMLFenced::createMathMLOperator(UChar uChar, Rend
newStyle->setMarginEnd(Length((operatorType == RenderMathMLOperator::Fence ? gFenceMarginEms : gSeparatorMarginEndEms) * style()->fontSize(), Fixed));
if (operatorType == RenderMathMLOperator::Fence)
newStyle->setMarginStart(Length(gFenceMarginEms * style()->fontSize(), Fixed));
RenderMathMLOperator* newOperator = new RenderMathMLOperator(*element(), uChar);
RenderMathMLOperator* newOperator = new RenderMathMLOperator(element(), uChar);
newOperator->setOperatorType(operatorType);
newOperator->setStyle(newStyle.release());
return newOperator;
@@ -159,15 +159,13 @@ void RenderMathMLFenced::styleDidChange(StyleDifference diff, const RenderStyle*
RenderMathMLBlock::styleDidChange(diff, oldStyle);

for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
if (child->node() == element()) {
if (child->node() == &element()) {
ASSERT(child->style()->refCount() == 1);
child->style()->inheritFrom(style());
bool isFence = child == firstChild() || child == lastChild();
child->style()->setMarginEnd(Length((isFence ? gFenceMarginEms : gSeparatorMarginEndEms) * style()->fontSize(), Fixed));
if (isFence) {
ASSERT(child->isRenderMathMLBlock());
RenderMathMLBlock* block = toRenderMathMLBlock(child);
ASSERT(block->isRenderMathMLOperator());
toRenderMathMLOperator(block)->updateFromElement();
child->style()->setMarginStart(Length(gFenceMarginEms * style()->fontSize(), Fixed));
}
@@ -28,25 +28,27 @@

#if ENABLE(MATHML)

#include "MathMLInlineContainerElement.h"
#include "RenderMathMLOperator.h"
#include "RenderMathMLRow.h"

namespace WebCore {

class RenderMathMLFenced : public RenderMathMLRow {
class RenderMathMLFenced FINAL : public RenderMathMLRow {
public:
explicit RenderMathMLFenced(Element&);
virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
virtual void updateFromElement();
explicit RenderMathMLFenced(MathMLInlineContainerElement&);
MathMLInlineContainerElement& element() { return static_cast<MathMLInlineContainerElement&>(nodeForNonAnonymous()); }

private:
virtual bool isRenderMathMLFenced() const { return true; }
virtual const char* renderName() const { return "RenderMathMLFenced"; }
virtual bool isRenderMathMLFenced() const OVERRIDE { return true; }
virtual const char* renderName() const OVERRIDE { return "RenderMathMLFenced"; }
virtual void addChild(RenderObject* child, RenderObject* beforeChild) OVERRIDE;
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;

virtual void updateFromElement() OVERRIDE;

RenderMathMLOperator* createMathMLOperator(UChar, RenderMathMLOperator::OperatorType);
void makeFences();

virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;

UChar m_open;
UChar m_close;

0 comments on commit a00a980

Please sign in to comment.