From f2ec9d9ab0b6a748ccd27899a86d97c1a1c98a0b Mon Sep 17 00:00:00 2001 From: Max Li Date: Wed, 4 Apr 2012 20:10:19 -0400 Subject: [PATCH] Bug 735645 - expose sub and sup elements in text attributes, r=surkov --- accessible/src/base/TextAttrs.cpp | 9 +++++++ .../tests/mochitest/attributes/test_text.html | 26 ++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/accessible/src/base/TextAttrs.cpp b/accessible/src/base/TextAttrs.cpp index f4aff5750f65..ea49050ae9ea 100644 --- a/accessible/src/base/TextAttrs.cpp +++ b/accessible/src/base/TextAttrs.cpp @@ -760,5 +760,14 @@ TextAttrsMgr::TextPosTextAttr:: } } + const nsIContent* content = aFrame->GetContent(); + if (content && content->IsHTML()) { + const nsIAtom* tagName = content->Tag(); + if (tagName == nsGkAtoms::sup) + return eTextPosSuper; + if (tagName == nsGkAtoms::sub) + return eTextPosSub; + } + return eTextPosNone; } diff --git a/accessible/tests/mochitest/attributes/test_text.html b/accessible/tests/mochitest/attributes/test_text.html index 2e2b4166de13..d98d1d2a59ee 100644 --- a/accessible/tests/mochitest/attributes/test_text.html +++ b/accessible/tests/mochitest/attributes/test_text.html @@ -142,7 +142,8 @@ testTextAttrs(ID, 11, attrs, defAttrs, 11, 18); ////////////////////////////////////////////////////////////////////////// - // area6 (CSS vertical-align property, bug 445938) + // area6 (CSS vertical-align property, refer to bug 445938 for details + // and sup and sub elements, refer to bug 735645 for details) ID = "area6"; defAttrs = buildDefaultTextAttrs(ID, "12pt"); testDefaultTextAttrs(ID, defAttrs); @@ -150,35 +151,25 @@ attrs = {}; testTextAttrs(ID, 0, attrs, defAttrs, 0, 5); - tempElem = getNode(ID).firstChild.nextSibling; - gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); - attrs = {"text-position": gComputedStyle.verticalAlign, - "font-size": "10pt"}; + attrs = { "text-position": "super", "font-size": "10pt" }; testTextAttrs(ID, 5, attrs, defAttrs, 5, 13); attrs = {}; testTextAttrs(ID, 13, attrs, defAttrs, 13, 27); - tempElem = tempElem.nextSibling.nextSibling; - gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); - attrs = {"text-position": gComputedStyle.verticalAlign}; + attrs = { "text-position": "super" }; testTextAttrs(ID, 27, attrs, defAttrs, 27, 35); attrs = {}; testTextAttrs(ID, 35, attrs, defAttrs, 35, 39); - tempElem = tempElem.nextSibling.nextSibling; - gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); - attrs = {"text-position": gComputedStyle.verticalAlign, - "font-size": "10pt"}; + attrs = { "text-position": "sub", "font-size": "10pt" }; testTextAttrs(ID, 39, attrs, defAttrs, 39, 50); attrs = {}; testTextAttrs(ID, 50, attrs, defAttrs, 50, 55); - tempElem = tempElem.nextSibling.nextSibling; - gComputedStyle = document.defaultView.getComputedStyle(tempElem, ""); - attrs = {"text-position": gComputedStyle.verticalAlign}; + attrs = { "text-position": "sub" }; testTextAttrs(ID, 55, attrs, defAttrs, 55, 64); attrs = {}; @@ -544,6 +535,11 @@ title="expose text-underline-color and text-line-through-color text attributes"> Mozilla Bug 523304 + + Mozilla Bug 735645 +