[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 02:05:55 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit ba875881cdd15699d0c260614fec41277f02e458
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Mar 2 00:22:13 2010 +0000

    2010-03-01  Alex Milowski  <alex at milowski.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            Added test for basic msubsup support.
    
            * mathml/presentation/subsup.xhtml: Added.
            * platform/mac/mathml/presentation/subsup-expected.checksum: Added.
            * platform/mac/mathml/presentation/subsup-expected.png: Added.
            * platform/mac/mathml/presentation/subsup-expected.txt: Added.
    2010-03-01  Alex Milowski  <alex at milowski.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            Added support for the msubsup element that also handles the msup and msub elements.
    
            Test: mathml/presentation/subsup.xhtml
    
            * WebCore.xcodeproj/project.pbxproj:
            * mathml/MathMLInlineContainerElement.cpp:
            (WebCore::MathMLInlineContainerElement::createRenderer):
            * mathml/RenderMathMLSubSup.cpp: Added.
            (WebCore::RenderMathMLSubSup::RenderMathMLSubSup):
            (WebCore::RenderMathMLSubSup::addChild):
            (WebCore::RenderMathMLSubSup::stretchToHeight):
            (WebCore::RenderMathMLSubSup::nonOperatorHeight):
            (WebCore::RenderMathMLSubSup::layout):
            (WebCore::RenderMathMLSubSup::baselinePosition):
            * mathml/RenderMathMLSubSup.h: Added.
            (WebCore::RenderMathMLSubSup::hasBase):
            (WebCore::RenderMathMLSubSup::):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55386 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 95f5989..c4af624 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2010-03-01  Alex Milowski  <alex at milowski.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added test for basic msubsup support.
+
+        * mathml/presentation/subsup.xhtml: Added.
+        * platform/mac/mathml/presentation/subsup-expected.checksum: Added.
+        * platform/mac/mathml/presentation/subsup-expected.png: Added.
+        * platform/mac/mathml/presentation/subsup-expected.txt: Added.
+
 2010-03-01  Thatcher Ulrich  <tulrich at google.com>
 
         Reviewed by Darin Fisher.
diff --git a/LayoutTests/mathml/presentation/subsup.xhtml b/LayoutTests/mathml/presentation/subsup.xhtml
new file mode 100644
index 0000000..b9954f8
--- /dev/null
+++ b/LayoutTests/mathml/presentation/subsup.xhtml
@@ -0,0 +1,39 @@
+<html xmlns='http://www.w3.org/1999/xhtml'>
+<head>
+<title>Subscript and Superscripts</title>
+</head>
+<body>
+<p id='t1'>both: 
+<math xmlns='http://www.w3.org/1998/Math/MathML'>
+<msubsup><mi>x</mi><mn>1</mn><mi>k</mi></msubsup>
+</math>
+</p>
+<p id='t2'>long subscript w/ both: 
+<math xmlns='http://www.w3.org/1998/Math/MathML'>
+<msubsup>
+<mi>Z</mi>
+<mrow><mi>x</mi><mo>+</mo><mi>y</mi><mo>+</mo><mi>z</mi></mrow>
+<mi>j</mi>
+</msubsup>
+</math>
+</p>
+<p id='t3'>long superscript w/ both: 
+<math xmlns='http://www.w3.org/1998/Math/MathML'>
+<msubsup>
+<mi>Z</mi>
+<mi>x</mi>
+<mrow><mi>k</mi><mo>+</mo><mi>j</mi></mrow>
+</msubsup>
+</math>
+</p>
+<p id='t4'>long w/ both: 
+<math xmlns='http://www.w3.org/1998/Math/MathML'>
+<msubsup>
+<mi>Z</mi>
+<mrow><mi>x</mi><mo>+</mo><mi>y</mi><mo>+</mo><mi>z</mi></mrow>
+<mrow><mi>k</mi><mo>+</mo><mi>j</mi></mrow>
+</msubsup>
+</math>
+</p>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/mathml/presentation/sub-expected.checksum b/LayoutTests/platform/mac/mathml/presentation/sub-expected.checksum
index 84a29cb..9ba9582 100644
--- a/LayoutTests/platform/mac/mathml/presentation/sub-expected.checksum
+++ b/LayoutTests/platform/mac/mathml/presentation/sub-expected.checksum
@@ -1 +1 @@
-86ca442a628788281b851fcf581c6abe
\ No newline at end of file
+e43f7c2c817b3102010bfa84e4bbb771
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/mathml/presentation/sub-expected.png b/LayoutTests/platform/mac/mathml/presentation/sub-expected.png
index 3580343..de53236 100644
Binary files a/LayoutTests/platform/mac/mathml/presentation/sub-expected.png and b/LayoutTests/platform/mac/mathml/presentation/sub-expected.png differ
diff --git a/LayoutTests/platform/mac/mathml/presentation/subsup-expected.checksum b/LayoutTests/platform/mac/mathml/presentation/subsup-expected.checksum
new file mode 100644
index 0000000..78c1705
--- /dev/null
+++ b/LayoutTests/platform/mac/mathml/presentation/subsup-expected.checksum
@@ -0,0 +1 @@
+4b8120a66ff233631ec61226a4f14393
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/mathml/presentation/subsup-expected.png b/LayoutTests/platform/mac/mathml/presentation/subsup-expected.png
new file mode 100644
index 0000000..77f9854
Binary files /dev/null and b/LayoutTests/platform/mac/mathml/presentation/subsup-expected.png differ
diff --git a/LayoutTests/platform/mac/mathml/presentation/subsup-expected.txt b/LayoutTests/platform/mac/mathml/presentation/subsup-expected.txt
new file mode 100644
index 0000000..eb32e81
--- /dev/null
+++ b/LayoutTests/platform/mac/mathml/presentation/subsup-expected.txt
@@ -0,0 +1,121 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x224
+  RenderBlock {html} at (0,0) size 800x224
+    RenderBody {body} at (8,16) size 784x192
+      RenderBlock {p} at (0,0) size 784x36
+        RenderText {#text} at (0,9) size 36x18
+          text run at (0,9) width 36: "both: "
+        RenderBlock {math} at (36,0) size 15x36
+          RenderBlock {msubsup} at (0,0) size 15x36
+            RenderBlock {msubsup} at (0,12) size 7x17
+              RenderInline {mi} at (0,0) size 7x16
+                RenderText {#text} at (0,1) size 7x16
+                  text run at (0,1) width 7: "x"
+            RenderBlock {msubsup} at (8,4) size 6x32
+              RenderBlock {msubsup} at (0,0) size 6x16
+                RenderInline {mi} at (0,0) size 5x12
+                  RenderText {#text} at (0,3) size 5x12
+                    text run at (0,3) width 5: "k"
+              RenderBlock {msubsup} at (0,16) size 6x16
+                RenderInline {mn} at (0,0) size 6x12
+                  RenderText {#text} at (0,3) size 6x12
+                    text run at (0,3) width 6: "1"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {p} at (0,52) size 784x36
+        RenderText {#text} at (0,9) size 148x18
+          text run at (0,9) width 148: "long subscript w/ both: "
+        RenderBlock {math} at (148,0) size 41x36
+          RenderBlock {msubsup} at (0,0) size 41x36
+            RenderBlock {msubsup} at (0,12) size 9x17
+              RenderInline {mi} at (0,0) size 9x16
+                RenderText {#text} at (0,1) size 9x16
+                  text run at (0,1) width 9: "Z"
+            RenderBlock {msubsup} at (10,4) size 30x32
+              RenderBlock {msubsup} at (0,0) size 30x16
+                RenderInline {mi} at (0,0) size 3x12
+                  RenderText {#text} at (0,3) size 3x12
+                    text run at (0,3) width 3: "j"
+              RenderBlock {msubsup} at (0,16) size 30x16
+                RenderBlock {mrow} at (1,2) size 29x13
+                  RenderInline {mi} at (0,0) size 5x12
+                    RenderText {#text} at (0,1) size 5x12
+                      text run at (0,1) width 5: "x"
+                  RenderBlock {mo} at (5,1) size 7x12
+                    RenderText {#text} at (0,0) size 7x12
+                      text run at (0,0) width 7: "+"
+                  RenderInline {mi} at (0,0) size 5x12
+                    RenderText {#text} at (12,1) size 5x12
+                      text run at (12,1) width 5: "y"
+                  RenderBlock {mo} at (17,1) size 7x12
+                    RenderText {#text} at (0,0) size 7x12
+                      text run at (0,0) width 7: "+"
+                  RenderInline {mi} at (0,0) size 5x12
+                    RenderText {#text} at (24,1) size 5x12
+                      text run at (24,1) width 5: "z"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {p} at (0,104) size 784x36
+        RenderText {#text} at (0,9) size 160x18
+          text run at (0,9) width 160: "long superscript w/ both: "
+        RenderBlock {math} at (160,0) size 27x36
+          RenderBlock {msubsup} at (0,0) size 27x36
+            RenderBlock {msubsup} at (0,12) size 9x17
+              RenderInline {mi} at (0,0) size 9x16
+                RenderText {#text} at (0,1) size 9x16
+                  text run at (0,1) width 9: "Z"
+            RenderBlock {msubsup} at (10,4) size 16x32
+              RenderBlock {msubsup} at (0,0) size 16x16
+                RenderBlock {mrow} at (1,2) size 15x13
+                  RenderInline {mi} at (0,0) size 5x12
+                    RenderText {#text} at (0,1) size 5x12
+                      text run at (0,1) width 5: "k"
+                  RenderBlock {mo} at (5,1) size 7x12
+                    RenderText {#text} at (0,0) size 7x12
+                      text run at (0,0) width 7: "+"
+                  RenderInline {mi} at (0,0) size 3x12
+                    RenderText {#text} at (12,1) size 3x12
+                      text run at (12,1) width 3: "j"
+              RenderBlock {msubsup} at (0,16) size 16x16
+                RenderInline {mi} at (0,0) size 5x12
+                  RenderText {#text} at (0,3) size 5x12
+                    text run at (0,3) width 5: "x"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {p} at (0,156) size 784x36
+        RenderText {#text} at (0,9) size 88x18
+          text run at (0,9) width 88: "long w/ both: "
+        RenderBlock {math} at (88,0) size 41x36
+          RenderBlock {msubsup} at (0,0) size 41x36
+            RenderBlock {msubsup} at (0,12) size 9x17
+              RenderInline {mi} at (0,0) size 9x16
+                RenderText {#text} at (0,1) size 9x16
+                  text run at (0,1) width 9: "Z"
+            RenderBlock {msubsup} at (10,4) size 30x32
+              RenderBlock {msubsup} at (0,0) size 30x16
+                RenderBlock {mrow} at (1,2) size 15x13
+                  RenderInline {mi} at (0,0) size 5x12
+                    RenderText {#text} at (0,1) size 5x12
+                      text run at (0,1) width 5: "k"
+                  RenderBlock {mo} at (5,1) size 7x12
+                    RenderText {#text} at (0,0) size 7x12
+                      text run at (0,0) width 7: "+"
+                  RenderInline {mi} at (0,0) size 3x12
+                    RenderText {#text} at (12,1) size 3x12
+                      text run at (12,1) width 3: "j"
+              RenderBlock {msubsup} at (0,16) size 30x16
+                RenderBlock {mrow} at (1,2) size 29x13
+                  RenderInline {mi} at (0,0) size 5x12
+                    RenderText {#text} at (0,1) size 5x12
+                      text run at (0,1) width 5: "x"
+                  RenderBlock {mo} at (5,1) size 7x12
+                    RenderText {#text} at (0,0) size 7x12
+                      text run at (0,0) width 7: "+"
+                  RenderInline {mi} at (0,0) size 5x12
+                    RenderText {#text} at (12,1) size 5x12
+                      text run at (12,1) width 5: "y"
+                  RenderBlock {mo} at (17,1) size 7x12
+                    RenderText {#text} at (0,0) size 7x12
+                      text run at (0,0) width 7: "+"
+                  RenderInline {mi} at (0,0) size 5x12
+                    RenderText {#text} at (24,1) size 5x12
+                      text run at (24,1) width 5: "z"
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/platform/mac/mathml/presentation/sup-expected.checksum b/LayoutTests/platform/mac/mathml/presentation/sup-expected.checksum
index 707e972..d6e4b1b 100644
--- a/LayoutTests/platform/mac/mathml/presentation/sup-expected.checksum
+++ b/LayoutTests/platform/mac/mathml/presentation/sup-expected.checksum
@@ -1 +1 @@
-702e3992b12242981f2a6ecd54df28b3
\ No newline at end of file
+3cb060a09cc106603e87617b82aa4e27
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/mathml/presentation/sup-expected.png b/LayoutTests/platform/mac/mathml/presentation/sup-expected.png
index 0466003..c11057c 100644
Binary files a/LayoutTests/platform/mac/mathml/presentation/sup-expected.png and b/LayoutTests/platform/mac/mathml/presentation/sup-expected.png differ
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e98d412..756a760 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-03-01  Alex Milowski  <alex at milowski.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added support for the msubsup element that also handles the msup and msub elements.
+
+        Test: mathml/presentation/subsup.xhtml
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * mathml/MathMLInlineContainerElement.cpp:
+        (WebCore::MathMLInlineContainerElement::createRenderer):
+        * mathml/RenderMathMLSubSup.cpp: Added.
+        (WebCore::RenderMathMLSubSup::RenderMathMLSubSup):
+        (WebCore::RenderMathMLSubSup::addChild):
+        (WebCore::RenderMathMLSubSup::stretchToHeight):
+        (WebCore::RenderMathMLSubSup::nonOperatorHeight):
+        (WebCore::RenderMathMLSubSup::layout):
+        (WebCore::RenderMathMLSubSup::baselinePosition):
+        * mathml/RenderMathMLSubSup.h: Added.
+        (WebCore::RenderMathMLSubSup::hasBase):
+        (WebCore::RenderMathMLSubSup::):
+
 2010-03-01  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index d70e6d6..19e9ce5 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4866,6 +4866,8 @@
 		FABE72F91059C1EB00D999DD /* MathMLMathElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FABE72F21059C1EB00D999DD /* MathMLMathElement.h */; };
 		FABE72FD1059C21100D999DD /* MathMLElementFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72FB1059C21100D999DD /* MathMLElementFactory.cpp */; };
 		FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72FC1059C21100D999DD /* MathMLNames.cpp */; };
+		FAC12CC41120DA6900DACC36 /* RenderMathMLSubSup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAC12CC21120DA6900DACC36 /* RenderMathMLSubSup.cpp */; };
+		FAC12CC51120DA6900DACC36 /* RenderMathMLSubSup.h in Headers */ = {isa = PBXBuildFile; fileRef = FAC12CC31120DA6900DACC36 /* RenderMathMLSubSup.h */; };
 		FE6FD4880F676E5700092873 /* Coordinates.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6FD4850F676E5700092873 /* Coordinates.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FE6FD48D0F676E9300092873 /* JSCoordinates.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE6FD48B0F676E9300092873 /* JSCoordinates.cpp */; };
 		FE6FD48E0F676E9300092873 /* JSCoordinates.h in Headers */ = {isa = PBXBuildFile; fileRef = FE6FD48C0F676E9300092873 /* JSCoordinates.h */; };
@@ -10202,6 +10204,8 @@
 		FABE72F31059C1EB00D999DD /* mathtags.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mathtags.in; sourceTree = "<group>"; };
 		FABE72FB1059C21100D999DD /* MathMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLElementFactory.cpp; sourceTree = "<group>"; };
 		FABE72FC1059C21100D999DD /* MathMLNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLNames.cpp; sourceTree = "<group>"; };
+		FAC12CC21120DA6900DACC36 /* RenderMathMLSubSup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMathMLSubSup.cpp; sourceTree = "<group>"; };
+		FAC12CC31120DA6900DACC36 /* RenderMathMLSubSup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLSubSup.h; sourceTree = "<group>"; };
 		FE136AE710643BE50078CF6D /* WebCore.OrientationEvents.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; path = WebCore.OrientationEvents.exp; sourceTree = "<group>"; };
 		FE49BD301061719100D0E1AE /* WebCore.Inspector.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; path = WebCore.Inspector.exp; sourceTree = "<group>"; };
 		FE49EF970DC51462004266E1 /* DashboardSupportCSSPropertyNames.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DashboardSupportCSSPropertyNames.in; sourceTree = "<group>"; };
@@ -16096,6 +16100,8 @@
 				FABE72F31059C1EB00D999DD /* mathtags.in */,
 				FA654A6D1108ABFF002615E0 /* RenderMathMLBlock.cpp */,
 				FA654A6E1108ABFF002615E0 /* RenderMathMLBlock.h */,
+				FAC12CC21120DA6900DACC36 /* RenderMathMLSubSup.cpp */,
+				FAC12CC31120DA6900DACC36 /* RenderMathMLSubSup.h */,
 				FA7EFB031120D25400CF79C7 /* RenderMathMLUnderOver.cpp */,
 				FA7EFB041120D25400CF79C7 /* RenderMathMLUnderOver.h */,
 			);
@@ -18568,6 +18574,7 @@
 				B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */,
 				9F72304F11184B4100AD0126 /* ScriptProfile.h in Headers */,
 				9F72305111184B4100AD0126 /* ScriptProfiler.h in Headers */,
+				FAC12CC51120DA6900DACC36 /* RenderMathMLSubSup.h in Headers */,
 				FA7EFB061120D25400CF79C7 /* RenderMathMLUnderOver.h in Headers */,
 				BCE789161120D6080060ECE5 /* InlineIterator.h in Headers */,
 				BCE789861120E7A60060ECE5 /* BidiRun.h in Headers */,
@@ -20758,6 +20765,7 @@
 				84D0C4041115F1D40018AA34 /* AffineTransform.cpp in Sources */,
 				B776D43D1104527500BEB0EC /* PrintContext.cpp in Sources */,
 				9F72305011184B4100AD0126 /* ScriptProfiler.cpp in Sources */,
+				FAC12CC41120DA6900DACC36 /* RenderMathMLSubSup.cpp in Sources */,
 				FA7EFB051120D25400CF79C7 /* RenderMathMLUnderOver.cpp in Sources */,
 				BCE7898B1120E8020060ECE5 /* BidiRun.cpp in Sources */,
 				9F6FC1961122E82A00E80196 /* ScriptDebugServer.cpp in Sources */,
diff --git a/WebCore/mathml/MathMLInlineContainerElement.cpp b/WebCore/mathml/MathMLInlineContainerElement.cpp
index b8dbe60..a1e384f 100644
--- a/WebCore/mathml/MathMLInlineContainerElement.cpp
+++ b/WebCore/mathml/MathMLInlineContainerElement.cpp
@@ -31,6 +31,7 @@
 
 #include "MathMLNames.h"
 #include "RenderMathMLBlock.h"
+#include "RenderMathMLSubSup.h"
 #include "RenderMathMLUnderOver.h"
 
 namespace WebCore {
@@ -49,9 +50,14 @@ PassRefPtr<MathMLInlineContainerElement> MathMLInlineContainerElement::create(co
 
 RenderObject* MathMLInlineContainerElement::createRenderer(RenderArena *arena, RenderStyle* style)
 {
-
     RenderObject* object = 0;
-    if (hasLocalName(MathMLNames::moverTag))
+    if (hasLocalName(MathMLNames::msubTag))
+        object = new (arena) RenderMathMLSubSup(this);
+    else if (hasLocalName(MathMLNames::msupTag))
+        object = new (arena) RenderMathMLSubSup(this);
+    else if (hasLocalName(MathMLNames::msubsupTag))
+        object = new (arena) RenderMathMLSubSup(this);
+    else if (hasLocalName(MathMLNames::moverTag))
         object = new (arena) RenderMathMLUnderOver(this);
     else if (hasLocalName(MathMLNames::munderTag))
         object = new (arena) RenderMathMLUnderOver(this);
diff --git a/WebCore/mathml/RenderMathMLBlock.h b/WebCore/mathml/RenderMathMLBlock.h
index e01a325..f05122a 100644
--- a/WebCore/mathml/RenderMathMLBlock.h
+++ b/WebCore/mathml/RenderMathMLBlock.h
@@ -52,6 +52,42 @@ public:
 #endif
     
 protected:
+    int getBoxModelObjectHeight(RenderObject* object) 
+    {
+        if (object && object->isBoxModelObject()) {
+            RenderBoxModelObject* box = toRenderBoxModelObject(object);
+            return box->offsetHeight();
+        }
+        
+        return 0;
+    }
+    int getBoxModelObjectHeight(const RenderObject* object) 
+    {
+        if (object && object->isBoxModelObject()) {
+            const RenderBoxModelObject* box = toRenderBoxModelObject(object);
+            return box->offsetHeight();
+        }
+        
+        return 0;
+    }
+    int getBoxModelObjectWidth(RenderObject* object) 
+    {
+        if (object && object->isBoxModelObject()) {
+            RenderBoxModelObject* box = toRenderBoxModelObject(object);
+            return box->offsetWidth();
+        }
+        
+        return 0;
+    }
+    int getBoxModelObjectWidth(const RenderObject* object) 
+    {
+        if (object && object->isBoxModelObject()) {
+            const RenderBoxModelObject* box = toRenderBoxModelObject(object);
+            return box->offsetWidth();
+        }
+        
+        return 0;
+    }
     virtual PassRefPtr<RenderStyle> makeBlockStyle();
     
 };
@@ -67,7 +103,7 @@ inline const RenderMathMLBlock* toRenderMathMLBlock(const RenderObject* object)
     ASSERT(!object || object->isRenderMathMLBlock());
     return static_cast<const RenderMathMLBlock*>(object);
 }
-    
+
 }
 
 
diff --git a/WebCore/mathml/RenderMathMLSubSup.cpp b/WebCore/mathml/RenderMathMLSubSup.cpp
new file mode 100644
index 0000000..3124ac9
--- /dev/null
+++ b/WebCore/mathml/RenderMathMLSubSup.cpp
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 2010 Alex Milowski (alex at milowski.com). All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(MATHML)
+
+#include "RenderMathMLSubSup.h"
+
+#include "FontSelector.h"
+#include "MathMLNames.h"
+#include "RenderInline.h"
+#include "RenderTable.h"
+#include "RenderTableCell.h"
+#include "RenderTableRow.h"
+#include "RenderTableSection.h"
+#include "RenderText.h"
+
+namespace WebCore {
+    
+using namespace MathMLNames;
+
+static const int gTopAdjustDivisor = 3;
+static const int gSubsupScriptMargin = 1;
+static const float gSubSupStretch = 1.2;
+
+RenderMathMLSubSup::RenderMathMLSubSup(Element* element) 
+    : RenderMathMLBlock(element)
+    , m_scripts(0)
+{
+    // Determine what kind of under/over expression we have by element name
+    if (element->hasLocalName(MathMLNames::msubTag))
+        m_kind = Sub;
+    else if (element->hasLocalName(MathMLNames::msupTag))
+        m_kind = Sup;
+    else if (element->hasLocalName(MathMLNames::msubsupTag))
+        m_kind = SubSup;
+    else 
+        m_kind = SubSup;
+}
+
+void RenderMathMLSubSup::addChild(RenderObject* child, RenderObject* beforeChild)
+{
+    if (firstChild()) {
+        // We already have a base, so this is the super/subscripts being added.
+        
+        if (m_kind == SubSup) {
+            if (!m_scripts) {
+                m_scripts = new (renderArena()) RenderMathMLBlock(node());
+                RefPtr<RenderStyle> scriptsStyle = RenderStyle::create();
+                scriptsStyle->inheritFrom(style());
+                scriptsStyle->setDisplay(INLINE_BLOCK);
+                scriptsStyle->setVerticalAlign(MIDDLE);
+                scriptsStyle->setMarginLeft(Length(gSubsupScriptMargin, Fixed));
+                scriptsStyle->setTextAlign(LEFT);
+                m_scripts->setStyle(scriptsStyle.release());
+                RenderMathMLBlock::addChild(m_scripts, beforeChild);
+            }
+            
+            RenderBlock* script = new (renderArena()) RenderMathMLBlock(node());
+            RefPtr<RenderStyle> scriptStyle = RenderStyle::create();
+            scriptStyle->inheritFrom(m_scripts->style());
+            scriptStyle->setDisplay(BLOCK);
+            script->setStyle(scriptStyle.release());
+            
+            m_scripts->addChild(script, m_scripts->firstChild());
+            script->addChild(child);
+        } else
+            RenderMathMLBlock::addChild(child, beforeChild);
+        
+    } else {
+        RenderMathMLBlock* wrapper = new (renderArena()) RenderMathMLBlock(node());
+        RefPtr<RenderStyle> wrapperStyle = RenderStyle::create();
+        wrapperStyle->inheritFrom(style());
+        wrapperStyle->setDisplay(INLINE_BLOCK);
+        wrapperStyle->setVerticalAlign(MIDDLE);
+        wrapper->setStyle(wrapperStyle.release());
+        RenderMathMLBlock::addChild(wrapper, beforeChild);
+        wrapper->addChild(child);
+    }
+}
+
+void  RenderMathMLSubSup::stretchToHeight(int height)
+{
+    RenderObject* base = firstChild();
+    if (!base)
+        return;
+    
+    if (base->isRenderMathMLBlock()) {
+        RenderMathMLBlock* block = toRenderMathMLBlock(base);
+        block->stretchToHeight(static_cast<int>(gSubSupStretch * height));
+    }
+    if (height > 0 && m_kind == SubSup && m_scripts) {
+        RenderObject* script = m_scripts->firstChild();
+        if (script) {
+            // Calculate the script height without the container margins.
+            RenderObject* top = script;
+            int topHeight = getBoxModelObjectHeight(top->firstChild());
+            int topAdjust = topHeight / gTopAdjustDivisor;
+            top->style()->setMarginTop(Length(-topAdjust, Fixed));
+            top->style()->setMarginBottom(Length(height - topHeight + topAdjust, Fixed));
+            if (top->isBoxModelObject()) {
+                RenderBoxModelObject* topBox = toRenderBoxModelObject(top);
+                topBox->updateBoxModelInfoFromStyle();
+            }
+            m_scripts->setNeedsLayoutAndPrefWidthsRecalc();
+            m_scripts->markContainingBlocksForLayout();
+        }
+    }
+    updateBoxModelInfoFromStyle();
+    setNeedsLayoutAndPrefWidthsRecalc();
+    markContainingBlocksForLayout();
+}
+
+int RenderMathMLSubSup::nonOperatorHeight() const 
+{
+    return 0;
+}
+
+void RenderMathMLSubSup::layout() 
+{
+    RenderBlock::layout();
+    
+    if (m_kind == SubSup) {
+        int width = 0;
+        RenderObject* current = firstChild();
+        while (current) {
+            width += getBoxModelObjectWidth(current);
+            current = current->nextSibling();
+        }
+        width++;
+        // 1 + margin of scripts
+        if (m_scripts) 
+            width += gSubsupScriptMargin;
+        style()->setWidth(Length(width, Fixed));
+
+        setNeedsLayoutAndPrefWidthsRecalc();
+        markContainingBlocksForLayout();
+        RenderBlock::layout();
+    }    
+}
+
+int RenderMathMLSubSup::baselinePosition(bool firstLine, bool isRootLineBox) const
+{
+    RenderObject* base = firstChild();
+    if (!base) 
+        return offsetHeight();
+    base = base->firstChild();
+    if (!base) 
+        return offsetHeight();
+    
+    int baseline = offsetHeight();
+    
+    switch (m_kind) {
+    case SubSup:
+        if (m_scripts) {
+            int topAdjust = 0;
+            if (base->isBoxModelObject()) {
+                RenderBoxModelObject* box = toRenderBoxModelObject(base);
+                topAdjust = (m_scripts->offsetHeight() - box->offsetHeight()) / 2;
+            }
+            return topAdjust + (base ? base->baselinePosition(firstLine, isRootLineBox) : 0) + 4;
+        }
+        break;
+    case Sup:
+        if (base) {
+            baseline = base->baselinePosition(firstLine, isRootLineBox) + 4;
+            // FIXME: The extra amount of the superscript ascending above the base's box
+            // isn't taken into account.  This should be calculated in a more reliable
+            // way.
+            RenderObject* sup = base->nextSibling();
+            if (sup && sup->isBoxModelObject()) {
+                RenderBoxModelObject* box = toRenderBoxModelObject(sup);
+                // we'll take half of the sup's box height into account in the baseline
+                baseline += static_cast<int>(box->offsetHeight() * 0.5);
+            }
+            baseline++;
+        }
+        break;
+    case Sub:
+        if (base) 
+            baseline = base->baselinePosition(true) + 4;
+    }
+    
+    return baseline;
+    
+}
+    
+}    
+
+#endif // ENABLE(MATHML)
diff --git a/WebCore/mathml/RenderMathMLSubSup.h b/WebCore/mathml/RenderMathMLSubSup.h
new file mode 100644
index 0000000..037ef89
--- /dev/null
+++ b/WebCore/mathml/RenderMathMLSubSup.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Alex Milowski (alex at milowski.com). All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef RenderMathMLSubSup_h
+#define RenderMathMLSubSup_h
+
+#if ENABLE(MATHML)
+
+#include "RenderMathMLBlock.h"
+#include "RenderTable.h"
+
+namespace WebCore {
+    
+class RenderMathMLSubSup : public RenderMathMLBlock {
+public:
+    RenderMathMLSubSup(Element* fraction);
+    virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
+    virtual bool hasBase() const { return true; }
+    virtual int nonOperatorHeight() const;
+    virtual void stretchToHeight(int pixelHeight);
+    virtual int baselinePosition(bool, bool) const;    
+
+protected:
+    virtual void layout();
+    
+private:
+    enum SubSupType { Sub, Sup, SubSup };
+    SubSupType m_kind;
+    RenderBlock* m_scripts;
+};
+    
+}
+
+#endif // ENABLE(MATHML)
+
+#endif // RenderMathMLSubSup_h
+

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list