Changeset 89273 in webkit


Ignore:
Timestamp:
Jun 20, 2011 12:35:50 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-06-20 Alex Milowski <alex@milowski.com>

Reviewed by Darin Adler.

New tests for scripting changes to DOM for msub, msup, msubsup.
https://bugs.webkit.org/show_bug.cgi?id=62098

  • mathml/presentation/msub-base-changed.xhtml: Added.
  • mathml/presentation/msub-sub-changed.xhtml: Added.
  • mathml/presentation/msubsup-base-changed.xhtml: Added.
  • mathml/presentation/msubsup-sub-changed.xhtml: Added.
  • mathml/presentation/msubsup-sup-changed.xhtml: Added.
  • mathml/presentation/msup-base-changed.xhtml: Added.
  • mathml/presentation/msup-sup-changed.xhtml: Added.
  • platform/mac/mathml/presentation/msub-base-changed-expected.png: Added.
  • platform/mac/mathml/presentation/msub-base-changed-expected.txt: Added.
  • platform/mac/mathml/presentation/msub-sub-changed-expected.png: Added.
  • platform/mac/mathml/presentation/msub-sub-changed-expected.txt: Added.
  • platform/mac/mathml/presentation/msubsup-base-changed-expected.png: Added.
  • platform/mac/mathml/presentation/msubsup-base-changed-expected.txt: Added.
  • platform/mac/mathml/presentation/msubsup-sub-changed-expected.png: Added.
  • platform/mac/mathml/presentation/msubsup-sub-changed-expected.txt: Added.
  • platform/mac/mathml/presentation/msubsup-sup-changed-expected.png: Added.
  • platform/mac/mathml/presentation/msubsup-sup-changed-expected.txt: Added.
  • platform/mac/mathml/presentation/msup-base-changed-expected.png: Added.
  • platform/mac/mathml/presentation/msup-base-changed-expected.txt: Added.
  • platform/mac/mathml/presentation/msup-sup-changed-expected.png: Added.
  • platform/mac/mathml/presentation/msup-sup-changed-expected.txt: Added.

2011-06-20 Alex Milowski <alex@milowski.com>

Reviewed by Darin Adler.

This patch addresses handling wrapping of child properly to maintain the layout regardless of whether
this is the initial build of the render tree or the result of DOM manipulation.
https://bugs.webkit.org/show_bug.cgi?id=62098

Tests: mathml/presentation/msub-base-changed.xhtml

mathml/presentation/msub-sub-changed.xhtml
mathml/presentation/msubsup-base-changed.xhtml
mathml/presentation/msubsup-sub-changed.xhtml
mathml/presentation/msubsup-sup-changed.xhtml
mathml/presentation/msup-base-changed.xhtml
mathml/presentation/msup-sup-changed.xhtml

  • rendering/mathml/RenderMathMLSubSup.cpp: (WebCore::RenderMathMLSubSup::addChild): (WebCore::RenderMathMLSubSup::stretchToHeight): (WebCore::RenderMathMLSubSup::baselinePosition):
Location:
trunk
Files:
21 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r89270 r89273  
     12011-06-20  Alex Milowski  <alex@milowski.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        New tests for scripting changes to DOM for msub, msup, msubsup.
     6        https://bugs.webkit.org/show_bug.cgi?id=62098
     7
     8        * mathml/presentation/msub-base-changed.xhtml: Added.
     9        * mathml/presentation/msub-sub-changed.xhtml: Added.
     10        * mathml/presentation/msubsup-base-changed.xhtml: Added.
     11        * mathml/presentation/msubsup-sub-changed.xhtml: Added.
     12        * mathml/presentation/msubsup-sup-changed.xhtml: Added.
     13        * mathml/presentation/msup-base-changed.xhtml: Added.
     14        * mathml/presentation/msup-sup-changed.xhtml: Added.
     15        * platform/mac/mathml/presentation/msub-base-changed-expected.png: Added.
     16        * platform/mac/mathml/presentation/msub-base-changed-expected.txt: Added.
     17        * platform/mac/mathml/presentation/msub-sub-changed-expected.png: Added.
     18        * platform/mac/mathml/presentation/msub-sub-changed-expected.txt: Added.
     19        * platform/mac/mathml/presentation/msubsup-base-changed-expected.png: Added.
     20        * platform/mac/mathml/presentation/msubsup-base-changed-expected.txt: Added.
     21        * platform/mac/mathml/presentation/msubsup-sub-changed-expected.png: Added.
     22        * platform/mac/mathml/presentation/msubsup-sub-changed-expected.txt: Added.
     23        * platform/mac/mathml/presentation/msubsup-sup-changed-expected.png: Added.
     24        * platform/mac/mathml/presentation/msubsup-sup-changed-expected.txt: Added.
     25        * platform/mac/mathml/presentation/msup-base-changed-expected.png: Added.
     26        * platform/mac/mathml/presentation/msup-base-changed-expected.txt: Added.
     27        * platform/mac/mathml/presentation/msup-sup-changed-expected.png: Added.
     28        * platform/mac/mathml/presentation/msup-sup-changed-expected.txt: Added.
     29
    1302011-06-20  Chang Shu  <cshu@webkit.org>
    231
  • trunk/Source/WebCore/ChangeLog

    r89271 r89273  
     12011-06-20  Alex Milowski  <alex@milowski.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        This patch addresses handling wrapping of child properly to maintain the layout regardless of whether
     6        this is the initial build of the render tree or the result of DOM manipulation.
     7        https://bugs.webkit.org/show_bug.cgi?id=62098
     8
     9        Tests: mathml/presentation/msub-base-changed.xhtml
     10               mathml/presentation/msub-sub-changed.xhtml
     11               mathml/presentation/msubsup-base-changed.xhtml
     12               mathml/presentation/msubsup-sub-changed.xhtml
     13               mathml/presentation/msubsup-sup-changed.xhtml
     14               mathml/presentation/msup-base-changed.xhtml
     15               mathml/presentation/msup-sup-changed.xhtml
     16
     17        * rendering/mathml/RenderMathMLSubSup.cpp:
     18        (WebCore::RenderMathMLSubSup::addChild):
     19        (WebCore::RenderMathMLSubSup::stretchToHeight):
     20        (WebCore::RenderMathMLSubSup::baselinePosition):
     21
    1222011-06-01  Jer Noble  <jer.noble@apple.com>
    223
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLSubSup.cpp

    r88730 r89273  
    6464void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild)
    6565{
    66     if (firstChild()) {
    67         // We already have a base, so this is the super/subscripts being added.
    68        
    69         if (m_kind == SubSup) {
    70             if (!m_scripts) {
    71                 m_scripts = new (renderArena()) RenderMathMLBlock(node());
    72                 RefPtr<RenderStyle> scriptsStyle = RenderStyle::create();
    73                 scriptsStyle->inheritFrom(style());
    74                 scriptsStyle->setDisplay(INLINE_BLOCK);
    75                 scriptsStyle->setVerticalAlign(TOP);
    76                 scriptsStyle->setMarginLeft(Length(gSubsupScriptMargin, Fixed));
    77                 scriptsStyle->setTextAlign(LEFT);
    78                 m_scripts->setStyle(scriptsStyle.release());
    79                 RenderMathMLBlock::addChild(m_scripts, beforeChild);
    80             }
    81            
    82             RenderBlock* script = new (renderArena()) RenderMathMLBlock(node());
    83             RefPtr<RenderStyle> scriptStyle = RenderStyle::create();
    84             scriptStyle->inheritFrom(m_scripts->style());
    85             scriptStyle->setDisplay(BLOCK);
    86             script->setStyle(scriptStyle.release());
    87            
    88             m_scripts->addChild(script, m_scripts->firstChild());
    89             script->addChild(child);
    90         } else
    91             RenderMathMLBlock::addChild(child, beforeChild);
    92        
    93     } else {
     66   
     67    // Note: The RenderMathMLBlock only allows element children to be added.
     68    Element* childElement = toElement(child->node());
     69
     70    if (!childElement->previousElementSibling()) {
     71        // Position 1 is always the base of the msub/msup/msubsup.
    9472        RenderMathMLBlock* wrapper = new (renderArena()) RenderMathMLBlock(node());
    9573        RefPtr<RenderStyle> wrapperStyle = RenderStyle::create();
     
    9876        wrapperStyle->setVerticalAlign(BASELINE);
    9977        wrapper->setStyle(wrapperStyle.release());
    100         RenderMathMLBlock::addChild(wrapper, beforeChild);
     78        RenderMathMLBlock::addChild(wrapper, firstChild());
    10179        wrapper->addChild(child);
    102        
     80           
     81        // Make sure we have a script block for rendering.
     82        if (m_kind == SubSup && !m_scripts) {
     83            m_scripts = new (renderArena()) RenderMathMLBlock(node());
     84            RefPtr<RenderStyle> scriptsStyle = RenderStyle::create();
     85            scriptsStyle->inheritFrom(style());
     86            scriptsStyle->setDisplay(INLINE_BLOCK);
     87            scriptsStyle->setVerticalAlign(TOP);
     88            scriptsStyle->setMarginLeft(Length(gSubsupScriptMargin, Fixed));
     89            scriptsStyle->setTextAlign(LEFT);
     90            m_scripts->setStyle(scriptsStyle.release());
     91            RenderMathMLBlock::addChild(m_scripts, beforeChild);
     92        }
     93    } else {
     94        if (m_kind == SubSup) {
     95            RenderBlock* script = new (renderArena()) RenderMathMLBlock(node());
     96            RefPtr<RenderStyle> scriptStyle = RenderStyle::create();
     97            scriptStyle->inheritFrom(m_scripts->style());
     98            scriptStyle->setDisplay(BLOCK);
     99            script->setStyle(scriptStyle.release());
     100
     101            // The order is always backwards so the first script is the subscript and the superscript
     102            // is last. That means the superscript is the first to render vertically.
     103            Element* previousSibling = childElement->previousElementSibling();
     104            if (previousSibling && !previousSibling->previousElementSibling())
     105                m_scripts->addChild(script);
     106            else                 
     107                m_scripts->addChild(script, m_scripts->firstChild());
     108           
     109            script->addChild(child);
     110        } else
     111            RenderMathMLBlock::addChild(child, beforeChild);
    103112    }
    104113}
     
    186195    case SubSup:
    187196        base = base->firstChild();
    188         if (!base)
    189             break;
    190 
    191         if (m_scripts && base->isBoxModelObject()) {
     197        if (m_scripts && base && base->isBoxModelObject()) {
    192198            RenderBoxModelObject* box = toRenderBoxModelObject(base);
    193199           
    194200            int topAdjust = (m_scripts->offsetHeight() - box->offsetHeight()) / 2;
    195201       
    196             // FIXME: The last bit of this calculation should be more exact.  Why is the 2-3px scaled for zoom necessary?
     202            // FIXME: The last bit of this calculation should be more exact. Why is the 2-3px scaled for zoom necessary?
    197203            // The baseline is top spacing of the base + the baseline of the base + adjusted space for zoom
    198204            float zoomFactor = style()->effectiveZoom();
Note: See TracChangeset for help on using the changeset viewer.