Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (202960 => 202961)
--- trunk/Source/WebCore/CMakeLists.txt 2016-07-08 05:40:20 UTC (rev 202960)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-07-08 05:51:20 UTC (rev 202961)
@@ -1053,6 +1053,7 @@
accessibility/AccessibilityList.cpp
accessibility/AccessibilityListBox.cpp
accessibility/AccessibilityListBoxOption.cpp
+ accessibility/AccessibilityMathMLElement.cpp
accessibility/AccessibilityMediaControls.cpp
accessibility/AccessibilityMenuList.cpp
accessibility/AccessibilityMenuListOption.cpp
Modified: trunk/Source/WebCore/ChangeLog (202960 => 202961)
--- trunk/Source/WebCore/ChangeLog 2016-07-08 05:40:20 UTC (rev 202960)
+++ trunk/Source/WebCore/ChangeLog 2016-07-08 05:51:20 UTC (rev 202961)
@@ -1,5 +1,125 @@
2016-07-07 Frederic Wang <[email protected]>
+ Move MathML-specific code into a separate accessibility class
+ https://bugs.webkit.org/show_bug.cgi?id=159213
+
+ Reviewed by Chris Fleizach.
+
+ Currently, MathML accessibility is completely handled in the generic AccessibilityRenderObject
+ and it's sometimes messy and unconvenient. Hence we move most of the MathML-specific code
+ into a separate AccessibilityMathMLElement class to facilitate future work and maintenance.
+
+ No new tests, already covered by existing tests.
+
+ * CMakeLists.txt: Add new AccessibilityMathMLElement module.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * accessibility/AccessibilityAllInOne.cpp: Ditto.
+ * accessibility/AXObjectCache.cpp: Add MathML headers and create AccessibilityMathMLElement.
+ (WebCore::createFromRenderer): Create AccessibilityMathMLElement for MathML elements and
+ anonymous operators created by the mfenced element.
+ * accessibility/AccessibilityMathMLElement.cpp: Added. This class handles all the MathML
+ elements as well as the anonymous operators created by the mfenced element. A boolean is
+ passed to the constructor to indicate whether we are in the latter case.
+ (WebCore::AccessibilityMathMLElement::AccessibilityMathMLElement):
+ (WebCore::AccessibilityMathMLElement::~AccessibilityMathMLElement):
+ (WebCore::AccessibilityMathMLElement::create):
+ (WebCore::AccessibilityMathMLElement::determineAccessibilityRole): Move handling of specific
+ MathElementRole and DocumentMathRole here.
+ (WebCore::AccessibilityMathMLElement::textUnderElement): Move retrieval of text from the
+ anonymous operators here.
+ (WebCore::AccessibilityMathMLElement::stringValue): Ditto.
+ (WebCore::AccessibilityMathMLElement::isIgnoredElementWithinMathTree): Move the determination
+ of ignored math elements here.
+ (WebCore::AccessibilityMathMLElement::isMathFraction): Moved from AccessibilityRenderObject.
+ (WebCore::AccessibilityMathMLElement::isMathFenced): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathSubscriptSuperscript): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathRow): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathUnderOver): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathSquareRoot): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathToken): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathRoot): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathOperator): Ditto.
+ (WebCore::AccessibilityMathMLElement::isAnonymousMathOperator): Move the determination of
+ anonymous operators here. We now just return the boolean passed at creation time.
+ (WebCore::AccessibilityMathMLElement::isMathFenceOperator): Moved from
+ AccessibilityRenderObject.
+ (WebCore::AccessibilityMathMLElement::isMathSeparatorOperator): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathText): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathNumber): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathIdentifier): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathMultiscript): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathTable): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathTableRow): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathTableCell): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathScriptObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::isMathMultiscriptObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathRadicandObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathRootIndexObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathNumeratorObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathDenominatorObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathUnderObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathOverObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathBaseObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathSubscriptObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathSuperscriptObject): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathFencedOpenString): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathFencedCloseString): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathPrescripts): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathPostscripts): Ditto.
+ (WebCore::AccessibilityMathMLElement::mathLineThickness): Ditto.
+ * accessibility/AccessibilityMathMLElement.h: Added.
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::AccessibilityRenderObject::isIgnoredElementWithinMathTree): The cases of
+ AccessibilityMathMLElement objects are now handled in the derived class. We remove the case
+ of text node since the MathML code no longer creates anonymous text nodes after r202420.
+ Anonymous block inserted into RenderMathMLBlocks to honor CSS rules are not AccessibilityMathMLElements
+ and it does not seem safe to modify AXObjectCache::createFromRenderer to force that. Hence
+ we still need to be handle them here.
+ (WebCore::AccessibilityRenderObject::textUnderElement): This code is moved into AccessibilityMathMLElement.
+ (WebCore::AccessibilityRenderObject::stringValue): Ditto.
+ (WebCore::AccessibilityRenderObject::determineAccessibilityRole): Ditto.
+ (WebCore::AccessibilityRenderObject::isMathElement): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathFraction): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathFenced): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathSubscriptSuperscript): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathRow): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathUnderOver): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathSquareRoot): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathToken): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathRoot): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathOperator): Deleted.
+ (WebCore::AccessibilityRenderObject::isAnonymousMathOperator): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathFenceOperator): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathSeparatorOperator): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathText): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathNumber): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathIdentifier): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathMultiscript): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathTable): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathTableRow): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathTableCell): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathScriptObject): Deleted.
+ (WebCore::AccessibilityRenderObject::isMathMultiscriptObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathRadicandObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathRootIndexObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathNumeratorObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathDenominatorObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathUnderObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathOverObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathBaseObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathSubscriptObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathSuperscriptObject): Deleted.
+ (WebCore::AccessibilityRenderObject::mathFencedOpenString): Deleted.
+ (WebCore::AccessibilityRenderObject::mathFencedCloseString): Deleted.
+ (WebCore::AccessibilityRenderObject::mathPrescripts): Deleted.
+ (WebCore::AccessibilityRenderObject::mathPostscripts): Deleted.
+ (WebCore::AccessibilityRenderObject::mathLineThickness): Deleted.
+ * accessibility/AccessibilityRenderObject.h: Remove declarations of functions that are now
+ overridden in AccessibilityMathMLElement. Make isIgnoredElementWithinMathTree virtual so that
+ it can be reimplemented in AccessibilityMathMLElement.
+
+2016-07-07 Frederic Wang <[email protected]>
+
Implement an internal style property for displaystyle.
https://bugs.webkit.org/show_bug.cgi?id=133845
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202960 => 202961)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-07-08 05:40:20 UTC (rev 202960)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-07-08 05:51:20 UTC (rev 202961)
@@ -294,6 +294,7 @@
07AC47011952102100EE9723 /* ISOVTTCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07AC46FF1952102100EE9723 /* ISOVTTCue.cpp */; };
07AC47021952102100EE9723 /* ISOVTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AC47001952102100EE9723 /* ISOVTTCue.h */; };
07B0113F1032242200FBDC33 /* AccessibilityMediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */; };
+ 07B0ABCF1032242200FBDC33 /* AccessibilityMathMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 07B0ABCE1032242200FBDC33 /* AccessibilityMathMLElement.h */; };
07B442D6166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07B442D4166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp */; };
07B442D7166C70B000556CAD /* InbandTextTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = 07B442D5166C70B000556CAD /* InbandTextTrackPrivateAVF.h */; settings = {ATTRIBUTES = (Private, ); }; };
07B5A2DB1464320A00A81ECE /* JSTextTrackList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07B5A2D91464320A00A81ECE /* JSTextTrackList.cpp */; };
@@ -1521,6 +1522,7 @@
37F57ABE1A50727E00876F98 /* AccessibilityListBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2981CAA2131822EC00D12F2A /* AccessibilityListBox.cpp */; };
37F57ABF1A50728100876F98 /* AccessibilityListBoxOption.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2981CAA3131822EC00D12F2A /* AccessibilityListBoxOption.cpp */; };
37F57AC01A50728400876F98 /* AccessibilityMediaControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2981CAA4131822EC00D12F2A /* AccessibilityMediaControls.cpp */; };
+ 37F57ABC1A50728400876F98 /* AccessibilityMathMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2981ABC4131822EC00D12F2A /* AccessibilityMathMLElement.cpp */; };
37F57AC11A50728700876F98 /* AccessibilityNodeObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2985709215CC532D006355CD /* AccessibilityNodeObject.cpp */; };
37F57AC21A50728B00876F98 /* AccessibilityObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2981CAA5131822EC00D12F2A /* AccessibilityObject.cpp */; };
37F57AC31A50728F00876F98 /* AccessibilityProgressIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A409C982116D0DDD007197BD /* AccessibilityProgressIndicator.cpp */; };
@@ -7760,6 +7762,7 @@
07AC46FF1952102100EE9723 /* ISOVTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ISOVTTCue.cpp; sourceTree = "<group>"; };
07AC47001952102100EE9723 /* ISOVTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ISOVTTCue.h; sourceTree = "<group>"; };
07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityMediaControls.h; sourceTree = "<group>"; };
+ 07B0ABCE1032242200FBDC33 /* AccessibilityMathMLElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityMathMLElement.h; sourceTree = "<group>"; };
07B442D4166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandTextTrackPrivateAVF.cpp; sourceTree = "<group>"; };
07B442D5166C70B000556CAD /* InbandTextTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrackPrivateAVF.h; sourceTree = "<group>"; };
07B5A2D91464320A00A81ECE /* JSTextTrackList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackList.cpp; sourceTree = "<group>"; };
@@ -8695,6 +8698,7 @@
2981CAA2131822EC00D12F2A /* AccessibilityListBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityListBox.cpp; sourceTree = "<group>"; };
2981CAA3131822EC00D12F2A /* AccessibilityListBoxOption.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityListBoxOption.cpp; sourceTree = "<group>"; };
2981CAA4131822EC00D12F2A /* AccessibilityMediaControls.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityMediaControls.cpp; sourceTree = "<group>"; };
+ 2981ABC4131822EC00D12F2A /* AccessibilityMathMLElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityMathMLElement.cpp; sourceTree = "<group>"; };
2981CAA5131822EC00D12F2A /* AccessibilityObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = AccessibilityObject.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
2981CAA6131822EC00D12F2A /* AccessibilityRenderObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityRenderObject.cpp; sourceTree = "<group>"; };
2981CAA7131822EC00D12F2A /* AccessibilityScrollbar.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityScrollbar.cpp; sourceTree = "<group>"; };
@@ -16718,6 +16722,8 @@
29A812240FBB9C1D00510293 /* AccessibilityListBoxOption.h */,
2981CAA4131822EC00D12F2A /* AccessibilityMediaControls.cpp */,
07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */,
+ 2981ABC4131822EC00D12F2A /* AccessibilityMathMLElement.cpp */,
+ 07B0ABCE1032242200FBDC33 /* AccessibilityMathMLElement.h */,
76CDD2EC1103DA6600680521 /* AccessibilityMenuList.cpp */,
76CDD2ED1103DA6600680521 /* AccessibilityMenuList.h */,
76CDD2F01103DA6600680521 /* AccessibilityMenuListOption.cpp */,
@@ -25289,6 +25295,7 @@
29A812430FBB9C1D00510293 /* AccessibilityListBox.h in Headers */,
29A812420FBB9C1D00510293 /* AccessibilityListBoxOption.h in Headers */,
07B0113F1032242200FBDC33 /* AccessibilityMediaControls.h in Headers */,
+ 07B0ABCF1032242200FBDC33 /* AccessibilityMathMLElement.h in Headers */,
76CDD2F31103DA6600680521 /* AccessibilityMenuList.h in Headers */,
76CDD2F71103DA6600680521 /* AccessibilityMenuListOption.h in Headers */,
76CDD2F51103DA6600680521 /* AccessibilityMenuListPopup.h in Headers */,
@@ -29307,6 +29314,7 @@
37F57ABE1A50727E00876F98 /* AccessibilityListBox.cpp in Sources */,
37F57ABF1A50728100876F98 /* AccessibilityListBoxOption.cpp in Sources */,
37F57AC01A50728400876F98 /* AccessibilityMediaControls.cpp in Sources */,
+ 37F57ABC1A50728400876F98 /* AccessibilityMathMLElement.cpp in Sources */,
76CDD2F21103DA6600680521 /* AccessibilityMenuList.cpp in Sources */,
76CDD2F61103DA6600680521 /* AccessibilityMenuListOption.cpp in Sources */,
76CDD2F41103DA6600680521 /* AccessibilityMenuListPopup.cpp in Sources */,
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (202960 => 202961)
--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2016-07-08 05:40:20 UTC (rev 202960)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2016-07-08 05:51:20 UTC (rev 202961)
@@ -41,6 +41,7 @@
#include "AccessibilityList.h"
#include "AccessibilityListBox.h"
#include "AccessibilityListBoxOption.h"
+#include "AccessibilityMathMLElement.h"
#include "AccessibilityMediaControls.h"
#include "AccessibilityMenuList.h"
#include "AccessibilityMenuListOption.h"
@@ -73,10 +74,12 @@
#include "HTMLMeterElement.h"
#include "HTMLNames.h"
#include "InlineElementBox.h"
+#include "MathMLElement.h"
#include "Page.h"
#include "RenderAttachment.h"
#include "RenderLineBreak.h"
#include "RenderListBox.h"
+#include "RenderMathMLOperator.h"
#include "RenderMenuList.h"
#include "RenderMeter.h"
#include "RenderProgress.h"
@@ -444,6 +447,15 @@
if (is<SVGElement>(node))
return AccessibilitySVGElement::create(renderer);
+#if ENABLE(MATHML)
+ // The mfenced element creates anonymous RenderMathMLOperators which should be treated
+ // as MathML elements and assigned the MathElementRole so that platform logic regarding
+ // inclusion and role mapping is not bypassed.
+ bool isAnonymousOperator = renderer->isAnonymous() && is<RenderMathMLOperator>(*renderer);
+ if (isAnonymousOperator || is<MathMLElement>(node))
+ return AccessibilityMathMLElement::create(renderer, isAnonymousOperator);
+#endif
+
if (is<RenderBoxModelObject>(*renderer)) {
RenderBoxModelObject& cssBox = downcast<RenderBoxModelObject>(*renderer);
if (is<RenderListBox>(cssBox))
Modified: trunk/Source/WebCore/accessibility/AccessibilityAllInOne.cpp (202960 => 202961)
--- trunk/Source/WebCore/accessibility/AccessibilityAllInOne.cpp 2016-07-08 05:40:20 UTC (rev 202960)
+++ trunk/Source/WebCore/accessibility/AccessibilityAllInOne.cpp 2016-07-08 05:51:20 UTC (rev 202961)
@@ -35,6 +35,7 @@
#include "AccessibilityList.cpp"
#include "AccessibilityListBox.cpp"
#include "AccessibilityListBoxOption.cpp"
+#include "AccessibilityMathMLElement.cpp"
#include "AccessibilityMediaControls.cpp"
#include "AccessibilityMenuList.cpp"
#include "AccessibilityMenuListOption.cpp"
Added: trunk/Source/WebCore/accessibility/AccessibilityMathMLElement.cpp (0 => 202961)
--- trunk/Source/WebCore/accessibility/AccessibilityMathMLElement.cpp (rev 0)
+++ trunk/Source/WebCore/accessibility/AccessibilityMathMLElement.cpp 2016-07-08 05:51:20 UTC (rev 202961)
@@ -0,0 +1,456 @@
+/*
+ * Copyright (C) 2016 Igalia, S.L.
+ * 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 "AccessibilityMathMLElement.h"
+
+#include "AXObjectCache.h"
+#include "MathMLNames.h"
+
+namespace WebCore {
+
+AccessibilityMathMLElement::AccessibilityMathMLElement(RenderObject* renderer, bool isAnonymousOperator)
+ : AccessibilityRenderObject(renderer)
+ , m_isAnonymousOperator(isAnonymousOperator)
+{
+}
+
+AccessibilityMathMLElement::~AccessibilityMathMLElement()
+{
+}
+
+Ref<AccessibilityMathMLElement> AccessibilityMathMLElement::create(RenderObject* renderer, bool isAnonymousOperator)
+{
+ return adoptRef(*new AccessibilityMathMLElement(renderer, isAnonymousOperator));
+}
+
+AccessibilityRole AccessibilityMathMLElement::determineAccessibilityRole()
+{
+ if (!m_renderer)
+ return UnknownRole;
+
+ if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole)
+ return m_ariaRole;
+
+ Node* node = m_renderer->node();
+ if (node && node->hasTagName(MathMLNames::mathTag))
+ return DocumentMathRole;
+
+ // It's not clear which role a platform should choose for a math element.
+ // Declaring a math element role should give flexibility to platforms to choose.
+ return MathElementRole;
+}
+
+String AccessibilityMathMLElement::textUnderElement(AccessibilityTextUnderElementMode mode) const
+{
+ if (m_isAnonymousOperator) {
+ UChar operatorChar = downcast<RenderMathMLOperator>(*m_renderer).textContent();
+ return operatorChar ? String(&operatorChar, 1) : String();
+ }
+
+ return AccessibilityRenderObject::textUnderElement(mode);
+}
+
+String AccessibilityMathMLElement::stringValue() const
+{
+ if (m_isAnonymousOperator)
+ return textUnderElement();
+
+ return AccessibilityRenderObject::stringValue();
+}
+
+bool AccessibilityMathMLElement::isIgnoredElementWithinMathTree() const
+{
+ if (m_isAnonymousOperator)
+ return false;
+
+ // Only math elements that we explicitly recognize should be included
+ // We don't want things like <mstyle> to appear in the tree.
+ if (isMathFraction() || isMathFenced() || isMathSubscriptSuperscript() || isMathRow()
+ || isMathUnderOver() || isMathRoot() || isMathText() || isMathNumber()
+ || isMathOperator() || isMathFenceOperator() || isMathSeparatorOperator()
+ || isMathIdentifier() || isMathTable() || isMathTableRow() || isMathTableCell() || isMathMultiscript())
+ return false;
+
+ return true;
+}
+
+bool AccessibilityMathMLElement::isMathFraction() const
+{
+ return m_renderer && m_renderer->isRenderMathMLFraction();
+}
+
+bool AccessibilityMathMLElement::isMathFenced() const
+{
+ return m_renderer && m_renderer->isRenderMathMLFenced();
+}
+
+bool AccessibilityMathMLElement::isMathSubscriptSuperscript() const
+{
+ return m_renderer && m_renderer->isRenderMathMLScripts() && !isMathMultiscript();
+}
+
+bool AccessibilityMathMLElement::isMathRow() const
+{
+ return m_renderer && m_renderer->isRenderMathMLRow() && !isMathRoot();
+}
+
+bool AccessibilityMathMLElement::isMathUnderOver() const
+{
+ return m_renderer && m_renderer->isRenderMathMLUnderOver();
+}
+
+bool AccessibilityMathMLElement::isMathSquareRoot() const
+{
+ return m_renderer && m_renderer->isRenderMathMLSquareRoot();
+}
+
+bool AccessibilityMathMLElement::isMathToken() const
+{
+ return m_renderer && m_renderer->isRenderMathMLToken();
+}
+
+bool AccessibilityMathMLElement::isMathRoot() const
+{
+ return m_renderer && m_renderer->isRenderMathMLRoot();
+}
+
+bool AccessibilityMathMLElement::isMathOperator() const
+{
+ return m_renderer && m_renderer->isRenderMathMLOperator();
+}
+
+bool AccessibilityMathMLElement::isAnonymousMathOperator() const
+{
+ return m_isAnonymousOperator;
+}
+
+bool AccessibilityMathMLElement::isMathFenceOperator() const
+{
+ if (!is<RenderMathMLOperator>(m_renderer))
+ return false;
+
+ return downcast<RenderMathMLOperator>(*m_renderer).hasOperatorFlag(MathMLOperatorDictionary::Fence);
+}
+
+bool AccessibilityMathMLElement::isMathSeparatorOperator() const
+{
+ if (!is<RenderMathMLOperator>(m_renderer))
+ return false;
+
+ return downcast<RenderMathMLOperator>(*m_renderer).hasOperatorFlag(MathMLOperatorDictionary::Separator);
+}
+
+bool AccessibilityMathMLElement::isMathText() const
+{
+ return node() && (node()->hasTagName(MathMLNames::mtextTag) || hasTagName(MathMLNames::msTag));
+}
+
+bool AccessibilityMathMLElement::isMathNumber() const
+{
+ return node() && node()->hasTagName(MathMLNames::mnTag);
+}
+
+bool AccessibilityMathMLElement::isMathIdentifier() const
+{
+ return node() && node()->hasTagName(MathMLNames::miTag);
+}
+
+bool AccessibilityMathMLElement::isMathMultiscript() const
+{
+ return node() && node()->hasTagName(MathMLNames::mmultiscriptsTag);
+}
+
+bool AccessibilityMathMLElement::isMathTable() const
+{
+ return node() && node()->hasTagName(MathMLNames::mtableTag);
+}
+
+bool AccessibilityMathMLElement::isMathTableRow() const
+{
+ return node() && (node()->hasTagName(MathMLNames::mtrTag) || hasTagName(MathMLNames::mlabeledtrTag));
+}
+
+bool AccessibilityMathMLElement::isMathTableCell() const
+{
+ return node() && node()->hasTagName(MathMLNames::mtdTag);
+}
+
+bool AccessibilityMathMLElement::isMathScriptObject(AccessibilityMathScriptObjectType type) const
+{
+ AccessibilityObject* parent = parentObjectUnignored();
+ if (!parent)
+ return false;
+
+ return type == Subscript ? this == parent->mathSubscriptObject() : this == parent->mathSuperscriptObject();
+}
+
+bool AccessibilityMathMLElement::isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType type) const
+{
+ AccessibilityObject* parent = parentObjectUnignored();
+ if (!parent || !parent->isMathMultiscript())
+ return false;
+
+ // The scripts in a MathML <mmultiscripts> element consist of one or more
+ // subscript, superscript pairs. In order to determine if this object is
+ // a scripted token, we need to examine each set of pairs to see if the
+ // this token is present and in the position corresponding with the type.
+
+ AccessibilityMathMultiscriptPairs pairs;
+ if (type == PreSubscript || type == PreSuperscript)
+ parent->mathPrescripts(pairs);
+ else
+ parent->mathPostscripts(pairs);
+
+ for (const auto& pair : pairs) {
+ if (this == pair.first)
+ return (type == PreSubscript || type == PostSubscript);
+ if (this == pair.second)
+ return (type == PreSuperscript || type == PostSuperscript);
+ }
+
+ return false;
+}
+
+AccessibilityObject* AccessibilityMathMLElement::mathRadicandObject()
+{
+ if (!isMathRoot())
+ return nullptr;
+
+ // For MathSquareRoot, we actually return the first child of the base.
+ // See also https://webkit.org/b/146452
+ const auto& children = this->children();
+ if (children.size() < 1)
+ return nullptr;
+
+ return children[0].get();
+}
+
+AccessibilityObject* AccessibilityMathMLElement::mathRootIndexObject()
+{
+ if (!isMathRoot() || isMathSquareRoot())
+ return nullptr;
+
+ const auto& children = this->children();
+ if (children.size() < 2)
+ return nullptr;
+
+ return children[1].get();
+}
+
+AccessibilityObject* AccessibilityMathMLElement::mathNumeratorObject()
+{
+ if (!isMathFraction())
+ return nullptr;
+
+ const auto& children = this->children();
+ if (children.size() != 2)
+ return nullptr;
+
+ return children[0].get();
+}
+
+AccessibilityObject* AccessibilityMathMLElement::mathDenominatorObject()
+{
+ if (!isMathFraction())
+ return nullptr;
+
+ const auto& children = this->children();
+ if (children.size() != 2)
+ return nullptr;
+
+ return children[1].get();
+}
+
+AccessibilityObject* AccessibilityMathMLElement::mathUnderObject()
+{
+ if (!isMathUnderOver() || !node())
+ return nullptr;
+
+ const auto& children = this->children();
+ if (children.size() < 2)
+ return nullptr;
+
+ if (node()->hasTagName(MathMLNames::munderTag) || node()->hasTagName(MathMLNames::munderoverTag))
+ return children[1].get();
+
+ return nullptr;
+}
+
+AccessibilityObject* AccessibilityMathMLElement::mathOverObject()
+{
+ if (!isMathUnderOver() || !node())
+ return nullptr;
+
+ const auto& children = this->children();
+ if (children.size() < 2)
+ return nullptr;
+
+ if (node()->hasTagName(MathMLNames::moverTag))
+ return children[1].get();
+ if (node()->hasTagName(MathMLNames::munderoverTag))
+ return children[2].get();
+
+ return nullptr;
+}
+
+AccessibilityObject* AccessibilityMathMLElement::mathBaseObject()
+{
+ if (!isMathSubscriptSuperscript() && !isMathUnderOver() && !isMathMultiscript())
+ return nullptr;
+
+ const auto& children = this->children();
+ // The base object in question is always the first child.
+ if (children.size() > 0)
+ return children[0].get();
+
+ return nullptr;
+}
+
+AccessibilityObject* AccessibilityMathMLElement::mathSubscriptObject()
+{
+ if (!isMathSubscriptSuperscript() || !node())
+ return nullptr;
+
+ const auto& children = this->children();
+ if (children.size() < 2)
+ return nullptr;
+
+ if (node()->hasTagName(MathMLNames::msubTag) || node()->hasTagName(MathMLNames::msubsupTag))
+ return children[1].get();
+
+ return nullptr;
+}
+
+AccessibilityObject* AccessibilityMathMLElement::mathSuperscriptObject()
+{
+ if (!isMathSubscriptSuperscript() || !node())
+ return nullptr;
+
+ const auto& children = this->children();
+ unsigned count = children.size();
+
+ if (count >= 2 && node()->hasTagName(MathMLNames::msupTag))
+ return children[1].get();
+
+ if (count >= 3 && node()->hasTagName(MathMLNames::msubsupTag))
+ return children[2].get();
+
+ return nullptr;
+}
+
+String AccessibilityMathMLElement::mathFencedOpenString() const
+{
+ if (!isMathFenced())
+ return String();
+
+ return getAttribute(MathMLNames::openAttr);
+}
+
+String AccessibilityMathMLElement::mathFencedCloseString() const
+{
+ if (!isMathFenced())
+ return String();
+
+ return getAttribute(MathMLNames::closeAttr);
+}
+
+void AccessibilityMathMLElement::mathPrescripts(AccessibilityMathMultiscriptPairs& prescripts)
+{
+ if (!isMathMultiscript() || !node())
+ return;
+
+ bool foundPrescript = false;
+ std::pair<AccessibilityObject*, AccessibilityObject*> prescriptPair;
+ for (Node* child = node()->firstChild(); child; child = child->nextSibling()) {
+ if (foundPrescript) {
+ AccessibilityObject* axChild = axObjectCache()->getOrCreate(child);
+ if (axChild && axChild->isMathElement()) {
+ if (!prescriptPair.first)
+ prescriptPair.first = axChild;
+ else {
+ prescriptPair.second = axChild;
+ prescripts.append(prescriptPair);
+ prescriptPair.first = nullptr;
+ prescriptPair.second = nullptr;
+ }
+ }
+ } else if (child->hasTagName(MathMLNames::mprescriptsTag))
+ foundPrescript = true;
+ }
+
+ // Handle the odd number of pre scripts case.
+ if (prescriptPair.first)
+ prescripts.append(prescriptPair);
+}
+
+void AccessibilityMathMLElement::mathPostscripts(AccessibilityMathMultiscriptPairs& postscripts)
+{
+ if (!isMathMultiscript() || !node())
+ return;
+
+ // In Multiscripts, the post-script elements start after the first element (which is the base)
+ // and continue until a <mprescripts> tag is found
+ std::pair<AccessibilityObject*, AccessibilityObject*> postscriptPair;
+ bool foundBaseElement = false;
+ for (Node* child = node()->firstChild(); child; child = child->nextSibling()) {
+ if (child->hasTagName(MathMLNames::mprescriptsTag))
+ break;
+
+ AccessibilityObject* axChild = axObjectCache()->getOrCreate(child);
+ if (axChild && axChild->isMathElement()) {
+ if (!foundBaseElement)
+ foundBaseElement = true;
+ else if (!postscriptPair.first)
+ postscriptPair.first = axChild;
+ else {
+ postscriptPair.second = axChild;
+ postscripts.append(postscriptPair);
+ postscriptPair.first = nullptr;
+ postscriptPair.second = nullptr;
+ }
+ }
+ }
+
+ // Handle the odd number of post scripts case.
+ if (postscriptPair.first)
+ postscripts.append(postscriptPair);
+}
+
+int AccessibilityMathMLElement::mathLineThickness() const
+{
+ if (!is<RenderMathMLFraction>(m_renderer))
+ return -1;
+
+ return downcast<RenderMathMLFraction>(*m_renderer).relativeLineThickness();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MATHML)
Property changes on: trunk/Source/WebCore/accessibility/AccessibilityMathMLElement.cpp
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/Source/WebCore/accessibility/AccessibilityMathMLElement.h (0 => 202961)
--- trunk/Source/WebCore/accessibility/AccessibilityMathMLElement.h (rev 0)
+++ trunk/Source/WebCore/accessibility/AccessibilityMathMLElement.h 2016-07-08 05:51:20 UTC (rev 202961)
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2016 Igalia, S.L.
+ * 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 AccessibilityMathMLElement_h
+#define AccessibilityMathMLElement_h
+
+#if ENABLE(MATHML)
+
+#include "AccessibilityRenderObject.h"
+
+#include "RenderMathMLBlock.h"
+#include "RenderMathMLFraction.h"
+#include "RenderMathMLMath.h"
+#include "RenderMathMLOperator.h"
+#include "RenderMathMLRoot.h"
+
+namespace WebCore {
+
+class AccessibilityMathMLElement : public AccessibilityRenderObject {
+
+public:
+ static Ref<AccessibilityMathMLElement> create(RenderObject*, bool isAnonymousOperator);
+ virtual ~AccessibilityMathMLElement();
+
+protected:
+ explicit AccessibilityMathMLElement(RenderObject*, bool isAnonymousOperator);
+
+private:
+ AccessibilityRole determineAccessibilityRole() final;
+ String textUnderElement(AccessibilityTextUnderElementMode = AccessibilityTextUnderElementMode()) const override;
+ String stringValue() const override;
+ bool isIgnoredElementWithinMathTree() const final;
+
+ bool isMathElement() const final { return true; }
+
+ bool isMathFraction() const override;
+ bool isMathFenced() const override;
+ bool isMathSubscriptSuperscript() const override;
+ bool isMathRow() const override;
+ bool isMathUnderOver() const override;
+ bool isMathRoot() const override;
+ bool isMathSquareRoot() const override;
+ bool isMathText() const override;
+ bool isMathNumber() const override;
+ bool isMathOperator() const override;
+ bool isMathFenceOperator() const override;
+ bool isMathSeparatorOperator() const override;
+ bool isMathIdentifier() const override;
+ bool isMathTable() const override;
+ bool isMathTableRow() const override;
+ bool isMathTableCell() const override;
+ bool isMathMultiscript() const override;
+ bool isMathToken() const override;
+ bool isMathScriptObject(AccessibilityMathScriptObjectType) const override;
+ bool isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType) const override;
+
+ // Generic components.
+ AccessibilityObject* mathBaseObject() override;
+
+ // Root components.
+ AccessibilityObject* mathRadicandObject() override;
+ AccessibilityObject* mathRootIndexObject() override;
+
+ // Fraction components.
+ AccessibilityObject* mathNumeratorObject() override;
+ AccessibilityObject* mathDenominatorObject() override;
+
+ // Under over components.
+ AccessibilityObject* mathUnderObject() override;
+ AccessibilityObject* mathOverObject() override;
+
+ // Subscript/superscript components.
+ AccessibilityObject* mathSubscriptObject() override;
+ AccessibilityObject* mathSuperscriptObject() override;
+
+ // Fenced components.
+ String mathFencedOpenString() const override;
+ String mathFencedCloseString() const override;
+ int mathLineThickness() const override;
+ bool isAnonymousMathOperator() const override;
+
+ // Multiscripts components.
+ void mathPrescripts(AccessibilityMathMultiscriptPairs&) override;
+ void mathPostscripts(AccessibilityMathMultiscriptPairs&) override;
+
+ bool m_isAnonymousOperator;
+};
+
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_ACCESSIBILITY(AccessibilityMathMLElement, isMathElement())
+
+#endif // ENABLE(MATHML)
+#endif // AccessibilityMathMLElement_h
Property changes on: trunk/Source/WebCore/accessibility/AccessibilityMathMLElement.h
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (202960 => 202961)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2016-07-08 05:40:20 UTC (rev 202960)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2016-07-08 05:51:20 UTC (rev 202961)
@@ -66,7 +66,6 @@
#include "HitTestResult.h"
#include "Image.h"
#include "LocalizedStrings.h"
-#include "MathMLNames.h"
#include "NodeList.h"
#include "Page.h"
#include "ProgressTracker.h"
@@ -83,10 +82,6 @@
#include "RenderListItem.h"
#include "RenderListMarker.h"
#include "RenderMathMLBlock.h"
-#include "RenderMathMLFraction.h"
-#include "RenderMathMLMath.h"
-#include "RenderMathMLOperator.h"
-#include "RenderMathMLRoot.h"
#include "RenderMenuList.h"
#include "RenderSVGRoot.h"
#include "RenderSVGShape.h"
@@ -631,13 +626,6 @@
bool isRenderText = is<RenderText>(*m_renderer);
-#if ENABLE(MATHML)
- if (isAnonymousMathOperator()) {
- UChar operatorChar = downcast<RenderMathMLOperator>(*m_renderer).textContent();
- return operatorChar ? String(&operatorChar, 1) : String();
- }
-#endif
-
if (shouldGetTextFromNode(mode))
return AccessibilityNodeObject::textUnderElement(mode);
@@ -761,9 +749,6 @@
if (is<RenderText>(*m_renderer))
return textUnderElement();
- if (isAnonymousMathOperator())
- return textUnderElement();
-
if (is<RenderMenuList>(cssBox)) {
// RenderMenuList will go straight to the text() of its selected item.
// This has to be overridden in the case where the selected item has an ARIA label.
@@ -2629,15 +2614,6 @@
if (isStyleFormatGroup())
return is<RenderInline>(*m_renderer) ? InlineRole : GroupRole;
-#if ENABLE(MATHML)
- if (node && node->hasTagName(MathMLNames::mathTag))
- return DocumentMathRole;
-#endif
- // It's not clear which role a platform should choose for a math element.
- // Declaring a math element role should give flexibility to platforms to choose.
- if (isMathElement())
- return MathElementRole;
-
if (node && node->hasTagName(ddTag))
return DescriptionListDetailRole;
@@ -3606,395 +3582,12 @@
}
#if ENABLE(MATHML)
-bool AccessibilityRenderObject::isMathElement() const
-{
- if (!m_renderer)
- return false;
-
- // The mfenced element creates anonymous RenderMathMLOperators which should be treated
- // as MathML elements and assigned the MathElementRole so that platform logic regarding
- // inclusion and role mapping is not bypassed.
- if (isAnonymousMathOperator())
- return true;
-
- return is<MathMLElement>(node());
-}
-
-bool AccessibilityRenderObject::isMathFraction() const
-{
- return m_renderer && m_renderer->isRenderMathMLFraction();
-}
-
-bool AccessibilityRenderObject::isMathFenced() const
-{
- return m_renderer && m_renderer->isRenderMathMLFenced();
-}
-
-bool AccessibilityRenderObject::isMathSubscriptSuperscript() const
-{
- return m_renderer && m_renderer->isRenderMathMLScripts() && !isMathMultiscript();
-}
-
-bool AccessibilityRenderObject::isMathRow() const
-{
- return m_renderer && m_renderer->isRenderMathMLRow() && !isMathRoot();
-}
-
-bool AccessibilityRenderObject::isMathUnderOver() const
-{
- return m_renderer && m_renderer->isRenderMathMLUnderOver();
-}
-
-bool AccessibilityRenderObject::isMathSquareRoot() const
-{
- return m_renderer && m_renderer->isRenderMathMLSquareRoot();
-}
-
-bool AccessibilityRenderObject::isMathToken() const
-{
- return m_renderer && m_renderer->isRenderMathMLToken();
-}
-
-bool AccessibilityRenderObject::isMathRoot() const
-{
- return m_renderer && m_renderer->isRenderMathMLRoot();
-}
-
-bool AccessibilityRenderObject::isMathOperator() const
-{
- if (!m_renderer || !m_renderer->isRenderMathMLOperator())
- return false;
-
- return true;
-}
-
-bool AccessibilityRenderObject::isAnonymousMathOperator() const
-{
- return is<RenderMathMLOperator>(m_renderer) && m_renderer->isAnonymous();
-}
-
-bool AccessibilityRenderObject::isMathFenceOperator() const
-{
- if (!is<RenderMathMLOperator>(m_renderer))
- return false;
-
- return downcast<RenderMathMLOperator>(*m_renderer).hasOperatorFlag(MathMLOperatorDictionary::Fence);
-}
-
-bool AccessibilityRenderObject::isMathSeparatorOperator() const
-{
- if (!is<RenderMathMLOperator>(m_renderer))
- return false;
-
- return downcast<RenderMathMLOperator>(*m_renderer).hasOperatorFlag(MathMLOperatorDictionary::Separator);
-}
-
-bool AccessibilityRenderObject::isMathText() const
-{
- return node() && (node()->hasTagName(MathMLNames::mtextTag) || hasTagName(MathMLNames::msTag));
-}
-
-bool AccessibilityRenderObject::isMathNumber() const
-{
- return node() && node()->hasTagName(MathMLNames::mnTag);
-}
-
-bool AccessibilityRenderObject::isMathIdentifier() const
-{
- return node() && node()->hasTagName(MathMLNames::miTag);
-}
-
-bool AccessibilityRenderObject::isMathMultiscript() const
-{
- return node() && node()->hasTagName(MathMLNames::mmultiscriptsTag);
-}
-
-bool AccessibilityRenderObject::isMathTable() const
-{
- return node() && node()->hasTagName(MathMLNames::mtableTag);
-}
-
-bool AccessibilityRenderObject::isMathTableRow() const
-{
- return node() && (node()->hasTagName(MathMLNames::mtrTag) || hasTagName(MathMLNames::mlabeledtrTag));
-}
-
-bool AccessibilityRenderObject::isMathTableCell() const
-{
- return node() && node()->hasTagName(MathMLNames::mtdTag);
-}
-
-bool AccessibilityRenderObject::isMathScriptObject(AccessibilityMathScriptObjectType type) const
-{
- AccessibilityObject* parent = parentObjectUnignored();
- if (!parent)
- return false;
-
- return type == Subscript ? this == parent->mathSubscriptObject() : this == parent->mathSuperscriptObject();
-}
-
-bool AccessibilityRenderObject::isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType type) const
-{
- AccessibilityObject* parent = parentObjectUnignored();
- if (!parent || !parent->isMathMultiscript())
- return false;
-
- // The scripts in a MathML <mmultiscripts> element consist of one or more
- // subscript, superscript pairs. In order to determine if this object is
- // a scripted token, we need to examine each set of pairs to see if the
- // this token is present and in the position corresponding with the type.
-
- AccessibilityMathMultiscriptPairs pairs;
- if (type == PreSubscript || type == PreSuperscript)
- parent->mathPrescripts(pairs);
- else
- parent->mathPostscripts(pairs);
-
- for (const auto& pair : pairs) {
- if (this == pair.first)
- return (type == PreSubscript || type == PostSubscript);
- if (this == pair.second)
- return (type == PreSuperscript || type == PostSuperscript);
- }
-
- return false;
-}
-
bool AccessibilityRenderObject::isIgnoredElementWithinMathTree() const
{
- if (!m_renderer)
- return true;
-
- if (is<RenderText>(*m_renderer))
- return false;
-
- // Only math elements that we explicitly recognize should be included
- // We don't want things like <mstyle> to appear in the tree.
- if (isMathElement()) {
- if (isMathFraction() || isMathFenced() || isMathSubscriptSuperscript() || isMathRow()
- || isMathUnderOver() || isMathRoot() || isMathText() || isMathNumber()
- || isMathOperator() || isMathFenceOperator() || isMathSeparatorOperator()
- || isMathIdentifier() || isMathTable() || isMathTableRow() || isMathTableCell() || isMathMultiscript())
- return false;
- return true;
- }
-
- return m_renderer->isAnonymous() && m_renderer->parent() && is<RenderMathMLBlock>(m_renderer->parent());
+ // We ignore anonymous boxes inserted into RenderMathMLBlocks to honor CSS rules.
+ // See https://www.w3.org/TR/css3-box/#block-level0
+ return m_renderer && m_renderer->isAnonymous() && m_renderer->parent() && is<RenderMathMLBlock>(m_renderer->parent());
}
-
-AccessibilityObject* AccessibilityRenderObject::mathRadicandObject()
-{
- if (!isMathRoot())
- return nullptr;
-
- // For MathSquareRoot, we actually return the first child of the base.
- // See also https://webkit.org/b/146452
- const auto& children = this->children();
- if (children.size() < 1)
- return nullptr;
-
- return children[0].get();
-}
-
-AccessibilityObject* AccessibilityRenderObject::mathRootIndexObject()
-{
- if (!isMathRoot() || isMathSquareRoot())
- return nullptr;
-
- const auto& children = this->children();
- if (children.size() < 2)
- return nullptr;
-
- return children[1].get();
-}
-
-AccessibilityObject* AccessibilityRenderObject::mathNumeratorObject()
-{
- if (!isMathFraction())
- return nullptr;
-
- const auto& children = this->children();
- if (children.size() != 2)
- return nullptr;
-
- return children[0].get();
-}
-
-AccessibilityObject* AccessibilityRenderObject::mathDenominatorObject()
-{
- if (!isMathFraction())
- return nullptr;
-
- const auto& children = this->children();
- if (children.size() != 2)
- return nullptr;
-
- return children[1].get();
-}
-
-AccessibilityObject* AccessibilityRenderObject::mathUnderObject()
-{
- if (!isMathUnderOver() || !node())
- return nullptr;
-
- const auto& children = this->children();
- if (children.size() < 2)
- return nullptr;
-
- if (node()->hasTagName(MathMLNames::munderTag) || node()->hasTagName(MathMLNames::munderoverTag))
- return children[1].get();
-
- return nullptr;
-}
-
-AccessibilityObject* AccessibilityRenderObject::mathOverObject()
-{
- if (!isMathUnderOver() || !node())
- return nullptr;
-
- const auto& children = this->children();
- if (children.size() < 2)
- return nullptr;
-
- if (node()->hasTagName(MathMLNames::moverTag))
- return children[1].get();
- if (node()->hasTagName(MathMLNames::munderoverTag))
- return children[2].get();
-
- return nullptr;
-}
-
-AccessibilityObject* AccessibilityRenderObject::mathBaseObject()
-{
- if (!isMathSubscriptSuperscript() && !isMathUnderOver() && !isMathMultiscript())
- return nullptr;
-
- const auto& children = this->children();
- // The base object in question is always the first child.
- if (children.size() > 0)
- return children[0].get();
-
- return nullptr;
-}
-
-AccessibilityObject* AccessibilityRenderObject::mathSubscriptObject()
-{
- if (!isMathSubscriptSuperscript() || !node())
- return nullptr;
-
- const auto& children = this->children();
- if (children.size() < 2)
- return nullptr;
-
- if (node()->hasTagName(MathMLNames::msubTag) || node()->hasTagName(MathMLNames::msubsupTag))
- return children[1].get();
-
- return nullptr;
-}
-
-AccessibilityObject* AccessibilityRenderObject::mathSuperscriptObject()
-{
- if (!isMathSubscriptSuperscript() || !node())
- return nullptr;
-
- const auto& children = this->children();
- unsigned count = children.size();
-
- if (count >= 2 && node()->hasTagName(MathMLNames::msupTag))
- return children[1].get();
-
- if (count >= 3 && node()->hasTagName(MathMLNames::msubsupTag))
- return children[2].get();
-
- return nullptr;
-}
-
-String AccessibilityRenderObject::mathFencedOpenString() const
-{
- if (!isMathFenced())
- return String();
-
- return getAttribute(MathMLNames::openAttr);
-}
-
-String AccessibilityRenderObject::mathFencedCloseString() const
-{
- if (!isMathFenced())
- return String();
-
- return getAttribute(MathMLNames::closeAttr);
-}
-
-void AccessibilityRenderObject::mathPrescripts(AccessibilityMathMultiscriptPairs& prescripts)
-{
- if (!isMathMultiscript() || !node())
- return;
-
- bool foundPrescript = false;
- std::pair<AccessibilityObject*, AccessibilityObject*> prescriptPair;
- for (Node* child = node()->firstChild(); child; child = child->nextSibling()) {
- if (foundPrescript) {
- AccessibilityObject* axChild = axObjectCache()->getOrCreate(child);
- if (axChild && axChild->isMathElement()) {
- if (!prescriptPair.first)
- prescriptPair.first = axChild;
- else {
- prescriptPair.second = axChild;
- prescripts.append(prescriptPair);
- prescriptPair.first = nullptr;
- prescriptPair.second = nullptr;
- }
- }
- } else if (child->hasTagName(MathMLNames::mprescriptsTag))
- foundPrescript = true;
- }
-
- // Handle the odd number of pre scripts case.
- if (prescriptPair.first)
- prescripts.append(prescriptPair);
-}
-
-void AccessibilityRenderObject::mathPostscripts(AccessibilityMathMultiscriptPairs& postscripts)
-{
- if (!isMathMultiscript() || !node())
- return;
-
- // In Multiscripts, the post-script elements start after the first element (which is the base)
- // and continue until a <mprescripts> tag is found
- std::pair<AccessibilityObject*, AccessibilityObject*> postscriptPair;
- bool foundBaseElement = false;
- for (Node* child = node()->firstChild(); child; child = child->nextSibling()) {
- if (child->hasTagName(MathMLNames::mprescriptsTag))
- break;
-
- AccessibilityObject* axChild = axObjectCache()->getOrCreate(child);
- if (axChild && axChild->isMathElement()) {
- if (!foundBaseElement)
- foundBaseElement = true;
- else if (!postscriptPair.first)
- postscriptPair.first = axChild;
- else {
- postscriptPair.second = axChild;
- postscripts.append(postscriptPair);
- postscriptPair.first = nullptr;
- postscriptPair.second = nullptr;
- }
- }
- }
-
- // Handle the odd number of post scripts case.
- if (postscriptPair.first)
- postscripts.append(postscriptPair);
-}
-
-int AccessibilityRenderObject::mathLineThickness() const
-{
- if (!is<RenderMathMLFraction>(m_renderer))
- return -1;
-
- return downcast<RenderMathMLFraction>(*m_renderer).relativeLineThickness();
-}
-
#endif
} // namespace WebCore
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h (202960 => 202961)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h 2016-07-08 05:40:20 UTC (rev 202960)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h 2016-07-08 05:51:20 UTC (rev 202961)
@@ -215,6 +215,10 @@
AccessibilityRole determineAccessibilityRole() override;
bool computeAccessibilityIsIgnored() const override;
+#if ENABLE(MATHML)
+ virtual bool isIgnoredElementWithinMathTree() const;
+#endif
+
RenderObject* m_renderer;
private:
@@ -279,62 +283,6 @@
bool inheritsPresentationalRole() const override;
bool shouldGetTextFromNode(AccessibilityTextUnderElementMode) const;
-
-#if ENABLE(MATHML)
- // All math elements return true for isMathElement().
- bool isMathElement() const override;
- bool isMathFraction() const override;
- bool isMathFenced() const override;
- bool isMathSubscriptSuperscript() const override;
- bool isMathRow() const override;
- bool isMathUnderOver() const override;
- bool isMathRoot() const override;
- bool isMathSquareRoot() const override;
- bool isMathText() const override;
- bool isMathNumber() const override;
- bool isMathOperator() const override;
- bool isMathFenceOperator() const override;
- bool isMathSeparatorOperator() const override;
- bool isMathIdentifier() const override;
- bool isMathTable() const override;
- bool isMathTableRow() const override;
- bool isMathTableCell() const override;
- bool isMathMultiscript() const override;
- bool isMathToken() const override;
- bool isMathScriptObject(AccessibilityMathScriptObjectType) const override;
- bool isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType) const override;
-
- // Generic components.
- AccessibilityObject* mathBaseObject() override;
-
- // Root components.
- AccessibilityObject* mathRadicandObject() override;
- AccessibilityObject* mathRootIndexObject() override;
-
- // Fraction components.
- AccessibilityObject* mathNumeratorObject() override;
- AccessibilityObject* mathDenominatorObject() override;
-
- // Under over components.
- AccessibilityObject* mathUnderObject() override;
- AccessibilityObject* mathOverObject() override;
-
- // Subscript/superscript components.
- AccessibilityObject* mathSubscriptObject() override;
- AccessibilityObject* mathSuperscriptObject() override;
-
- // Fenced components.
- String mathFencedOpenString() const override;
- String mathFencedCloseString() const override;
- int mathLineThickness() const override;
- bool isAnonymousMathOperator() const override;
-
- // Multiscripts components.
- void mathPrescripts(AccessibilityMathMultiscriptPairs&) override;
- void mathPostscripts(AccessibilityMathMultiscriptPairs&) override;
-
- bool isIgnoredElementWithinMathTree() const;
-#endif
};
} // namespace WebCore