Merge m-c to b-s
authorPhil Ringnalda <philringnalda@gmail.com>
Tue, 03 Apr 2012 08:27:38 -0700
changeset 90973 dd43f89c753e15a3c21b1005a0b0bf14955172fe
parent 90972 0fe55a35369ff75edf47ecedb4d88a94036750f2 (current diff)
parent 90894 5128e92c536c17aede8e950dcf1f1974324c9c1e (diff)
child 90974 6236ee493160f1448424886d1697eb3827cd2986
push id22404
push usercoop@mozilla.com
push dateWed, 04 Apr 2012 18:06:17 +0000
treeherdermozilla-central@c598b7b202e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge m-c to b-s
accessible/src/atk/nsMaiInterfaceAction.h
accessible/src/atk/nsMaiInterfaceComponent.h
accessible/src/atk/nsMaiInterfaceDocument.h
accessible/src/atk/nsMaiInterfaceEditableText.h
accessible/src/atk/nsMaiInterfaceHyperlinkImpl.h
accessible/src/atk/nsMaiInterfaceHypertext.h
accessible/src/atk/nsMaiInterfaceImage.h
accessible/src/atk/nsMaiInterfaceSelection.h
accessible/src/atk/nsMaiInterfaceTable.h
accessible/src/atk/nsMaiInterfaceText.h
accessible/src/atk/nsMaiInterfaceValue.h
accessible/src/msaa/CAccessibleAction.cpp
accessible/src/msaa/CAccessibleAction.h
accessible/tests/mochitest/hittest/test_general.xul
allmakefiles.sh
b2g/chrome/content/httpd.js
browser/app/profile/extensions/Extensions.rdf
browser/app/profile/extensions/installed-extensions.txt
browser/modules/KeywordURLResetPrompter.jsm
config/rules.mk
content/base/public/mozISanitizingSerializer.h
content/base/public/nsIMutationObserver2.h
content/base/src/mozSanitizingSerializer.cpp
content/base/src/mozSanitizingSerializer.h
content/base/test/test_bug590771.html
content/base/test/test_bug598877.html
content/base/test/test_bug600466.html
content/base/test/test_bug600468.html
content/base/test/test_bug600471.html
content/canvas/test/webgl/conformance/extensions/compressed-textures/4x4.rgb.dxt1.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/4x4.rgba.dxt1.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/4x4.rgba.dxt3.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/4x4.rgba.dxt5.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/4x4.rgba.raw.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/8x8.rgb.dxt1.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/8x8.rgba.dxt1.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/8x8.rgba.dxt3.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/8x8.rgba.dxt5.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/8x8.rgba.pvrtc4bpp.js
content/canvas/test/webgl/conformance/extensions/compressed-textures/8x8.rgba.raw.js
content/canvas/test/webgl/conformance/extensions/webgl-experimental-compressed-textures.html
content/canvas/test/webgl/conformance/more/conformance/quickCheckAPI.html
content/canvas/test/webgl/conformance/shaders/00_shaders.txt
content/canvas/test/webgl/conformance/shaders/00_test_list.txt
content/canvas/test/webgl/conformance/shaders/glsl-features/00_test_list.txt
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec2-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec2-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec2.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec2.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec3-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec3-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec3.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec3.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec4-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec4-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec4.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/abs-vec4.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/abs.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/abs.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/base.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/base.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec2-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec2-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec2.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec2.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec3-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec3-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec3.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec3.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec4-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec4-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec4.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil-vec4.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/ceil.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec2-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec2-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec2.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec2.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec3-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec3-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec3.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec3.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec4-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec4-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec4.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/floor-vec4.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/floor.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/floor.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec2-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec2-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec2.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec2.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec3-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec3-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec3.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec3.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec4-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec4-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec4.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/fract-vec4.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/fract.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/fract.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec2-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec2-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec2.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec2.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec3-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec3-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec3.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec3.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec4-ref.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec4-ref.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec4.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/sign-vec4.vert
content/canvas/test/webgl/conformance/shaders/glsl-features/sign.frag
content/canvas/test/webgl/conformance/shaders/glsl-features/sign.vert
content/canvas/test/webgl/conformance/shaders/implicit/00_shaders.txt
content/canvas/test/webgl/conformance/shaders/implicit/add_int_float.vert
content/canvas/test/webgl/conformance/shaders/implicit/add_int_mat2.vert
content/canvas/test/webgl/conformance/shaders/implicit/add_int_mat3.vert
content/canvas/test/webgl/conformance/shaders/implicit/add_int_mat4.vert
content/canvas/test/webgl/conformance/shaders/implicit/add_int_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/add_int_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/add_int_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/add_ivec2_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/add_ivec3_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/add_ivec4_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/assign_int_to_float.vert
content/canvas/test/webgl/conformance/shaders/implicit/assign_ivec2_to_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/assign_ivec3_to_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/assign_ivec4_to_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/construct_struct.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_int_float.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_int_mat2.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_int_mat3.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_int_mat4.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_int_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_int_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_int_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_ivec2_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_ivec3_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/divide_ivec4_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/equal_int_float.vert
content/canvas/test/webgl/conformance/shaders/implicit/equal_ivec2_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/equal_ivec3_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/equal_ivec4_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/function_int_float.vert
content/canvas/test/webgl/conformance/shaders/implicit/function_ivec2_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/function_ivec3_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/function_ivec4_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/greater_than.vert
content/canvas/test/webgl/conformance/shaders/implicit/greater_than_equal.vert
content/canvas/test/webgl/conformance/shaders/implicit/less_than.vert
content/canvas/test/webgl/conformance/shaders/implicit/less_than_equal.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_int_float.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_int_mat2.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_int_mat3.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_int_mat4.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_int_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_int_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_int_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_ivec2_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_ivec3_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/multiply_ivec4_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/not_equal_int_float.vert
content/canvas/test/webgl/conformance/shaders/implicit/not_equal_ivec2_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/not_equal_ivec3_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/not_equal_ivec4_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_int_float.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_int_mat2.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_int_mat3.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_int_mat4.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_int_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_int_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_int_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_ivec2_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_ivec3_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/subtract_ivec4_vec4.vert
content/canvas/test/webgl/conformance/shaders/implicit/ternary_int_float.vert
content/canvas/test/webgl/conformance/shaders/implicit/ternary_ivec2_vec2.vert
content/canvas/test/webgl/conformance/shaders/implicit/ternary_ivec3_vec3.vert
content/canvas/test/webgl/conformance/shaders/implicit/ternary_ivec4_vec4.vert
content/canvas/test/webgl/conformance/shaders/misc/00_shaders.txt
content/canvas/test/webgl/conformance/shaders/misc/non-ascii-comments.vert
content/canvas/test/webgl/conformance/shaders/misc/non-ascii.vert
content/canvas/test/webgl/conformance/shaders/misc/shared-a.frag
content/canvas/test/webgl/conformance/shaders/misc/shared-b.frag
content/canvas/test/webgl/conformance/shaders/misc/shared.vert
content/canvas/test/webgl/conformance/shaders/reserved/00_shaders.txt
content/canvas/test/webgl/conformance/shaders/reserved/_webgl_field.vert
content/canvas/test/webgl/conformance/shaders/reserved/_webgl_function.vert
content/canvas/test/webgl/conformance/shaders/reserved/_webgl_struct.vert
content/canvas/test/webgl/conformance/shaders/reserved/_webgl_variable.vert
content/canvas/test/webgl/conformance/shaders/reserved/webgl_field.vert
content/canvas/test/webgl/conformance/shaders/reserved/webgl_function.vert
content/canvas/test/webgl/conformance/shaders/reserved/webgl_struct.vert
content/canvas/test/webgl/conformance/shaders/reserved/webgl_variable.vert
content/canvas/test/webgl/remove-uniqueObjectTest.patch
dom/system/android/nsDeviceMotionSystem.cpp
dom/system/android/nsDeviceMotionSystem.h
dom/system/cocoa/Makefile.in
dom/system/cocoa/nsDeviceMotionSystem.h
dom/system/cocoa/nsDeviceMotionSystem.mm
dom/system/cocoa/nsHapticFeedback.cpp
dom/system/cocoa/nsHapticFeedback.h
dom/system/cocoa/smslib.h
dom/system/cocoa/smslib.mm
dom/system/nsDeviceMotion.cpp
dom/system/nsDeviceMotion.h
dom/system/unix/nsDeviceMotionSystem.cpp
dom/system/unix/nsDeviceMotionSystem.h
dom/system/unix/nsQTMDeviceMotionSystem.cpp
dom/system/unix/nsQTMDeviceMotionSystem.h
dom/system/windows/nsDeviceMotionSystem.cpp
dom/system/windows/nsDeviceMotionSystem.h
dom/tests/mochitest/general/browserFrameHelpers.js
dom/tests/mochitest/general/test_browserFrame1.html
dom/tests/mochitest/general/test_browserFrame2.html
dom/tests/mochitest/general/test_browserFrame3.html
dom/tests/mochitest/general/test_browserFrame4.html
dom/tests/mochitest/general/test_browserFrame5.html
dom/tests/mochitest/general/test_browserFrame6.html
dom/tests/mochitest/general/test_browserFrame7.html
dom/wifi/libcutils.js
dom/wifi/network_worker.js
dom/wifi/nsDOMWifiManager.js
dom/wifi/nsDOMWifiManager.manifest
dom/wifi/nsWifiWorker.h
dom/wifi/nsWifiWorker.js
dom/wifi/nsWifiWorker.manifest
dom/workers/ListenerManager.cpp
dom/workers/ListenerManager.h
dom/workers/XMLHttpRequestPrivate.cpp
dom/workers/XMLHttpRequestPrivate.h
editor/libeditor/text/tests/test_bug717147.html
gfx/thebes/gfxAtomList.h
gfx/thebes/gfxAtoms.cpp
gfx/thebes/gfxAtoms.h
js/src/config/rules.mk
js/src/jit-test/tests/basic/testInitDictionary.js
js/src/jsxdrapi.cpp
js/src/jsxdrapi.h
layout/mathml/nsMathMLForeignFrameWrapper.cpp
layout/mathml/nsMathMLForeignFrameWrapper.h
layout/reftests/svg/as-image/img-blobBuilder-1.html
layout/reftests/svg/as-image/img-blobBuilder-2.html
layout/reftests/transform/skew-1-ref.html
layout/reftests/transform/skew-1a.html
layout/reftests/transform/skew-1b.html
layout/reftests/transform/skew-2-ref.html
layout/reftests/transform/skew-2a.html
layout/svg/base/src/nsSVGLeafFrame.cpp
mobile/android/base/gfx/GLThread.java
mobile/android/base/gfx/PlaceholderLayerClient.java
mobile/android/base/resources/drawable-hdpi/address_bar_texture.png
mobile/android/base/resources/drawable-land-hdpi-v14/address_bar_texture.png
mobile/android/base/resources/drawable-land-mdpi-v14/address_bar_texture.png
mobile/android/base/resources/drawable-land-xhdpi-v14/address_bar_texture.png
mobile/android/base/resources/drawable-xhdpi-v11/address_bar_texture.png
mobile/android/base/resources/drawable/address_bar_texture.png
mobile/android/base/resources/layout/abouthome_content.xml
mobile/android/base/resources/layout/awesomebar_folder_header_row.xml
mobile/android/base/resources/menu-v11/gecko_menu.xml
mobile/android/base/resources/menu/gecko_menu.xml
mobile/android/base/sync/repositories/android/PasswordColumns.java
mobile/android/components/CapturePicker.js
mobile/android/locales/en-US/chrome/webapps.dtd
mobile/android/themes/core/gingerbread/browser.css
mobile/android/themes/core/gingerbread/content.css
mobile/android/themes/core/gingerbread/defines.inc
mobile/android/themes/core/gingerbread/images/alert-addons-30.png
mobile/android/themes/core/gingerbread/images/alert-downloads-30.png
mobile/android/themes/core/gingerbread/images/arrowdown-16.png
mobile/android/themes/core/gingerbread/images/arrowleft-16.png
mobile/android/themes/core/gingerbread/images/arrowright-16.png
mobile/android/themes/core/gingerbread/images/errorpage-larry-black.png
mobile/android/themes/core/gingerbread/images/errorpage-larry-white.png
mobile/android/themes/core/gingerbread/images/errorpage-warning.png
mobile/android/themes/core/gingerbread/images/forward-default-hdpi.png
mobile/android/themes/core/gingerbread/images/mute-hdpi.png
mobile/android/themes/core/gingerbread/images/pause-hdpi.png
mobile/android/themes/core/gingerbread/images/play-hdpi.png
mobile/android/themes/core/gingerbread/images/popup-selected-item-hdpi.png
mobile/android/themes/core/gingerbread/images/remotetabs-32.png
mobile/android/themes/core/gingerbread/images/scrubber-hdpi.png
mobile/android/themes/core/gingerbread/images/search-clear-30.png
mobile/android/themes/core/gingerbread/images/throbber.png
mobile/android/themes/core/gingerbread/images/unmute-hdpi.png
mobile/android/themes/core/gingerbread/images/urlbar-bg.png
mobile/android/themes/core/honeycomb/browser.css
mobile/android/themes/core/honeycomb/defines.inc
mobile/android/themes/core/honeycomb/images/alert-addons-30.png
mobile/android/themes/core/honeycomb/images/alert-downloads-30.png
mobile/android/themes/core/honeycomb/images/arrowdown-16.png
mobile/android/themes/core/honeycomb/images/arrowleft-16.png
mobile/android/themes/core/honeycomb/images/arrowright-16.png
mobile/android/themes/core/honeycomb/images/errorpage-larry-black.png
mobile/android/themes/core/honeycomb/images/errorpage-larry-white.png
mobile/android/themes/core/honeycomb/images/errorpage-warning.png
mobile/android/themes/core/honeycomb/images/forward-default-hdpi.png
mobile/android/themes/core/honeycomb/images/mute-hdpi.png
mobile/android/themes/core/honeycomb/images/pause-hdpi.png
mobile/android/themes/core/honeycomb/images/play-hdpi.png
mobile/android/themes/core/honeycomb/images/popup-selected-item-hdpi.png
mobile/android/themes/core/honeycomb/images/remotetabs-32.png
mobile/android/themes/core/honeycomb/images/scrubber-hdpi.png
mobile/android/themes/core/honeycomb/images/search-clear-30.png
mobile/android/themes/core/honeycomb/images/sidebarbutton-active-hdpi.png
mobile/android/themes/core/honeycomb/images/throbber.png
mobile/android/themes/core/honeycomb/images/unmute-hdpi.png
mobile/android/themes/core/images/alert-addons-30.png
mobile/android/themes/core/images/alert-downloads-30.png
mobile/android/themes/core/images/forward-default-hdpi.png
mobile/android/themes/core/images/popup-selected-item-hdpi.png
mobile/android/themes/core/images/remotetabs-32.png
mobile/android/themes/core/images/sidebarbutton-active-hdpi.png
parser/htmlparser/public/nsIHTMLFragmentContentSink.h
services/sync/tests/unit/test_auth_manager.js
services/sync/tests/unit/test_records_crypto_generateEntry.js
services/sync/tests/unit/test_utils_ensureOneOpen.js
testing/peptest/tests/firefox/server/mozilla.org/index.html.orig
toolkit/components/feeds/test/xml/rfc4287/feed_accessible.xml
toolkit/components/feeds/test/xml/rfc4287/feed_roleatt.xml
toolkit/components/places/nsPlacesImportExportService.cpp
toolkit/components/places/nsPlacesImportExportService.h
toolkit/components/places/tests/unit/expected-favicon-big16.ico.png
toolkit/components/places/tests/unit/expected-favicon-big32.jpg.png
toolkit/components/places/tests/unit/expected-favicon-big4.jpg.png
toolkit/components/places/tests/unit/expected-favicon-big48.ico.png
toolkit/components/places/tests/unit/expected-favicon-big64.png.png
toolkit/components/places/tests/unit/expected-favicon-scale160x3.jpg.png
toolkit/components/places/tests/unit/expected-favicon-scale3x160.jpg.png
toolkit/components/places/tests/unit/favicon-big16.ico
toolkit/components/places/tests/unit/favicon-big32.jpg
toolkit/components/places/tests/unit/favicon-big4.jpg
toolkit/components/places/tests/unit/favicon-big48.ico
toolkit/components/places/tests/unit/favicon-big64.png
toolkit/components/places/tests/unit/favicon-normal16.png
toolkit/components/places/tests/unit/favicon-normal32.png
toolkit/components/places/tests/unit/favicon-scale160x3.jpg
toolkit/components/places/tests/unit/favicon-scale3x160.jpg
toolkit/components/places/tests/unit/test_404630.js
toolkit/components/places/tests/unit/test_451499.js
toolkit/components/places/tests/unit/test_doReplaceFaviconData.js
toolkit/components/places/tests/unit/test_doReplaceFaviconDataFromDataURL.js
toolkit/components/places/tests/unit/test_doSetAndLoadFaviconForPage.js
toolkit/components/places/tests/unit/test_doSetAndLoadFaviconForPage_failures.js
toolkit/components/places/tests/unit/test_faviconService_expireAllFavicons.js
toolkit/components/places/tests/unit/test_favicons.js
toolkit/components/places/tests/unit/test_moz-anno_favicon_mime_type.js
xpcom/system/nsIDeviceMotion.idl
xulrunner/app/profile/extensions/Extensions.rdf
xulrunner/app/profile/extensions/Makefile.in
xulrunner/app/profile/extensions/installed-extensions.txt
xulrunner/installer/mac/Description.plist.in
xulrunner/installer/mac/Info.plist.in
xulrunner/installer/mac/Makefile.in
--- a/Makefile.in
+++ b/Makefile.in
@@ -67,19 +67,25 @@ tier_base_dirs = \
 
 ifndef LIBXUL_SDK
 ifeq (android,$(MOZ_WIDGET_TOOLKIT))
 tier_base_dirs += \
   other-licenses/android \
   other-licenses/skia-npapi \
   $(NULL)
 endif
+ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
+tier_base_dirs += \
+  other-licenses/android \
+  $(NULL)
+endif
 
 ifdef MOZ_MEMORY
 tier_base_dirs += memory/jemalloc
+tier_base_dirs += memory/build
 endif
 tier_base_dirs += \
   mozglue \
   memory/mozalloc \
   $(NULL)
 endif
 
 ifdef COMPILE_ENVIRONMENT
--- a/accessible/public/nsIAccessibilityService.h
+++ b/accessible/public/nsIAccessibilityService.h
@@ -80,60 +80,17 @@ public:
    *
    * @param aPresShell  [in] the presshell
    * @param aCanCreate  [in] points whether the root document accessible
    *                        should be returned from the cache or can be created
    */
   virtual nsAccessible* GetRootDocumentAccessible(nsIPresShell* aPresShell,
                                                   bool aCanCreate) = 0;
 
-  /**
-   * Creates accessible for the given DOM node or frame.
-   */
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLBRAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLCaptionAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLCheckboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLComboboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLGroupboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLHRAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLImageAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLLabelAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLLIAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLListboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLMediaAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLObjectFrameAccessible(nsObjectFrame* aFrame, nsIContent* aContent,
-                                    nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLRadioButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLTableAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLTableCellAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLTextAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHTMLTextFieldAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateHyperTextAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-  virtual already_AddRefed<nsAccessible>
-    CreateOuterDocAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
-
-  /**
+   /**
    * Adds/remove ATK root accessible for gtk+ native window to/from children
    * of the application accessible.
    */
   virtual nsAccessible* AddNativeRootAccessible(void* aAtkAccessible) = 0;
   virtual void RemoveNativeRootAccessible(nsAccessible* aRootAccessible) = 0;
 
   /**
    * Notification used to update the accessible tree when new content is
@@ -158,22 +115,16 @@ public:
 
   /**
    * Notify the accessibility service that the given presshell is
    * being destroyed.
    */
   virtual void PresShellDestroyed(nsIPresShell *aPresShell) = 0;
 
   /**
-   * Recreate an accessible for the given content node in the presshell.
-   */
-  virtual void RecreateAccessible(nsIPresShell* aPresShell,
-                                  nsIContent* aContent) = 0;
-
-  /**
    * Fire accessible event of the given type for the given target.
    *
    * @param aEvent   [in] accessible event type
    * @param aTarget  [in] target of accessible event
    */
   virtual void FireAccessibleEvent(PRUint32 aEvent, nsAccessible* aTarget) = 0;
 };
 
--- a/accessible/public/nsIAccessible.idl
+++ b/accessible/public/nsIAccessible.idl
@@ -54,17 +54,17 @@ interface nsIAccessibleRelation;
  * accessibility APIs like MSAA and ATK. Contains the sum of what's needed
  * to support IAccessible as well as ATK's generic accessibility objects.
  * Can also be used by in-process accessibility clients to get information
  * about objects in the accessible tree. The accessible tree is a subset of 
  * nodes in the DOM tree -- such as documents, focusable elements and text.
  * Mozilla creates the implementations of nsIAccessible on demand.
  * See http://www.mozilla.org/projects/ui/accessibility for more information.
  */
-[scriptable, uuid(e7c44e0d-736e-4ead-afee-b51f4b574020)]
+[scriptable, uuid(46d422d1-c92f-4536-bdef-f77bc8350ec7)]
 interface nsIAccessible : nsISupports
 {
   /**
    * Parent node in accessible tree.
    */
   readonly attribute nsIAccessible parent;
 
   /**
@@ -99,23 +99,16 @@ interface nsIAccessible : nsISupports
 
   /**
    * The 0-based index of this accessible in its parent's list of children,
    * or -1 if this accessible does not have a parent.
    */
   readonly attribute long indexInParent;
 
   /**
-   * The innerHTML for the HTML element associated with this accessible if applicable.
-   * This is a text string of all the markup inside the DOM
-   * node, not including the start and end tag for the node.
-   */
-  readonly attribute DOMString innerHTML;
-
-  /**
    * The DOM node this nsIAccessible is associated with.
    */
   readonly attribute nsIDOMNode DOMNode;
 
   /**
    * The document accessible that this access node resides in.
    */
   readonly attribute nsIAccessibleDocument document;
--- a/accessible/public/nsIAccessibleRole.idl
+++ b/accessible/public/nsIAccessibleRole.idl
@@ -788,14 +788,19 @@ interface nsIAccessibleRole : nsISupport
   const unsigned long ROLE_NOTE = 123;
 
   /**
    * A figure. Used for things like HTML5 figure element.
    */
   const unsigned long ROLE_FIGURE = 124;
 
   /**
+   * Represents a rich item with a check box.
+   */
+  const unsigned long ROLE_CHECK_RICH_OPTION = 125;
+
+  /**
    * It's not role actually. This constant is important to help ensure
    * nsRoleMap's are synchronized.
    */
-  const unsigned long ROLE_LAST_ENTRY = 125;
+  const unsigned long ROLE_LAST_ENTRY = 126;
 };
 
--- a/accessible/src/atk/AtkSocketAccessible.cpp
+++ b/accessible/src/atk/AtkSocketAccessible.cpp
@@ -34,137 +34,121 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <atk/atk.h>
 #include "AtkSocketAccessible.h"
+
+#include "InterfaceInitFuncs.h"
 #include "nsMai.h"
-#include "nsMaiInterfaceComponent.h"
 
-void (*AtkSocketAccessible::g_atk_socket_embed) (AtkSocket*, gchar*) = NULL;
+AtkSocketEmbedType AtkSocketAccessible::g_atk_socket_embed = NULL;
 GType AtkSocketAccessible::g_atk_socket_type = G_TYPE_INVALID;
 const char* AtkSocketAccessible::sATKSocketEmbedSymbol = "atk_socket_embed";
 const char* AtkSocketAccessible::sATKSocketGetTypeSymbol = "atk_socket_get_type";
 
 bool AtkSocketAccessible::gCanEmbed = FALSE;
 
+extern "C" void mai_atk_component_iface_init(AtkComponentIface* aIface);
+extern "C" GType mai_atk_socket_get_type(void);
+
 /* MaiAtkSocket */
 
 #define MAI_TYPE_ATK_SOCKET              (mai_atk_socket_get_type ())
 #define MAI_ATK_SOCKET(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
                                           MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
 #define MAI_IS_ATK_SOCKET(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
                                           MAI_TYPE_ATK_SOCKET))
 #define MAI_ATK_SOCKET_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass),\
                                           MAI_TYPE_ATK_SOCKET,\
                                           MaiAtkSocketClass))
 #define MAI_IS_ATK_SOCKET_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass),\
                                           MAI_TYPE_ATK_SOCKET))
 #define MAI_ATK_SOCKET_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj),\
                                           MAI_TYPE_ATK_SOCKET,\
                                           MaiAtkSocketClass))
 
-typedef struct _MaiAtkSocket             MaiAtkSocket;
-typedef struct _MaiAtkSocketClass        MaiAtkSocketClass;
-
-struct _MaiAtkSocket
+typedef struct _MaiAtkSocket
 {
   AtkSocket parent;
 
   nsAccessibleWrap* accWrap;
-};
+} MaiAtkSocket;
 
-struct _MaiAtkSocketClass
+typedef struct _MaiAtkSocketClass
 {
   AtkSocketClass parent_class;
-};
-
-G_BEGIN_DECLS
-
-GType mai_atk_socket_get_type(void);
-AtkObject* mai_atk_socket_new(nsAccessibleWrap* aAccWrap);
-
-void mai_atk_component_iface_init(AtkComponentIface* aIface);
-AtkObject* mai_atk_socket_ref_accessible_at_point(AtkComponent *aComponent,
-                                                  gint aAccX,
-                                                  gint aAccY,
-                                                  AtkCoordType aCoordType);
-void mai_atk_socket_get_extents(AtkComponent* aComponent,
-                                gint* aAccX,
-                                gint* aAccY,
-                                gint* aAccWidth,
-                                gint* aAccHeight,
-                                AtkCoordType aCoordType);
-
-G_END_DECLS
+} MaiAtkSocketClass;
 
 G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
                        AtkSocketAccessible::g_atk_socket_type, 0,
                        G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
                                              mai_atk_component_iface_init))
 
 void
 mai_atk_socket_class_init(MaiAtkSocketClass* aAcc)
 {
 }
 
 void
 mai_atk_socket_init(MaiAtkSocket* aAcc)
 {
 }
 
-AtkObject*
+static AtkObject*
 mai_atk_socket_new(nsAccessibleWrap* aAccWrap)
 {
   NS_ENSURE_TRUE(aAccWrap, NULL);
 
   MaiAtkSocket* acc = nsnull;
   acc = static_cast<MaiAtkSocket*>(g_object_new(MAI_TYPE_ATK_SOCKET, NULL));
   NS_ENSURE_TRUE(acc, NULL);
 
   acc->accWrap = aAccWrap;
   return ATK_OBJECT(acc);
 }
 
-void
-mai_atk_component_iface_init(AtkComponentIface* aIface)
-{
-  NS_ASSERTION(aIface, "Invalid Interface");
-
-  aIface->ref_accessible_at_point = mai_atk_socket_ref_accessible_at_point;
-  aIface->get_extents = mai_atk_socket_get_extents;
-}
-
-AtkObject*
-mai_atk_socket_ref_accessible_at_point(AtkComponent* aComponent,
-                                       gint aX, gint aY,
-                                       AtkCoordType aCoordType)
+extern "C" {
+static AtkObject*
+RefAccessibleAtPoint(AtkComponent* aComponent, gint aX, gint aY,
+                     AtkCoordType aCoordType)
 {
   NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nsnull);
 
   return refAccessibleAtPointHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
                                     aX, aY, aCoordType);
 }
 
-void
-mai_atk_socket_get_extents(AtkComponent* aComponent,
-                           gint* aX, gint* aY, gint* aWidth, gint* aHeight,
-                           AtkCoordType aCoordType)
+static void
+GetExtents(AtkComponent* aComponent, gint* aX, gint* aY, gint* aWidth,
+           gint* aHeight, AtkCoordType aCoordType)
 {
   *aX = *aY = *aWidth = *aHeight = 0;
 
   if (!MAI_IS_ATK_SOCKET(aComponent))
     return;
 
   getExtentsHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
                    aX, aY, aWidth, aHeight, aCoordType);
 }
+}
+
+void
+mai_atk_component_iface_init(AtkComponentIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid Interface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->ref_accessible_at_point = RefAccessibleAtPoint;
+  aIface->get_extents = GetExtents;
+}
 
 AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
                                          nsDocAccessible* aDoc,
                                          const nsCString& aPlugId) :
   nsAccessibleWrap(aContent, aDoc)
 {
   mAtkObject = mai_atk_socket_new(this);
   if (!mAtkObject)
--- a/accessible/src/atk/AtkSocketAccessible.h
+++ b/accessible/src/atk/AtkSocketAccessible.h
@@ -40,19 +40,19 @@
 #ifndef _AtkSocketAccessible_H_
 #define _AtkSocketAccessible_H_
 
 #include "nsAccessibleWrap.h"
 
 // This file gets included by nsAccessibilityService.cpp, which can't include
 // atk.h (or glib.h), so we can't rely on it being included.
 #ifdef __ATK_H__
-typedef void (*AtkSocketEmbedType) (AtkSocket*, gchar*);
+extern "C" typedef void (*AtkSocketEmbedType) (AtkSocket*, gchar*);
 #else
-typedef void (*AtkSocketEmbedType) (void*, void*);
+extern "C" typedef void (*AtkSocketEmbedType) (void*, void*);
 #endif
 
 /**
  * Provides a nsAccessibleWrap wrapper around AtkSocket for out-of-process
  * accessibles.
  */
 class AtkSocketAccessible: public nsAccessibleWrap
 {
new file mode 100644
--- /dev/null
+++ b/accessible/src/atk/InterfaceInitFuncs.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ *  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ *   * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef ATK_INTERFACE_INIT_FUNCS_H_
+#define ATK_INTERFACE_INIT_FUNCS_H_
+
+#include <atk/atk.h>
+
+class nsAccessibleWrap;
+
+extern "C" {
+void actionInterfaceInitCB(AtkActionIface* aIface);
+void componentInterfaceInitCB(AtkComponentIface* aIface);
+void documentInterfaceInitCB(AtkDocumentIface *aIface);
+void editableTextInterfaceInitCB(AtkEditableTextIface* aIface);
+void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface);
+void hypertextInterfaceInitCB(AtkHypertextIface* aIface);
+void imageInterfaceInitCB(AtkImageIface* aIface);
+void selectionInterfaceInitCB(AtkSelectionIface* aIface);
+void tableInterfaceInitCB(AtkTableIface *aIface);
+void textInterfaceInitCB(AtkTextIface* aIface);
+void valueInterfaceInitCB(AtkValueIface *aIface);
+}
+
+/**
+ * XXX these should live in a file of utils for atk.
+ */
+AtkObject* refAccessibleAtPointHelper(nsAccessibleWrap* aAccWrap,
+                                      gint aX, gint aY, AtkCoordType aCoordType);
+void getExtentsHelper(nsAccessibleWrap* aAccWrap,
+                      gint* aX, gint* aY, gint* aWidth, gint* aHeight,
+                      AtkCoordType aCoordType);
+
+#endif // ATK_INTERFACE_INIT_FUNCS_H_
--- a/accessible/src/atk/Makefile.in
+++ b/accessible/src/atk/Makefile.in
@@ -94,12 +94,14 @@ CXXFLAGS	+= $(MOZ_GTK2_CFLAGS)
 
 ifdef MOZ_ENABLE_DBUS
 CXXFLAGS += $(MOZ_DBUS_CFLAGS)
 endif
 
 LOCAL_INCLUDES += \
   -I$(srcdir) \
   -I$(srcdir)/../base \
+  -I$(srcdir)/../generic \
   -I$(srcdir)/../html \
+  -I$(srcdir)/../xpcom \
   -I$(srcdir)/../xul \
   -I$(topsrcdir)/other-licenses/atk-1.0 \
   $(NULL)
--- a/accessible/src/atk/nsAccessNodeWrap.cpp
+++ b/accessible/src/atk/nsAccessNodeWrap.cpp
@@ -34,17 +34,16 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsAccessNodeWrap.h"
 #include "nsApplicationAccessibleWrap.h"
-#include "nsMaiInterfaceText.h"
 
 /* For documentation of the accessibility architecture, 
  * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
  */
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessNodeWrap
--- a/accessible/src/atk/nsAccessibleWrap.cpp
+++ b/accessible/src/atk/nsAccessibleWrap.cpp
@@ -38,43 +38,35 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
 #include "nsAccessible.h"
 #include "nsAccessibleWrap.h"
 
+#include "InterfaceInitFuncs.h"
 #include "nsAccUtils.h"
 #include "nsApplicationAccessibleWrap.h"
 #include "nsIAccessibleRelation.h"
 #include "nsRootAccessible.h"
 #include "nsDocAccessibleWrap.h"
 #include "nsIAccessibleValue.h"
+#include "nsMai.h"
+#include "nsMaiHyperlink.h"
 #include "nsString.h"
 #include "nsAutoPtr.h"
 #include "prprf.h"
 #include "nsRoleMap.h"
 #include "nsStateMap.h"
 #include "Relation.h"
 #include "States.h"
 
-#include "nsMaiInterfaceComponent.h"
-#include "nsMaiInterfaceAction.h"
-#include "nsMaiInterfaceText.h"
-#include "nsMaiInterfaceEditableText.h"
-#include "nsMaiInterfaceSelection.h"
-#include "nsMaiInterfaceValue.h"
-#include "nsMaiInterfaceHypertext.h"
-#include "nsMaiInterfaceHyperlinkImpl.h"
-#include "nsMaiInterfaceTable.h"
 #include "nsXPCOMStrings.h"
 #include "nsComponentManagerUtils.h"
-#include "nsMaiInterfaceDocument.h"
-#include "nsMaiInterfaceImage.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 nsAccessibleWrap::EAvailableAtkSignals nsAccessibleWrap::gAvailableAtkSignals =
   eUnknown;
 
 //defined in nsApplicationAccessibleWrap.cpp
--- a/accessible/src/atk/nsMaiInterfaceAction.cpp
+++ b/accessible/src/atk/nsMaiInterfaceAction.cpp
@@ -32,86 +32,72 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceAction.h"
+#include "InterfaceInitFuncs.h"
 
-#include "nsAccUtils.h"
-#include "nsRoleMap.h"
-#include "nsString.h"
+#include "nsMai.h"
 #include "Role.h"
 
-#include "nsIDOMDOMStringList.h"
+#include "nsString.h"
 
 using namespace mozilla::a11y;
 
-void
-actionInterfaceInitCB(AtkActionIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
+extern "C" {
 
-    aIface->do_action = doActionCB;
-    aIface->get_n_actions = getActionCountCB;
-    aIface->get_description = getActionDescriptionCB;
-    aIface->get_keybinding = getKeyBindingCB;
-    aIface->get_name = getActionNameCB;
-}
-
-gboolean
+static gboolean
 doActionCB(AtkAction *aAction, gint aActionIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
     if (!accWrap)
         return FALSE;
  
     nsresult rv = accWrap->DoAction(aActionIndex);
     return (NS_FAILED(rv)) ? FALSE : TRUE;
 }
 
-gint
+static gint
 getActionCountCB(AtkAction *aAction)
 {
   nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
   return accWrap ? accWrap->ActionCount() : 0;
 }
 
-const gchar *
+static const gchar*
 getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
     if (!accWrap)
         return nsnull;
 
     nsAutoString description;
     nsresult rv = accWrap->GetActionDescription(aActionIndex, description);
     NS_ENSURE_SUCCESS(rv, nsnull);
     return nsAccessibleWrap::ReturnString(description);
 }
 
-const gchar *
+static const gchar*
 getActionNameCB(AtkAction *aAction, gint aActionIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
     if (!accWrap)
         return nsnull;
 
     nsAutoString autoStr;
     nsresult rv = accWrap->GetActionName(aActionIndex, autoStr);
     NS_ENSURE_SUCCESS(rv, nsnull);
     return nsAccessibleWrap::ReturnString(autoStr);
 }
 
-const gchar *
+static const gchar*
 getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
 {
   nsAccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction));
   if (!acc)
     return nsnull;
 
   // Return all key bindings including access key and keyboard shortcut.
   nsAutoString keyBindingsStr;
@@ -151,8 +137,23 @@ getKeyBindingCB(AtkAction *aAction, gint
   keyBindingsStr.Append(';');
   keyBinding = acc->KeyboardShortcut();
   if (!keyBinding.IsEmpty()) {
     keyBinding.AppendToString(keyBindingsStr, KeyBinding::eAtkFormat);
   }
 
   return nsAccessibleWrap::ReturnString(keyBindingsStr);
 }
+}
+
+void
+actionInterfaceInitCB(AtkActionIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->do_action = doActionCB;
+  aIface->get_n_actions = getActionCountCB;
+  aIface->get_description = getActionDescriptionCB;
+  aIface->get_keybinding = getKeyBindingCB;
+  aIface->get_name = getActionNameCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceAction.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_ACTION_H__
-#define __MAI_INTERFACE_ACTION_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-/* action interface callbacks */
-void actionInterfaceInitCB(AtkActionIface *aIface);
-gboolean doActionCB(AtkAction *aAction, gint aActionIndex);
-gint getActionCountCB(AtkAction *aAction);
-const gchar *getActionDescriptionCB(AtkAction *aAction, gint aActionIndex);
-const gchar *getActionNameCB(AtkAction *aAction, gint aActionIndex);
-const gchar *getKeyBindingCB(AtkAction *aAction, gint aActionIndex);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_ACTION_H__ */
--- a/accessible/src/atk/nsMaiInterfaceComponent.cpp
+++ b/accessible/src/atk/nsMaiInterfaceComponent.cpp
@@ -32,64 +32,52 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceComponent.h"
+#include "InterfaceInitFuncs.h"
 
 #include "nsAccessibleWrap.h"
 #include "nsAccUtils.h"
 #include "nsCoreUtils.h"
-
-void
-componentInterfaceInitCB(AtkComponentIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid Interface");
-    if(!aIface)
-        return;
+#include "nsMai.h"
 
-    /*
-     * Use default implementation in atk for contains, get_position,
-     * and get_size
-     */
-    aIface->ref_accessible_at_point = refAccessibleAtPointCB;
-    aIface->get_extents = getExtentsCB;
-    aIface->grab_focus = grabFocusCB;
-}
+extern "C" {
 
-AtkObject*
+static AtkObject*
 refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX, gint aAccY,
                        AtkCoordType aCoordType)
 {
   return refAccessibleAtPointHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
                                     aAccX, aAccY, aCoordType);
 }
 
-void
+static void
 getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
              gint* aWidth, gint* aHeight, AtkCoordType aCoordType)
 {
   getExtentsHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
                    aX, aY, aWidth, aHeight, aCoordType);
 }
 
-gboolean
+static gboolean
 grabFocusCB(AtkComponent* aComponent)
 {
   nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
   if (!accWrap)
     return FALSE;
 
   nsresult rv = accWrap->TakeFocus();
   return (NS_FAILED(rv)) ? FALSE : TRUE;
 }
+}
 
 AtkObject*
 refAccessibleAtPointHelper(nsAccessibleWrap* aAccWrap, gint aX, gint aY,
                            AtkCoordType aCoordType)
 {
   if (!aAccWrap || aAccWrap->IsDefunct() || nsAccUtils::MustPrune(aAccWrap))
     return nsnull;
 
@@ -135,8 +123,24 @@ getExtentsHelper(nsAccessibleWrap* aAccW
     y -= winCoords.y;
   }
 
   *aX = x;
   *aY = y;
   *aWidth = width;
   *aHeight = height;
 }
+
+void
+componentInterfaceInitCB(AtkComponentIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid Interface");
+  if(NS_UNLIKELY(!aIface))
+    return;
+
+  /*
+   * Use default implementation in atk for contains, get_position,
+   * and get_size
+   */
+  aIface->ref_accessible_at_point = refAccessibleAtPointCB;
+  aIface->get_extents = getExtentsCB;
+  aIface->grab_focus = grabFocusCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceComponent.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_COMPONENT_H__
-#define __MAI_INTERFACE_COMPONENT_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-/* component interface callbacks */
-void componentInterfaceInitCB(AtkComponentIface* aIface);
-AtkObject* refAccessibleAtPointCB(AtkComponent* aComponent,
-                                  gint aX, gint aY,
-                                  AtkCoordType aCoordType);
-void getExtentsCB(AtkComponent* aComponent,
-                  gint* aX, gint* aY, gint* aWidth, gint* aHeight,
-                  AtkCoordType aCoordType);
-/* the "contains", "get_position", "get_size" can take advantage of
- * "get_extents", there is no need to implement them now.
- */
-gboolean grabFocusCB(AtkComponent* aComponent);
-
-/* what are missing now for atk component:
- *
- * add_focus_handler
- * remove_focus_handler
- * set_extents
- * set_position
- * set_size
- * get_layer
- * get_mdi_zorder
- */
-
-AtkObject* refAccessibleAtPointHelper(nsAccessibleWrap* aAccWrap,
-                                      gint aX, gint aY, AtkCoordType aCoordType);
-void getExtentsHelper(nsAccessibleWrap* aAccWrap,
-                      gint* aX, gint* aY, gint* aWidth, gint* aHeight,
-                      AtkCoordType aCoordType);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_COMPONENT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceDocument.cpp
+++ b/accessible/src/atk/nsMaiInterfaceDocument.cpp
@@ -32,20 +32,21 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceDocument.h"
+#include "InterfaceInitFuncs.h"
 
 #include "nsAccessibleWrap.h"
 #include "nsDocAccessible.h"
+#include "nsMai.h"
 
 static const char* const kDocTypeName = "W3C-doctype";
 static const char* const kDocUrlName = "DocURL";
 static const char* const kMimeTypeName = "MimeType";
 
 // below functions are vfuncs on an ATK  interface so they need to be C call
 extern "C" {
 
@@ -53,17 +54,17 @@ static const gchar* getDocumentLocaleCB(
 static AtkAttributeSet* getDocumentAttributesCB(AtkDocument* aDocument);
 static const gchar* getDocumentAttributeValueCB(AtkDocument* aDocument,
                                                 const gchar* aAttrName);
 
 void
 documentInterfaceInitCB(AtkDocumentIface *aIface)
 {
     NS_ASSERTION(aIface, "Invalid Interface");
-    if(!aIface)
+    if(NS_UNLIKELY(!aIface))
         return;
 
     /*
      * We don't support get_document or set_attribute right now.
      * get_document_type is deprecated, we return DocType in
      * get_document_attribute_value and get_document_attributes instead.
      */
     aIface->get_document_attributes = getDocumentAttributesCB;
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceDocument.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Evan Yan (evan.yan@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_DOCUMENT_H__
-#define __MAI_INTERFACE_DOCUMENT_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-/* document interface callbacks */
-void documentInterfaceInitCB(AtkDocumentIface *aIface);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_DOCUMENT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceEditableText.cpp
+++ b/accessible/src/atk/nsMaiInterfaceEditableText.cpp
@@ -32,41 +32,28 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsString.h"
-#include "nsMaiInterfaceEditableText.h"
+#include "InterfaceInitFuncs.h"
 
-void
-editableTextInterfaceInitCB(AtkEditableTextIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
+#include "nsHyperTextAccessible.h"
+#include "nsMai.h"
 
-    aIface->set_run_attributes = setRunAttributesCB;
-    aIface->set_text_contents = setTextContentsCB;
-    aIface->insert_text = insertTextCB;
-    aIface->copy_text = copyTextCB;
-    aIface->cut_text = cutTextCB;
-    aIface->delete_text = deleteTextCB;
-    aIface->paste_text = pasteTextCB;
-}
+#include "nsString.h"
 
-/* static, callbacks for atkeditabletext virutal functions */
+extern "C" {
 
-gboolean
+static gboolean
 setRunAttributesCB(AtkEditableText *aText, AtkAttributeSet *aAttribSet,
                    gint aStartOffset, gint aEndOffset)
-
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
                             getter_AddRefs(accText));
@@ -75,17 +62,17 @@ setRunAttributesCB(AtkEditableText *aTex
     nsCOMPtr<nsISupports> attrSet;
     /* how to insert attributes into nsISupports ??? */
 
     nsresult rv = accText->SetAttributes(aStartOffset, aEndOffset,
                                          attrSet);
     return NS_FAILED(rv) ? FALSE : TRUE;
 }
 
-void
+static void
 setTextContentsCB(AtkEditableText *aText, const gchar *aString)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
@@ -94,45 +81,45 @@ setTextContentsCB(AtkEditableText *aText
         return;
 
     MAI_LOG_DEBUG(("EditableText: setTextContentsCB, aString=%s", aString));
 
     NS_ConvertUTF8toUTF16 strContent(aString);
     accText->SetTextContents(strContent);
 }
 
-void
+static void
 insertTextCB(AtkEditableText *aText,
              const gchar *aString, gint aLength, gint *aPosition)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
                             getter_AddRefs(accText));
     if (!accText)
         return;
 
-    NS_ConvertUTF8toUTF16 strContent(aString);
+    NS_ConvertUTF8toUTF16 strContent(aString, aLength);
 
     // interface changed in nsIAccessibleEditableText.idl ???
     //
     // PRInt32 pos = *aPosition;
     // nsresult rv = accText->InsertText(strContent, aLength, &pos);
     // *aPosition = pos;
 
     accText->InsertText(strContent, *aPosition);
 
     MAI_LOG_DEBUG(("EditableText: insert aString=%s, aLength=%d, aPosition=%d",
                    aString, aLength, *aPosition));
 }
 
-void
+static void
 copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
@@ -140,34 +127,34 @@ copyTextCB(AtkEditableText *aText, gint 
     if (!accText)
         return;
 
     MAI_LOG_DEBUG(("EditableText: copyTextCB, aStartPos=%d, aEndPos=%d",
                    aStartPos, aEndPos));
     accText->CopyText(aStartPos, aEndPos);
 }
 
-void
+static void
 cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
                             getter_AddRefs(accText));
     if (!accText)
         return;
     MAI_LOG_DEBUG(("EditableText: cutTextCB, aStartPos=%d, aEndPos=%d",
                    aStartPos, aEndPos));
     accText->CutText(aStartPos, aEndPos);
 }
 
-void
+static void
 deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
@@ -175,24 +162,41 @@ deleteTextCB(AtkEditableText *aText, gin
     if (!accText)
         return;
 
     MAI_LOG_DEBUG(("EditableText: deleteTextCB, aStartPos=%d, aEndPos=%d",
                    aStartPos, aEndPos));
     accText->DeleteText(aStartPos, aEndPos);
 }
 
-void
+static void
 pasteTextCB(AtkEditableText *aText, gint aPosition)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
                             getter_AddRefs(accText));
     if (!accText)
         return;
 
     MAI_LOG_DEBUG(("EditableText: pasteTextCB, aPosition=%d", aPosition));
     accText->PasteText(aPosition);
 }
+}
+
+void
+editableTextInterfaceInitCB(AtkEditableTextIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->set_run_attributes = setRunAttributesCB;
+  aIface->set_text_contents = setTextContentsCB;
+  aIface->insert_text = insertTextCB;
+  aIface->copy_text = copyTextCB;
+  aIface->cut_text = cutTextCB;
+  aIface->delete_text = deleteTextCB;
+  aIface->paste_text = pasteTextCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceEditableText.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_EDITABLETEXT_H__
-#define __MAI_INTERFACE_EDITABLETEXT_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleEditableText.h"
-
-G_BEGIN_DECLS
-
-void editableTextInterfaceInitCB(AtkEditableTextIface *aIface);
-
-/* editabletext interface callbacks */
-gboolean setRunAttributesCB(AtkEditableText *aText,
-                            AtkAttributeSet *aAttribSet,
-                            gint aStartOffset,
-                            gint aEndOffset);
-void setTextContentsCB(AtkEditableText *aText, const gchar *aString);
-void insertTextCB(AtkEditableText *aText,
-                  const gchar *aString, gint aLength, gint *aPosition);
-void copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos);
-void cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos);
-void deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos);
-void pasteTextCB(AtkEditableText *aText, gint aPosition);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_EDITABLETEXT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp
+++ b/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp
@@ -32,32 +32,37 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceHyperlinkImpl.h"
+#include "InterfaceInitFuncs.h"
+
 #include "nsMaiHyperlink.h"
 
-void
-hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface)
-{
-    g_return_if_fail(aIface != NULL);
-
-    aIface->get_hyperlink = getHyperlinkCB;
-}
-
-AtkHyperlink*
+extern "C" {
+static AtkHyperlink*
 getHyperlinkCB(AtkHyperlinkImpl* aImpl)
 {
   nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImpl));
   if (!accWrap)
     return nsnull;
 
   NS_ENSURE_TRUE(accWrap->IsLink(), nsnull);
 
   MaiHyperlink* maiHyperlink = accWrap->GetMaiHyperlink();
   NS_ENSURE_TRUE(maiHyperlink, nsnull);
   return maiHyperlink->GetAtkHyperlink();
 }
+}
+
+void
+hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface)
+{
+  NS_ASSERTION(aIface, "no interface!");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_hyperlink = getHyperlinkCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Neo Liu(nian.liu@sun.com) 
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_HYPERLINKIMPL_H__
-#define __MAI_INTERFACE_HYPERLINKIMPL_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface);
-
-/* hyperlinkImpl interface callbacks */
-AtkHyperlink  *getHyperlinkCB (AtkHyperlinkImpl *aImpl);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_HYPERLINKIMPL_H__ */
-
--- a/accessible/src/atk/nsMaiInterfaceHypertext.cpp
+++ b/accessible/src/atk/nsMaiInterfaceHypertext.cpp
@@ -32,30 +32,25 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceHypertext.h"
-#include "nsHyperTextAccessible.h"
+#include "InterfaceInitFuncs.h"
 
-void
-hypertextInterfaceInitCB(AtkHypertextIface *aIface)
-{
-    g_return_if_fail(aIface != NULL);
+#include "nsHyperTextAccessible.h"
+#include "nsMai.h"
+#include "nsMaiHyperlink.h"
 
-    aIface->get_link = getLinkCB;
-    aIface->get_n_links = getLinkCountCB;
-    aIface->get_link_index = getLinkIndexCB;
-}
+extern "C" {
 
-AtkHyperlink *
+static AtkHyperlink*
 getLinkCB(AtkHypertext *aText, gint aLinkIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsHyperTextAccessible* hyperText = accWrap->AsHyperText();
     NS_ENSURE_TRUE(hyperText, nsnull);
@@ -68,37 +63,50 @@ getLinkCB(AtkHypertext *aText, gint aLin
     nsAccessibleWrap *accChild = GetAccessibleWrap(hyperLinkAtkObj);
     NS_ENSURE_TRUE(accChild, nsnull);
 
     MaiHyperlink *maiHyperlink = accChild->GetMaiHyperlink();
     NS_ENSURE_TRUE(maiHyperlink, nsnull);
     return maiHyperlink->GetAtkHyperlink();
 }
 
-gint
+static gint
 getLinkCountCB(AtkHypertext *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return -1;
 
     nsHyperTextAccessible* hyperText = accWrap->AsHyperText();
     NS_ENSURE_TRUE(hyperText, -1);
 
     return hyperText->GetLinkCount();
 }
 
-gint
+static gint
 getLinkIndexCB(AtkHypertext *aText, gint aCharIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return -1;
 
     nsHyperTextAccessible* hyperText = accWrap->AsHyperText();
     NS_ENSURE_TRUE(hyperText, -1);
 
     PRInt32 index = -1;
     nsresult rv = hyperText->GetLinkIndexAtOffset(aCharIndex, &index);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return index;
 }
+}
+
+void
+hypertextInterfaceInitCB(AtkHypertextIface* aIface)
+{
+  NS_ASSERTION(aIface, "no interface!");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_link = getLinkCB;
+  aIface->get_n_links = getLinkCountCB;
+  aIface->get_link_index = getLinkIndexCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceHypertext.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_HYPERTEXT_H__
-#define __MAI_INTERFACE_HYPERTEXT_H__
-
-#include "nsMai.h"
-#include "nsMaiHyperlink.h"
-#include "nsIAccessibleHyperText.h"
-
-G_BEGIN_DECLS
-
-void hypertextInterfaceInitCB(AtkHypertextIface *aIface);
-
-/* hypertext interface callbacks */
-AtkHyperlink *getLinkCB(AtkHypertext *aText, gint aLinkIndex);
-gint getLinkCountCB(AtkHypertext *aText);
-gint getLinkIndexCB(AtkHypertext *aText, gint aCharIndex);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_HYPERTEXT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceImage.cpp
+++ b/accessible/src/atk/nsMaiInterfaceImage.cpp
@@ -32,57 +32,61 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceImage.h"
+#include "InterfaceInitFuncs.h"
 
 #include "nsAccessibleWrap.h"
 #include "nsHTMLImageAccessible.h"
-
-extern "C" const gchar* getDescriptionCB(AtkObject* aAtkObj);
-
-void
-imageInterfaceInitCB(AtkImageIface *aIface)
-{
-    g_return_if_fail(aIface != NULL);
+#include "nsMai.h"
 
-    aIface->get_image_position = getImagePositionCB;
-    aIface->get_image_description = getImageDescriptionCB;
-    aIface->get_image_size = getImageSizeCB;
+extern "C" {
+const gchar* getDescriptionCB(AtkObject* aAtkObj);
 
-}
-
-void
+static void
 getImagePositionCB(AtkImage *aImage, gint *aAccX, gint *aAccY,
                    AtkCoordType aCoordType)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
     if (!accWrap || !accWrap->IsImageAccessible())
       return;
 
     nsHTMLImageAccessible* image = accWrap->AsImage();
     PRUint32 geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
       nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
       nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
     // Returned in screen coordinates
     image->GetImagePosition(geckoCoordType, aAccX, aAccY);
 }
 
-const gchar *
+static const gchar*
 getImageDescriptionCB(AtkImage *aImage)
 {
    return getDescriptionCB(ATK_OBJECT(aImage));
 }
 
-void
+static void
 getImageSizeCB(AtkImage *aImage, gint *aAccWidth, gint *aAccHeight)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
     if (!accWrap || !accWrap->IsImageAccessible())
       return;
 
     accWrap->AsImage()->GetImageSize(aAccWidth, aAccHeight);
 }
+}
+
+void
+imageInterfaceInitCB(AtkImageIface* aIface)
+{
+  NS_ASSERTION(aIface, "no interface!");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_image_position = getImagePositionCB;
+  aIface->get_image_description = getImageDescriptionCB;
+  aIface->get_image_size = getImageSizeCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceImage.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2006
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Gao, Ming (gaoming@cn.ibm.com)
- *   Neo Liu(nian.liu@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_IMAGE_H__
-#define __MAI_INTERFACE_IMAGE_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleImage.h"
-
-G_BEGIN_DECLS
-
-void imageInterfaceInitCB(AtkImageIface *aIface);
-
-/* image interface callbacks */
-void getImagePositionCB(AtkImage *aImage,
-                        gint *aAccX,
-                        gint *aAccY,
-                        AtkCoordType aCoordType);
-const gchar* getImageDescriptionCB(AtkImage *aImage);
-void getImageSizeCB(AtkImage *aImage,
-                    gint *aAccWidth,
-                    gint *aAccHeight);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_DOCUMENT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceSelection.cpp
+++ b/accessible/src/atk/nsMaiInterfaceSelection.cpp
@@ -32,55 +32,46 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceSelection.h"
+#include "InterfaceInitFuncs.h"
 
-void
-selectionInterfaceInitCB(AtkSelectionIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
+#include "nsAccessibleWrap.h"
+#include "nsMai.h"
 
-    aIface->add_selection = addSelectionCB;
-    aIface->clear_selection = clearSelectionCB;
-    aIface->ref_selection = refSelectionCB;
-    aIface->get_selection_count = getSelectionCountCB;
-    aIface->is_child_selected = isChildSelectedCB;
-    aIface->remove_selection = removeSelectionCB;
-    aIface->select_all_selection = selectAllSelectionCB;
-}
+#include <atk/atk.h>
 
-gboolean
+extern "C" {
+
+static gboolean
 addSelectionCB(AtkSelection *aSelection, gint i)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->AddItemToSelection(i);
 }
 
-gboolean
+static gboolean
 clearSelectionCB(AtkSelection *aSelection)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->UnselectAll();
 }
 
-AtkObject *
+static AtkObject*
 refSelectionCB(AtkSelection *aSelection, gint i)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return nsnull;
 
     nsAccessible* selectedItem = accWrap->GetSelectedItem(i);
     if (!selectedItem)
@@ -88,47 +79,64 @@ refSelectionCB(AtkSelection *aSelection,
 
     AtkObject* atkObj = nsAccessibleWrap::GetAtkObject(selectedItem);
     if (atkObj) {
         g_object_ref(atkObj);
     }
     return atkObj;
 }
 
-gint
+static gint
 getSelectionCountCB(AtkSelection *aSelection)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return -1;
 
     return accWrap->SelectedItemCount();
 }
 
-gboolean
+static gboolean
 isChildSelectedCB(AtkSelection *aSelection, gint i)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->IsItemSelected(i);
 }
 
-gboolean
+static gboolean
 removeSelectionCB(AtkSelection *aSelection, gint i)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->RemoveItemFromSelection(i);
 }
 
-gboolean
+static gboolean
 selectAllSelectionCB(AtkSelection *aSelection)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->SelectAll();
 }
+}
+
+void
+selectionInterfaceInitCB(AtkSelectionIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->add_selection = addSelectionCB;
+  aIface->clear_selection = clearSelectionCB;
+  aIface->ref_selection = refSelectionCB;
+  aIface->get_selection_count = getSelectionCountCB;
+  aIface->is_child_selected = isChildSelectedCB;
+  aIface->remove_selection = removeSelectionCB;
+  aIface->select_all_selection = selectAllSelectionCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceSelection.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Silvia Zhao (silvia.zhao@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_SELECTION_H__
-#define __MAI_INTERFACE_SELECTION_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-/* selection interface callbacks */
-
-void selectionInterfaceInitCB(AtkSelectionIface *aIface);
-gboolean addSelectionCB(AtkSelection *aSelection, gint i);
-gboolean clearSelectionCB(AtkSelection *aSelection);
-AtkObject *refSelectionCB(AtkSelection *aSelection, gint i);
-gint getSelectionCountCB(AtkSelection *aSelection);
-gboolean isChildSelectedCB(AtkSelection *aSelection, gint i);
-gboolean removeSelectionCB(AtkSelection *aSelection, gint i);
-gboolean selectAllSelectionCB(AtkSelection *aSelection);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_SELECTION_H__ */
--- a/accessible/src/atk/nsMaiInterfaceTable.cpp
+++ b/accessible/src/atk/nsMaiInterfaceTable.cpp
@@ -32,51 +32,30 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceTable.h"
+#include "InterfaceInitFuncs.h"
 
+#include "nsAccessibleWrap.h"
 #include "nsAccUtils.h"
+#include "nsIAccessibleTable.h"
+#include "TableAccessible.h"
+#include "nsMai.h"
 
 #include "nsArrayUtils.h"
 
-void
-tableInterfaceInitCB(AtkTableIface *aIface)
-
-{
-    g_return_if_fail(aIface != NULL);
+using namespace mozilla::a11y;
 
-    aIface->ref_at = refAtCB;
-    aIface->get_index_at = getIndexAtCB;
-    aIface->get_column_at_index = getColumnAtIndexCB;
-    aIface->get_row_at_index = getRowAtIndexCB;
-    aIface->get_n_columns = getColumnCountCB;
-    aIface->get_n_rows = getRowCountCB;
-    aIface->get_column_extent_at = getColumnExtentAtCB;
-    aIface->get_row_extent_at = getRowExtentAtCB;
-    aIface->get_caption = getCaptionCB;
-    aIface->get_column_description = getColumnDescriptionCB;
-    aIface->get_column_header = getColumnHeaderCB;
-    aIface->get_row_description = getRowDescriptionCB;
-    aIface->get_row_header = getRowHeaderCB;
-    aIface->get_summary = getSummaryCB;
-    aIface->get_selected_columns = getSelectedColumnsCB;
-    aIface->get_selected_rows = getSelectedRowsCB;
-    aIface->is_column_selected = isColumnSelectedCB;
-    aIface->is_row_selected = isRowSelectedCB;
-    aIface->is_selected = isCellSelectedCB;
-}
-
-/* static */
-AtkObject*
+extern "C" {
+static AtkObject*
 refAtCB(AtkTable *aTable, gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -90,17 +69,17 @@ refAtCB(AtkTable *aTable, gint aRow, gin
 
     AtkObject *cellAtkObj = nsAccessibleWrap::GetAtkObject(cell);
     if (cellAtkObj) {
         g_object_ref(cellAtkObj);
     }
     return cellAtkObj;
 }
 
-gint
+static gint
 getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -109,17 +88,17 @@ getIndexAtCB(AtkTable *aTable, gint aRow
 
     PRInt32 index;
     nsresult rv = accTable->GetCellIndexAt(aRow, aColumn, &index);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(index);
 }
 
-gint
+static gint
 getColumnAtIndexCB(AtkTable *aTable, gint aIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -128,17 +107,17 @@ getColumnAtIndexCB(AtkTable *aTable, gin
 
     PRInt32 col;
     nsresult rv = accTable->GetColumnIndexAt(aIndex, &col);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(col);
 }
 
-gint
+static gint
 getRowAtIndexCB(AtkTable *aTable, gint aIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -147,17 +126,17 @@ getRowAtIndexCB(AtkTable *aTable, gint a
 
     PRInt32 row;
     nsresult rv = accTable->GetRowIndexAt(aIndex, &row);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(row);
 }
 
-gint
+static gint
 getColumnCountCB(AtkTable *aTable)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -166,17 +145,17 @@ getColumnCountCB(AtkTable *aTable)
 
     PRInt32 count;
     nsresult rv = accTable->GetColumnCount(&count);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(count);
 }
 
-gint
+static gint
 getRowCountCB(AtkTable *aTable)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -185,17 +164,17 @@ getRowCountCB(AtkTable *aTable)
 
     PRInt32 count;
     nsresult rv = accTable->GetRowCount(&count);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(count);
 }
 
-gint
+static gint
 getColumnExtentAtCB(AtkTable *aTable,
                     gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
@@ -205,17 +184,17 @@ getColumnExtentAtCB(AtkTable *aTable,
 
     PRInt32 extent;
     nsresult rv = accTable->GetColumnExtentAt(aRow, aColumn, &extent);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(extent);
 }
 
-gint
+static gint
 getRowExtentAtCB(AtkTable *aTable,
                  gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
@@ -225,37 +204,31 @@ getRowExtentAtCB(AtkTable *aTable,
 
     PRInt32 extent;
     nsresult rv = accTable->GetRowExtentAt(aRow, aColumn, &extent);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(extent);
 }
 
-AtkObject*
-getCaptionCB(AtkTable *aTable)
+static AtkObject*
+getCaptionCB(AtkTable* aTable)
 {
-    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
-    if (!accWrap)
-        return nsnull;
+  nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
+  if (!accWrap)
+    return nsnull;
 
-    nsCOMPtr<nsIAccessibleTable> accTable;
-    accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
-                            getter_AddRefs(accTable));
-    NS_ENSURE_TRUE(accTable, nsnull);
+  TableAccessible* table = accWrap->AsTable();
+  NS_ENSURE_TRUE(table, nsnull);
 
-    nsCOMPtr<nsIAccessible> caption;
-    nsresult rv = accTable->GetCaption(getter_AddRefs(caption));
-    if (NS_FAILED(rv) || !caption)
-        return nsnull;
-
-    return nsAccessibleWrap::GetAtkObject(caption);
+  nsAccessible* caption = table->Caption();
+  return caption ? nsAccessibleWrap::GetAtkObject(caption) : nsnull;
 }
 
-const gchar*
+static const gchar*
 getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -264,17 +237,17 @@ getColumnDescriptionCB(AtkTable *aTable,
 
     nsAutoString autoStr;
     nsresult rv = accTable->GetColumnDescription(aColumn, autoStr);
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     return nsAccessibleWrap::ReturnString(autoStr);
 }
 
-AtkObject*
+static AtkObject*
 getColumnHeaderCB(AtkTable *aTable, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -306,17 +279,17 @@ getColumnHeaderCB(AtkTable *aTable, gint
 
             return nsAccessibleWrap::GetAtkObject(accHeaderCell);
         }
     }
 
     return nsnull;
 }
 
-const gchar*
+static const gchar*
 getRowDescriptionCB(AtkTable *aTable, gint aRow)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -325,17 +298,17 @@ getRowDescriptionCB(AtkTable *aTable, gi
 
     nsAutoString autoStr;
     nsresult rv = accTable->GetRowDescription(aRow, autoStr);
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     return nsAccessibleWrap::ReturnString(autoStr);
 }
 
-AtkObject*
+static AtkObject*
 getRowHeaderCB(AtkTable *aTable, gint aRow)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -367,27 +340,27 @@ getRowHeaderCB(AtkTable *aTable, gint aR
 
         return nsAccessibleWrap::GetAtkObject(accHeaderCell);
       }
     }
 
     return nsnull;
 }
 
-AtkObject*
+static AtkObject*
 getSummaryCB(AtkTable *aTable)
 {
     // Neither html:table nor xul:tree nor ARIA grid/tree have an ability to
     // link an accessible object to specify a summary. There is closes method
     // in nsIAccessibleTable::summary to get a summary as a string which is not
     // mapped directly to ATK.
     return nsnull;
 }
 
-gint
+static gint
 getSelectedColumnsCB(AtkTable *aTable, gint **aSelected)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return 0;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -412,17 +385,17 @@ getSelectedColumnsCB(AtkTable *aTable, g
     for (PRUint32 index = 0; index < size; ++index)
         atkColumns[index] = static_cast<gint>(columns[index]);
     nsMemory::Free(columns);
 
     *aSelected = atkColumns;
     return size;
 }
 
-gint
+static gint
 getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return 0;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -447,58 +420,87 @@ getSelectedRowsCB(AtkTable *aTable, gint
     for (PRUint32 index = 0; index < size; ++index)
         atkRows[index] = static_cast<gint>(rows[index]);
     nsMemory::Free(rows);
 
     *aSelected = atkRows;
     return size;
 }
 
-gboolean
+static gboolean
 isColumnSelectedCB(AtkTable *aTable, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
                             getter_AddRefs(accTable));
     NS_ENSURE_TRUE(accTable, FALSE);
 
     bool outValue;
     nsresult rv = accTable->IsColumnSelected(aColumn, &outValue);
     return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
 }
 
-gboolean
+static gboolean
 isRowSelectedCB(AtkTable *aTable, gint aRow)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
                             getter_AddRefs(accTable));
     NS_ENSURE_TRUE(accTable, FALSE);
 
     bool outValue;
     nsresult rv = accTable->IsRowSelected(aRow, &outValue);
     return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
 }
 
-gboolean
+static gboolean
 isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
                             getter_AddRefs(accTable));
     NS_ENSURE_TRUE(accTable, FALSE);
 
     bool outValue;
     nsresult rv = accTable->IsCellSelected(aRow, aColumn, &outValue);
     return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
 }
+}
+
+void
+tableInterfaceInitCB(AtkTableIface* aIface)
+{
+  NS_ASSERTION(aIface, "no interface!");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->ref_at = refAtCB;
+  aIface->get_index_at = getIndexAtCB;
+  aIface->get_column_at_index = getColumnAtIndexCB;
+  aIface->get_row_at_index = getRowAtIndexCB;
+  aIface->get_n_columns = getColumnCountCB;
+  aIface->get_n_rows = getRowCountCB;
+  aIface->get_column_extent_at = getColumnExtentAtCB;
+  aIface->get_row_extent_at = getRowExtentAtCB;
+  aIface->get_caption = getCaptionCB;
+  aIface->get_column_description = getColumnDescriptionCB;
+  aIface->get_column_header = getColumnHeaderCB;
+  aIface->get_row_description = getRowDescriptionCB;
+  aIface->get_row_header = getRowHeaderCB;
+  aIface->get_summary = getSummaryCB;
+  aIface->get_selected_columns = getSelectedColumnsCB;
+  aIface->get_selected_rows = getSelectedRowsCB;
+  aIface->is_column_selected = isColumnSelectedCB;
+  aIface->is_row_selected = isRowSelectedCB;
+  aIface->is_selected = isCellSelectedCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceTable.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_TABLE_H__
-#define __MAI_INTERFACE_TABLE_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleTable.h"
-
-G_BEGIN_DECLS
-
-/* table interface callbacks */
-void tableInterfaceInitCB(AtkTableIface *aIface);
-AtkObject* refAtCB(AtkTable *aTable, gint aRow, gint aColumn);
-gint getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn);
-gint getColumnAtIndexCB(AtkTable *aTable, gint aIndex);
-gint getRowAtIndexCB(AtkTable *aTable, gint aIndex);
-gint getColumnCountCB(AtkTable *aTable);
-gint getRowCountCB(AtkTable *aTable);
-gint getColumnExtentAtCB(AtkTable *aTable, gint aRow, gint aColumn);
-gint getRowExtentAtCB(AtkTable *aTable, gint aRow, gint aColumn);
-AtkObject* getCaptionCB(AtkTable *aTable);
-const gchar* getColumnDescriptionCB(AtkTable *aTable, gint aColumn);
-AtkObject* getColumnHeaderCB(AtkTable *aTable, gint aColumn);
-const gchar* getRowDescriptionCB(AtkTable *aTable, gint aRow);
-AtkObject* getRowHeaderCB(AtkTable *aTable, gint aRow);
-AtkObject* getSummaryCB(AtkTable *aTable);
-gint getSelectedColumnsCB(AtkTable *aTable, gint **aSelected);
-gint getSelectedRowsCB(AtkTable *aTable, gint **aSelected);
-gboolean isColumnSelectedCB(AtkTable *aTable, gint aColumn);
-gboolean isRowSelectedCB(AtkTable *aTable, gint aRow);
-gboolean isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn);
-
-/* what are missing now for atk table */
-
-/* ==================================================
-   void              (* set_caption)              (AtkTable      *aTable,
-   AtkObject     *caption);
-   void              (* set_column_description)   (AtkTable      *aTable,
-   gint          aColumn,
-   const gchar   *description);
-   void              (* set_column_header)        (AtkTable      *aTable,
-   gint          aColumn,
-   AtkObject     *header);
-   void              (* set_row_description)      (AtkTable      *aTable,
-   gint          aRow,
-   const gchar   *description);
-   void              (* set_row_header)           (AtkTable      *aTable,
-   gint          aRow,
-   AtkObject     *header);
-   void              (* set_summary)              (AtkTable      *aTable,
-   AtkObject     *accessible);
-   gboolean          (* add_row_selection)        (AtkTable      *aTable,
-   gint          aRow);
-   gboolean          (* remove_row_selection)     (AtkTable      *aTable,
-   gint          aRow);
-   gboolean          (* add_column_selection)     (AtkTable      *aTable,
-   gint          aColumn);
-   gboolean          (* remove_column_selection)  (AtkTable      *aTable,
-   gint          aColumn);
-
-   ////////////////////////////////////////
-   // signal handlers
-   //
-   void              (* row_inserted)           (AtkTable      *aTable,
-   gint          aRow,
-   gint          num_inserted);
-   void              (* column_inserted)        (AtkTable      *aTable,
-   gint          aColumn,
-   gint          num_inserted);
-   void              (* row_deleted)              (AtkTable      *aTable,
-   gint          aRow,
-   gint          num_deleted);
-   void              (* column_deleted)           (AtkTable      *aTable,
-   gint          aColumn,
-   gint          num_deleted);
-   void              (* row_reordered)            (AtkTable      *aTable);
-   void              (* column_reordered)         (AtkTable      *aTable);
-   void              (* model_changed)            (AtkTable      *aTable);
-
-   * ==================================================
-   */
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_TABLE_H__ */
--- a/accessible/src/atk/nsMaiInterfaceText.cpp
+++ b/accessible/src/atk/nsMaiInterfaceText.cpp
@@ -33,66 +33,40 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceText.h"
+#include "InterfaceInitFuncs.h"
 
 #include "nsHyperTextAccessible.h"
+#include "nsMai.h"
 #include "nsRoleMap.h"
 
 #include "nsIPersistentProperties2.h"
 
 AtkAttributeSet* ConvertToAtkAttributeSet(nsIPersistentProperties* aAttributes);
 
-void
-textInterfaceInitCB(AtkTextIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
-
-    aIface->get_text = getTextCB;
-    aIface->get_text_after_offset = getTextAfterOffsetCB;
-    aIface->get_text_at_offset = getTextAtOffsetCB;
-    aIface->get_character_at_offset = getCharacterAtOffsetCB;
-    aIface->get_text_before_offset = getTextBeforeOffsetCB;
-    aIface->get_caret_offset = getCaretOffsetCB;
-    aIface->get_run_attributes = getRunAttributesCB;
-    aIface->get_default_attributes = getDefaultAttributesCB;
-    aIface->get_character_extents = getCharacterExtentsCB;
-    aIface->get_range_extents = getRangeExtentsCB;
-    aIface->get_character_count = getCharacterCountCB;
-    aIface->get_offset_at_point = getOffsetAtPointCB;
-    aIface->get_n_selections = getTextSelectionCountCB;
-    aIface->get_selection = getTextSelectionCB;
-
-    // set methods
-    aIface->add_selection = addTextSelectionCB;
-    aIface->remove_selection = removeTextSelectionCB;
-    aIface->set_selection = setTextSelectionCB;
-    aIface->set_caret_offset = setCaretOffsetCB;
-}
-
-
-void ConvertTexttoAsterisks(nsAccessibleWrap* accWrap, nsAString& aString)
+static void
+ConvertTexttoAsterisks(nsAccessibleWrap* accWrap, nsAString& aString)
 {
     // convert each char to "*" when it's "password text" 
     PRUint32 atkRole = atkRoleMap[accWrap->NativeRole()];
     if (atkRole == ATK_ROLE_PASSWORD_TEXT) {
         for (PRUint32 i = 0; i < aString.Length(); i++)
             aString.Replace(i, 1, NS_LITERAL_STRING("*"));
     }
 }
 
-gchar *
+extern "C" {
+
+static gchar*
 getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@@ -105,17 +79,17 @@ getTextCB(AtkText *aText, gint aStartOff
 
     ConvertTexttoAsterisks(accWrap, autoStr);
     NS_ConvertUTF16toUTF8 cautoStr(autoStr);
 
     //copy and return, libspi will free it.
     return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
 }
 
-gchar *
+static gchar*
 getTextAfterOffsetCB(AtkText *aText, gint aOffset,
                      AtkTextBoundary aBoundaryType,
                      gint *aStartOffset, gint *aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
@@ -134,17 +108,17 @@ getTextAfterOffsetCB(AtkText *aText, gin
 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     ConvertTexttoAsterisks(accWrap, autoStr);
     NS_ConvertUTF16toUTF8 cautoStr(autoStr);
     return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
 }
 
-gchar *
+static gchar*
 getTextAtOffsetCB(AtkText *aText, gint aOffset,
                   AtkTextBoundary aBoundaryType,
                   gint *aStartOffset, gint *aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
@@ -163,17 +137,17 @@ getTextAtOffsetCB(AtkText *aText, gint a
 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     ConvertTexttoAsterisks(accWrap, autoStr);
     NS_ConvertUTF16toUTF8 cautoStr(autoStr);
     return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
 }
 
-gunichar
+static gunichar
 getCharacterAtOffsetCB(AtkText *aText, gint aOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return 0;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@@ -189,17 +163,17 @@ getCharacterAtOffsetCB(AtkText *aText, g
     // convert char to "*" when it's "password text" 
     PRUint32 atkRole = atkRoleMap[accWrap->NativeRole()];
     if (atkRole == ATK_ROLE_PASSWORD_TEXT)
         uniChar = '*';
 
     return (NS_FAILED(rv)) ? 0 : static_cast<gunichar>(uniChar);
 }
 
-gchar *
+static gchar*
 getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
                       AtkTextBoundary aBoundaryType,
                       gint *aStartOffset, gint *aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
@@ -218,34 +192,34 @@ getTextBeforeOffsetCB(AtkText *aText, gi
 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     ConvertTexttoAsterisks(accWrap, autoStr);
     NS_ConvertUTF16toUTF8 cautoStr(autoStr);
     return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
 }
 
-gint
+static gint
 getCaretOffsetCB(AtkText *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return 0;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, 0);
 
     PRInt32 offset;
     nsresult rv = accText->GetCaretOffset(&offset);
     return (NS_FAILED(rv)) ? 0 : static_cast<gint>(offset);
 }
 
-AtkAttributeSet *
+static AtkAttributeSet*
 getRunAttributesCB(AtkText *aText, gint aOffset,
                    gint *aStartOffset,
                    gint *aEndOffset)
 {
     *aStartOffset = -1;
     *aEndOffset = -1;
 
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
@@ -265,17 +239,17 @@ getRunAttributesCB(AtkText *aText, gint 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     *aStartOffset = startOffset;
     *aEndOffset = endOffset;
 
     return ConvertToAtkAttributeSet(attributes);
 }
 
-AtkAttributeSet *
+static AtkAttributeSet*
 getDefaultAttributesCB(AtkText *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@@ -285,17 +259,17 @@ getDefaultAttributesCB(AtkText *aText)
     nsCOMPtr<nsIPersistentProperties> attributes;
     nsresult rv = accText->GetDefaultTextAttributes(getter_AddRefs(attributes));
     if (NS_FAILED(rv))
         return nsnull;
 
     return ConvertToAtkAttributeSet(attributes);
 }
 
-void
+static void
 getCharacterExtentsCB(AtkText *aText, gint aOffset,
                       gint *aX, gint *aY,
                       gint *aWidth, gint *aHeight,
                       AtkCoordType aCoords)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if(!accWrap || !aX || !aY || !aWidth || !aHeight)
         return;
@@ -324,17 +298,17 @@ getCharacterExtentsCB(AtkText *aText, gi
     *aX = extX;
     *aY = extY;
     *aWidth = extWidth;
     *aHeight = extHeight;
     NS_ASSERTION(NS_SUCCEEDED(rv),
                  "MaiInterfaceText::GetCharacterExtents, failed\n");
 }
 
-void
+static void
 getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
                   AtkCoordType aCoords, AtkTextRectangle *aRect)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if(!accWrap || !aRect)
         return;
 
     nsCOMPtr<nsIAccessibleText> accText;
@@ -362,29 +336,29 @@ getRangeExtentsCB(AtkText *aText, gint a
     aRect->x = extX;
     aRect->y = extY;
     aRect->width = extWidth;
     aRect->height = extHeight;
     NS_ASSERTION(NS_SUCCEEDED(rv),
                  "MaiInterfaceText::GetRangeExtents, failed\n");
 }
 
-gint
+static gint
 getCharacterCountCB(AtkText *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return 0;
 
     nsHyperTextAccessible* textAcc = accWrap->AsHyperText();
     return textAcc->IsDefunct() ?
         0 : static_cast<gint>(textAcc->CharacterCount());
 }
 
-gint
+static gint
 getOffsetAtPointCB(AtkText *aText,
                    gint aX, gint aY,
                    AtkCoordType aCoords)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return -1;
 
@@ -399,17 +373,17 @@ getOffsetAtPointCB(AtkText *aText,
         geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
     else
         geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
 
     accText->GetOffsetAtPoint(aX, aY, geckoCoordType, &offset);
     return static_cast<gint>(offset);
 }
 
-gint
+static gint
 getTextSelectionCountCB(AtkText *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@@ -417,17 +391,17 @@ getTextSelectionCountCB(AtkText *aText)
     NS_ENSURE_TRUE(accText, nsnull);
 
     PRInt32 selectionCount;
     nsresult rv = accText->GetSelectionCount(&selectionCount);
  
     return NS_FAILED(rv) ? 0 : selectionCount;
 }
 
-gchar *
+static gchar*
 getTextSelectionCB(AtkText *aText, gint aSelectionNum,
                    gint *aStartOffset, gint *aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleText> accText;
@@ -443,17 +417,17 @@ getTextSelectionCB(AtkText *aText, gint 
     *aEndOffset = endOffset;
 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     return getTextCB(aText, *aStartOffset, *aEndOffset);
 }
 
 // set methods
-gboolean
+static gboolean
 addTextSelectionCB(AtkText *aText,
                    gint aStartOffset,
                    gint aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
@@ -462,17 +436,17 @@ addTextSelectionCB(AtkText *aText,
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, FALSE);
 
     nsresult rv = accText->AddSelection(aStartOffset, aEndOffset);
 
     return NS_SUCCEEDED(rv) ? TRUE : FALSE;
 }
 
-gboolean
+static gboolean
 removeTextSelectionCB(AtkText *aText,
                       gint aSelectionNum)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleText> accText;
@@ -480,17 +454,17 @@ removeTextSelectionCB(AtkText *aText,
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, FALSE);
 
     nsresult rv = accText->RemoveSelection(aSelectionNum);
 
     return NS_SUCCEEDED(rv) ? TRUE : FALSE;
 }
 
-gboolean
+static gboolean
 setTextSelectionCB(AtkText *aText, gint aSelectionNum,
                    gint aStartOffset, gint aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleText> accText;
@@ -498,23 +472,53 @@ setTextSelectionCB(AtkText *aText, gint 
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, FALSE);
 
     nsresult rv = accText->SetSelectionBounds(aSelectionNum,
                                               aStartOffset, aEndOffset);
     return NS_SUCCEEDED(rv) ? TRUE : FALSE;
 }
 
-gboolean
+static gboolean
 setCaretOffsetCB(AtkText *aText, gint aOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, FALSE);
 
     nsresult rv = accText->SetCaretOffset(aOffset);
     return NS_SUCCEEDED(rv) ? TRUE : FALSE;
 }
+}
+
+void
+textInterfaceInitCB(AtkTextIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_text = getTextCB;
+  aIface->get_text_after_offset = getTextAfterOffsetCB;
+  aIface->get_text_at_offset = getTextAtOffsetCB;
+  aIface->get_character_at_offset = getCharacterAtOffsetCB;
+  aIface->get_text_before_offset = getTextBeforeOffsetCB;
+  aIface->get_caret_offset = getCaretOffsetCB;
+  aIface->get_run_attributes = getRunAttributesCB;
+  aIface->get_default_attributes = getDefaultAttributesCB;
+  aIface->get_character_extents = getCharacterExtentsCB;
+  aIface->get_range_extents = getRangeExtentsCB;
+  aIface->get_character_count = getCharacterCountCB;
+  aIface->get_offset_at_point = getOffsetAtPointCB;
+  aIface->get_n_selections = getTextSelectionCountCB;
+  aIface->get_selection = getTextSelectionCB;
+
+    // set methods
+  aIface->add_selection = addTextSelectionCB;
+  aIface->remove_selection = removeTextSelectionCB;
+  aIface->set_selection = setTextSelectionCB;
+  aIface->set_caret_offset = setCaretOffsetCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceText.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_TEXT_H__
-#define __MAI_INTERFACE_TEXT_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleText.h"
-
-G_BEGIN_DECLS
-
-void textInterfaceInitCB(AtkTextIface *aIface);
-
-/* text interface callbacks */
-gchar *getTextCB(AtkText *aText,
-                 gint aStartOffset, gint aEndOffset);
-gchar *getTextAfterOffsetCB(AtkText *aText, gint aOffset,
-                            AtkTextBoundary aBoundaryType,
-                            gint *aStartOffset, gint *aEndOffset);
-gchar *getTextAtOffsetCB(AtkText *aText, gint aOffset,
-                         AtkTextBoundary aBoundaryType,
-                         gint *aStartOffset, gint *aEndOffset);
-gunichar getCharacterAtOffsetCB(AtkText *aText, gint aOffset);
-gchar *getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
-                             AtkTextBoundary aBoundaryType,
-                             gint *aStartOffset, gint *aEndOffset);
-gint getCaretOffsetCB(AtkText *aText);
-AtkAttributeSet *getRunAttributesCB(AtkText *aText, gint aOffset,
-                                    gint *aStartOffset,
-                                    gint *aEndOffset);
-AtkAttributeSet* getDefaultAttributesCB(AtkText *aText);
-void getCharacterExtentsCB(AtkText *aText, gint aOffset,
-                           gint *aX, gint *aY,
-                           gint *aWidth, gint *aHeight,
-                           AtkCoordType aCoords);
-void getRangeExtentsCB(AtkText *aText, gint aStartOffset,
-                       gint aEndOffset, AtkCoordType aCoords,
-                       AtkTextRectangle *aRect);
-gint getCharacterCountCB(AtkText *aText);
-gint getOffsetAtPointCB(AtkText *aText,
-                        gint aX, gint aY,
-                        AtkCoordType aCoords);
-gint getTextSelectionCountCB(AtkText *aText);
-gchar *getTextSelectionCB(AtkText *aText, gint aSelectionNum,
-                          gint *aStartOffset, gint *aEndOffset);
-
-// set methods
-gboolean addTextSelectionCB(AtkText *aText,
-                            gint aStartOffset,
-                            gint aEndOffset);
-gboolean removeTextSelectionCB(AtkText *aText,
-                               gint aSelectionNum);
-gboolean setTextSelectionCB(AtkText *aText, gint aSelectionNum,
-                            gint aStartOffset, gint aEndOffset);
-gboolean setCaretOffsetCB(AtkText *aText, gint aOffset);
-
-/*************************************************
- // signal handlers
- //
-    void TextChangedCB(AtkText *aText, gint aPosition, gint aLength);
-    void TextCaretMovedCB(AtkText *aText, gint aLocation);
-    void TextSelectionChangedCB(AtkText *aText);
-*/
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_TEXT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceValue.cpp
+++ b/accessible/src/atk/nsMaiInterfaceValue.cpp
@@ -32,33 +32,24 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceValue.h"
-
-void
-valueInterfaceInitCB(AtkValueIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
+#include "InterfaceInitFuncs.h"
 
-    aIface->get_current_value = getCurrentValueCB;
-    aIface->get_maximum_value = getMaximumValueCB;
-    aIface->get_minimum_value = getMinimumValueCB;
-    aIface->get_minimum_increment = getMinimumIncrementCB;
-    aIface->set_current_value = setCurrentValueCB;
-}
+#include "nsAccessibleWrap.h"
+#include "nsMai.h"
 
-void
+extern "C" {
+
+static void
 getCurrentValueCB(AtkValue *obj, GValue *value)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
@@ -69,17 +60,17 @@ getCurrentValueCB(AtkValue *obj, GValue 
     memset (value,  0, sizeof (GValue));
     double accDouble;
     if (NS_FAILED(accValue->GetCurrentValue(&accDouble)))
         return;
     g_value_init (value, G_TYPE_DOUBLE);
     g_value_set_double (value, accDouble);
 }
 
-void
+static void
 getMaximumValueCB(AtkValue *obj, GValue *value)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
@@ -90,17 +81,17 @@ getMaximumValueCB(AtkValue *obj, GValue 
     memset (value,  0, sizeof (GValue));
     double accDouble;
     if (NS_FAILED(accValue->GetMaximumValue(&accDouble)))
         return;
     g_value_init (value, G_TYPE_DOUBLE);
     g_value_set_double (value, accDouble);
 }
 
-void
+static void
 getMinimumValueCB(AtkValue *obj, GValue *value)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
@@ -111,17 +102,17 @@ getMinimumValueCB(AtkValue *obj, GValue 
     memset (value,  0, sizeof (GValue));
     double accDouble;
     if (NS_FAILED(accValue->GetMinimumValue(&accDouble)))
         return;
     g_value_init (value, G_TYPE_DOUBLE);
     g_value_set_double (value, accDouble);
 }
 
-void
+static void
 getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
@@ -132,23 +123,38 @@ getMinimumIncrementCB(AtkValue *obj, GVa
     memset (minimumIncrement,  0, sizeof (GValue));
     double accDouble;
     if (NS_FAILED(accValue->GetMinimumIncrement(&accDouble)))
         return;
     g_value_init (minimumIncrement, G_TYPE_DOUBLE);
     g_value_set_double (minimumIncrement, accDouble);
 }
 
-gboolean
+static gboolean
 setCurrentValueCB(AtkValue *obj, const GValue *value)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
                             getter_AddRefs(accValue));
     NS_ENSURE_TRUE(accValue, FALSE);
 
     double accDouble =g_value_get_double (value);
     return !NS_FAILED(accValue->SetCurrentValue(accDouble));
 }
+}
+
+void
+valueInterfaceInitCB(AtkValueIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_current_value = getCurrentValueCB;
+  aIface->get_maximum_value = getMaximumValueCB;
+  aIface->get_minimum_value = getMinimumValueCB;
+  aIface->get_minimum_increment = getMinimumIncrementCB;
+  aIface->set_current_value = setCurrentValueCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceValue.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Silvia Zhao (silvia.zhao@sun.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __MAI_INTERFACE_VALUE_H__
-#define __MAI_INTERFACE_VALUE_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleValue.h"
-
-G_BEGIN_DECLS
-
-/*value interface callbacks*/
-void valueInterfaceInitCB(AtkValueIface *aIface);
-void getCurrentValueCB(AtkValue *obj, GValue *value);
-void getMaximumValueCB(AtkValue *obj, GValue *value);
-void getMinimumValueCB(AtkValue *obj, GValue *value);
-void getMinimumIncrementCB(AtkValue *obj, GValue *minIncrement);
-gboolean setCurrentValueCB(AtkValue *obj, const GValue *value);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_VALUE_H__ */
--- a/accessible/src/atk/nsRoleMap.h
+++ b/accessible/src/atk/nsRoleMap.h
@@ -165,11 +165,12 @@ static const PRUint32 atkRoleMap[] = {
     ATK_ROLE_LIST_ITEM,           // roles::OPTION               117
     ATK_ROLE_LIST_ITEM,           // roles::RICH_OPTION          118
     ATK_ROLE_LIST,                // roles::LISTBOX              119
     ATK_ROLE_UNKNOWN,             // roles::FLAT_EQUATION        120
     ATK_ROLE_TABLE_CELL,          // roles::GRID_CELL            121
     ATK_ROLE_PANEL,               // roles::EMBEDDED_OBJECT      122
     ATK_ROLE_SECTION,             // roles::NOTE                 123
     ATK_ROLE_PANEL,               // roles::FIGURE               124
+    ATK_ROLE_CHECK_BOX,           // roles::CHECK_RICH_OPTION    125
     kROLE_ATK_LAST_ENTRY          // roles::LAST_ENTRY
 };
 
--- a/accessible/src/atk/nsRootAccessibleWrap.cpp
+++ b/accessible/src/atk/nsRootAccessibleWrap.cpp
@@ -39,17 +39,21 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsMai.h"
 #include "nsRootAccessibleWrap.h"
 
 nsNativeRootAccessibleWrap::nsNativeRootAccessibleWrap(AtkObject *aAccessible):
     nsRootAccessible(nsnull, nsnull, nsnull)
 {
-    g_object_ref(aAccessible);
-    mAtkObject = aAccessible;
+  // XXX: mark the object as defunct to ensure no single internal method is
+  // running on it.
+  mFlags |= eIsDefunct;
+
+  g_object_ref(aAccessible);
+  mAtkObject = aAccessible;
 }
 
 nsNativeRootAccessibleWrap::~nsNativeRootAccessibleWrap()
 {
     g_object_unref(mAtkObject);
     mAtkObject = nsnull;
 }
--- a/accessible/src/base/AccEvent.cpp
+++ b/accessible/src/base/AccEvent.cpp
@@ -39,28 +39,28 @@
 
 #include "AccEvent.h"
 
 #include "nsAccessibilityService.h"
 #include "nsAccUtils.h"
 #include "nsApplicationAccessibleWrap.h"
 #include "nsDocAccessible.h"
 #include "nsIAccessibleText.h"
-#ifdef MOZ_XUL
-#include "nsXULTreeAccessible.h"
-#endif
 #include "nsAccEvent.h"
+#include "States.h"
 
 #include "nsIDOMDocument.h"
 #include "nsEventStateManager.h"
 #include "nsIServiceManager.h"
 #ifdef MOZ_XUL
 #include "nsIDOMXULMultSelectCntrlEl.h"
 #endif
 
+using namespace mozilla::a11y;
+
 ////////////////////////////////////////////////////////////////////////////////
 // AccEvent
 ////////////////////////////////////////////////////////////////////////////////
 
 ////////////////////////////////////////////////////////////////////////////////
 // AccEvent constructors
 
 AccEvent::AccEvent(PRUint32 aEventType, nsAccessible* aAccessible,
@@ -96,17 +96,20 @@ AccEvent::GetNode()
     mNode = mAccessible->GetNode();
 
   return mNode;
 }
 
 nsDocAccessible*
 AccEvent::GetDocAccessible()
 {
-  nsINode *node = GetNode();
+  if (mAccessible)
+    return mAccessible->Document();
+
+  nsINode* node = GetNode();
   if (node)
     return GetAccService()->GetDocAccessible(node->OwnerDoc());
 
   return nsnull;
 }
 
 already_AddRefed<nsAccEvent>
 AccEvent::CreateXPCOMObject()
@@ -249,16 +252,20 @@ AccTextChangeEvent::
   : AccEvent(aIsInserted ?
              static_cast<PRUint32>(nsIAccessibleEvent::EVENT_TEXT_INSERTED) :
              static_cast<PRUint32>(nsIAccessibleEvent::EVENT_TEXT_REMOVED),
              aAccessible, aIsFromUserInput, eAllowDupes)
   , mStart(aStart)
   , mIsInserted(aIsInserted)
   , mModifiedText(aModifiedText)
 {
+  // XXX We should use IsFromUserInput here, but that isn't always correct
+  // when the text change isn't related to content insertion or removal.
+   mIsFromUserInput = mAccessible->State() &
+    (states::FOCUSED | states::EDITABLE);
 }
 
 already_AddRefed<nsAccEvent>
 AccTextChangeEvent::CreateXPCOMObject()
 {
   nsAccEvent* event = new nsAccTextChangeEvent(this);
   NS_IF_ADDREF(event);
   return event;
--- a/accessible/src/base/AccGroupInfo.h
+++ b/accessible/src/base/AccGroupInfo.h
@@ -62,16 +62,18 @@ public:
     mozilla::a11y::role role = aAccessible->Role();
     if (role != mozilla::a11y::roles::ROW &&
         role != mozilla::a11y::roles::GRID_CELL &&
         role != mozilla::a11y::roles::OUTLINEITEM &&
         role != mozilla::a11y::roles::OPTION &&
         role != mozilla::a11y::roles::LISTITEM &&
         role != mozilla::a11y::roles::MENUITEM &&
         role != mozilla::a11y::roles::COMBOBOX_OPTION &&
+        role != mozilla::a11y::roles::RICH_OPTION &&
+        role != mozilla::a11y::roles::CHECK_RICH_OPTION &&
         role != mozilla::a11y::roles::PARENT_MENUITEM &&
         role != mozilla::a11y::roles::CHECK_MENU_ITEM &&
         role != mozilla::a11y::roles::RADIO_MENU_ITEM &&
         role != mozilla::a11y::roles::RADIOBUTTON &&
         role != mozilla::a11y::roles::PAGETAB)
       return nsnull;
 
     AccGroupInfo* info = new AccGroupInfo(aAccessible, BaseRole(role));
@@ -83,16 +85,20 @@ private:
   AccGroupInfo& operator =(const AccGroupInfo&);
 
   static mozilla::a11y::role BaseRole(mozilla::a11y::role aRole)
   {
     if (aRole == mozilla::a11y::roles::CHECK_MENU_ITEM ||
         aRole == mozilla::a11y::roles::PARENT_MENUITEM ||
         aRole == mozilla::a11y::roles::RADIO_MENU_ITEM)
       return mozilla::a11y::roles::MENUITEM;
+
+    if (aRole == mozilla::a11y::roles::CHECK_RICH_OPTION)
+      return mozilla::a11y::roles::RICH_OPTION;
+
     return aRole;
   }
 
   /**
    * Return true if the given parent role is conceptual parent of the given
    * role.
    */
   static bool IsConceptualParent(mozilla::a11y::role aRole,
--- a/accessible/src/base/AccIterator.cpp
+++ b/accessible/src/base/AccIterator.cpp
@@ -272,18 +272,20 @@ XULDescriptionIterator::Next()
 
   return nsnull;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // IDRefsIterator
 ////////////////////////////////////////////////////////////////////////////////
 
-IDRefsIterator::IDRefsIterator(nsIContent* aContent, nsIAtom* aIDRefsAttr) :
-  mCurrIdx(0), mContent(aContent)
+IDRefsIterator::
+  IDRefsIterator(nsDocAccessible* aDoc, nsIContent* aContent,
+                 nsIAtom* aIDRefsAttr) :
+  mCurrIdx(0), mContent(aContent), mDoc(aDoc)
 {
   if (mContent->IsInDoc())
     mContent->GetAttr(kNameSpaceID_None, aIDRefsAttr, mIDs);
 }
 
 const nsDependentSubstring
 IDRefsIterator::NextID()
 {
@@ -363,17 +365,17 @@ IDRefsIterator::GetElem(const nsDependen
 
   return nsnull;
 }
 
 nsAccessible*
 IDRefsIterator::Next()
 {
   nsIContent* nextElm = NextElem();
-  return nextElm ? GetAccService()->GetAccessible(nextElm, nsnull) : nsnull;
+  return nextElm ? mDoc->GetAccessible(nextElm) : nsnull;
 }
 
 nsAccessible*
 SingleAccIterator::Next()
 {
   nsRefPtr<nsAccessible> nextAcc;
   mAcc.swap(nextAcc);
   return (nextAcc && !nextAcc->IsDefunct()) ? nextAcc : nsnull;
--- a/accessible/src/base/AccIterator.h
+++ b/accessible/src/base/AccIterator.h
@@ -259,17 +259,18 @@ private:
 /**
  * Used to iterate through IDs, elements or accessibles pointed by IDRefs
  * attribute. Note, any method used to iterate through IDs, elements, or
  * accessibles moves iterator to next position.
  */
 class IDRefsIterator : public AccIterable
 {
 public:
-  IDRefsIterator(nsIContent* aContent, nsIAtom* aIDRefsAttr);
+  IDRefsIterator(nsDocAccessible* aDoc, nsIContent* aContent,
+                 nsIAtom* aIDRefsAttr);
   virtual ~IDRefsIterator() { }
 
   /**
    * Return next ID.
    */
   const nsDependentSubstring NextID();
 
   /**
@@ -287,16 +288,17 @@ public:
 
 private:
   IDRefsIterator();
   IDRefsIterator(const IDRefsIterator&);
   IDRefsIterator operator = (const IDRefsIterator&);
 
   nsString mIDs;
   nsIContent* mContent;
+  nsDocAccessible* mDoc;
   nsAString::index_type mCurrIdx;
 };
 
 /**
  * Iterator that points to a single accessible returning it on the first call
  * to Next().
  */
 class SingleAccIterator : public AccIterable
--- a/accessible/src/base/Makefile.in
+++ b/accessible/src/base/Makefile.in
@@ -99,18 +99,19 @@ EXPORTS_mozilla/a11y = \
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES += \
   -I$(srcdir) \
+  -I$(srcdir)/../generic \
+  -I$(srcdir)/../html \
   -I$(srcdir)/../xpcom \
-  -I$(srcdir)/../html \
   -I$(srcdir)/../xul \
   -I$(srcdir)/../../../layout/generic \
   -I$(srcdir)/../../../layout/style \
   -I$(srcdir)/../../../layout/xul/base/src \
   -I$(srcdir)/../xforms \
   $(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
--- a/accessible/src/base/Role.h
+++ b/accessible/src/base/Role.h
@@ -785,19 +785,24 @@ namespace roles {
   NOTE = 123,
 
   /**
    * A figure. Used for things like HTML5 figure element.
    */
   FIGURE = 124,
 
   /**
+   * Represents a rich item with a check box.
+   */
+  CHECK_RICH_OPTION = 125,
+
+  /**
    * It's not role actually. This constant is important to help ensure
    * nsRoleMap's are synchronized.
    */
-  LAST_ENTRY = 125
+  LAST_ENTRY = 126
   };
 } // namespace role
 typedef enum mozilla::a11y::roles::Role role;
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/src/base/nsARIAGridAccessible.cpp
+++ b/accessible/src/base/nsARIAGridAccessible.cpp
@@ -53,42 +53,39 @@ using namespace mozilla::a11y;
 ////////////////////////////////////////////////////////////////////////////////
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // Constructor
 
 nsARIAGridAccessible::
   nsARIAGridAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
-  nsAccessibleWrap(aContent, aDoc)
+  nsAccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupports
 
 NS_IMPL_ISUPPORTS_INHERITED1(nsARIAGridAccessible,
                              nsAccessible,
                              nsIAccessibleTable)
 
 ////////////////////////////////////////////////////////////////////////////////
-// nsIAccessibleTable
+//nsAccessNode
 
-NS_IMETHODIMP
-nsARIAGridAccessible::GetCaption(nsIAccessible **aCaption)
+void
+nsARIAGridAccessible::Shutdown()
 {
-  NS_ENSURE_ARG_POINTER(aCaption);
-  *aCaption = nsnull;
+  mTable = nsnull;
+  nsAccessibleWrap::Shutdown();
+}
 
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  // XXX: should be pointed by aria-labelledby on grid?
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
+////////////////////////////////////////////////////////////////////////////////
+// nsIAccessibleTable
 
 NS_IMETHODIMP
 nsARIAGridAccessible::GetSummary(nsAString &aSummary)
 {
   aSummary.Truncate();
 
   if (IsDefunct())
     return NS_ERROR_FAILURE;
@@ -705,25 +702,16 @@ nsARIAGridAccessible::UnselectColumn(PRI
       nsresult rv = SetARIASelected(cell, false);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsARIAGridAccessible::IsProbablyForLayout(bool *aIsProbablyForLayout)
-{
-  NS_ENSURE_ARG_POINTER(aIsProbablyForLayout);
-  *aIsProbablyForLayout = false;
-
-  return NS_OK;
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // Protected
 
 bool
 nsARIAGridAccessible::IsValidRow(PRInt32 aRow)
 {
   if (aRow < 0)
     return false;
--- a/accessible/src/base/nsARIAGridAccessible.h
+++ b/accessible/src/base/nsARIAGridAccessible.h
@@ -37,31 +37,41 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsARIAGridAccessible_h_
 #define nsARIAGridAccessible_h_
 
 #include "nsIAccessibleTable.h"
 
 #include "nsHyperTextAccessibleWrap.h"
+#include "TableAccessible.h"
+#include "xpcAccessibleTable.h"
 
 /**
  * Accessible for ARIA grid and treegrid.
  */
 class nsARIAGridAccessible : public nsAccessibleWrap,
-                             public nsIAccessibleTable
+                             public xpcAccessibleTable,
+                             public nsIAccessibleTable,
+                             public mozilla::a11y::TableAccessible
 {
 public:
   nsARIAGridAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIAccessibleTable
-  NS_DECL_NSIACCESSIBLETABLE
+  NS_DECL_OR_FORWARD_NSIACCESSIBLETABLE_WITH_XPCACCESSIBLETABLE
+
+  // nsAccessible
+  virtual mozilla::a11y::TableAccessible* AsTable() { return this; }
+
+  // nsAccessNode
+  virtual void Shutdown();
 
 protected:
   /**
    * Return true if the given row index is valid.
    */
   bool IsValidRow(PRInt32 aRow);
 
   /**
--- a/accessible/src/base/nsARIAMap.cpp
+++ b/accessible/src/base/nsARIAMap.cpp
@@ -168,16 +168,25 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] 
     kUseMapRole,
     eNoValue,
     eNoAction,
     eNoLiveAttr,
     kNoReqStates,
     eReadonlyUntilEditable
   },
   {
+    "form",
+    roles::FORM,
+    kUseMapRole,
+    eNoValue,
+    eNoAction,
+    eNoLiveAttr,
+    kNoReqStates
+  },
+  {
     "grid",
     roles::TABLE,
     kUseMapRole,
     eNoValue,
     eNoAction,
     eNoLiveAttr,
     states::FOCUSABLE,
     eARIAMultiSelectable,
@@ -331,16 +340,25 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] 
     kUseMapRole,
     eNoValue,
     eClickAction,
     eNoLiveAttr,
     kNoReqStates,
     eARIACheckableBool
   },
   {
+    "note",
+    roles::NOTE,
+    kUseMapRole,
+    eNoValue,
+    eNoAction,
+    eNoLiveAttr,
+    kNoReqStates
+  },
+  {
     "option",
     roles::OPTION,
     kUseMapRole,
     eNoValue,
     eSelectAction,
     eNoLiveAttr,
     kNoReqStates,
     eARIASelectable,
--- a/accessible/src/base/nsAccCache.h
+++ b/accessible/src/base/nsAccCache.h
@@ -59,21 +59,21 @@ ClearCacheEntry(const void* aKey, nsRefP
     aAccessible->Shutdown();
 
   return PL_DHASH_REMOVE;
 }
 
 /**
  * Clear the cache and shutdown the accessibles.
  */
-template <class T>
+
 static void
-ClearCache(nsRefPtrHashtable<nsVoidPtrHashKey, T> & aCache)
+ClearCache(nsAccessibleHashtable & aCache)
 {
-  aCache.Enumerate(ClearCacheEntry<T>, nsnull);
+  aCache.Enumerate(ClearCacheEntry<nsAccessible>, nsnull);
 }
 
 /**
  * Traverse the accessible cache entry for cycle collector.
  */
 template <class T>
 static PLDHashOperator
 CycleCollectorTraverseCacheEntry(const void *aKey, T *aAccessible,
@@ -87,17 +87,17 @@ CycleCollectorTraverseCacheEntry(const v
   nsISupports *supports = static_cast<nsIAccessible*>(aAccessible);
   cb->NoteXPCOMChild(supports);
   return PL_DHASH_NEXT;
 }
 
 /**
  * Traverse the accessible cache for cycle collector.
  */
-template <class T>
+
 static void
-CycleCollectorTraverseCache(nsRefPtrHashtable<nsVoidPtrHashKey, T> & aCache,
+CycleCollectorTraverseCache(nsAccessibleHashtable & aCache,
                             nsCycleCollectionTraversalCallback *aCallback)
 {
-  aCache.EnumerateRead(CycleCollectorTraverseCacheEntry<T>, aCallback);
+  aCache.EnumerateRead(CycleCollectorTraverseCacheEntry<nsAccessible>, aCallback);
 }
 
 #endif
--- a/accessible/src/base/nsAccUtils.cpp
+++ b/accessible/src/base/nsAccUtils.cpp
@@ -42,19 +42,17 @@
 #include "nsIAccessibleTypes.h"
 #include "Role.h"
 #include "States.h"
 
 #include "nsAccessibilityService.h"
 #include "nsARIAMap.h"
 #include "nsDocAccessible.h"
 #include "nsHyperTextAccessible.h"
-#include "nsHTMLTableAccessible.h"
 #include "nsTextAccessible.h"
-#include "nsXULTreeGridAccessible.h"
 
 #include "nsIDOMXULContainerElement.h"
 #include "nsIDOMXULSelectCntrlEl.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsWhitespaceTokenizer.h"
 #include "nsComponentManagerUtils.h"
 
 namespace dom = mozilla::dom;
@@ -129,57 +127,16 @@ nsAccUtils::GetARIAOrDefaultLevel(nsAcce
                            nsGkAtoms::aria_level, &level);
 
   if (level != 0)
     return level;
 
   return GetDefaultLevel(aAccessible);
 }
 
-void
-nsAccUtils::GetPositionAndSizeForXULSelectControlItem(nsIContent *aContent,
-                                                      PRInt32 *aPosInSet,
-                                                      PRInt32 *aSetSize)
-{
-  nsCOMPtr<nsIDOMXULSelectControlItemElement> item(do_QueryInterface(aContent));
-  if (!item)
-    return;
-
-  nsCOMPtr<nsIDOMXULSelectControlElement> control;
-  item->GetControl(getter_AddRefs(control));
-  if (!control)
-    return;
-
-  PRUint32 itemsCount = 0;
-  control->GetItemCount(&itemsCount);
-
-  PRInt32 indexOf = 0;
-  control->GetIndexOfItem(item, &indexOf);
-
-  *aSetSize = itemsCount;
-  *aPosInSet = indexOf;
-
-  for (PRUint32 index = 0; index < itemsCount; index++) {
-    nsCOMPtr<nsIDOMXULSelectControlItemElement> currItem;
-    control->GetItemAtIndex(index, getter_AddRefs(currItem));
-    nsCOMPtr<nsINode> currNode(do_QueryInterface(currItem));
-
-    nsAccessible* itemAcc = currNode ?
-      GetAccService()->GetAccessible(currNode, nsnull) : nsnull;
-
-    if (!itemAcc || itemAcc->State() & states::INVISIBLE) {
-      (*aSetSize)--;
-      if (index < static_cast<PRUint32>(indexOf))
-        (*aPosInSet)--;
-    }
-  }
-
-  (*aPosInSet)++; // group position is 1-index based.
-}
-
 PRInt32
 nsAccUtils::GetLevelForXULContainerItem(nsIContent *aContent)
 {
   nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aContent));
   if (!item)
     return 0;
 
   nsCOMPtr<nsIDOMXULContainerElement> container;
--- a/accessible/src/base/nsAccUtils.h
+++ b/accessible/src/base/nsAccUtils.h
@@ -103,24 +103,16 @@ public:
 
   /**
    * Return ARIA level value or the default one if ARIA is missed for the
    * given accessible.
    */
   static PRInt32 GetARIAOrDefaultLevel(nsAccessible *aAccessible);
 
   /**
-   * Compute position in group (posinset) and group size (setsize) for
-   * nsIDOMXULSelectControlItemElement node.
-   */
-  static void GetPositionAndSizeForXULSelectControlItem(nsIContent *aContent,
-                                                        PRInt32 *aPosInSet,
-                                                        PRInt32 *aSetSize);
-
-  /**
    * Compute group level for nsIDOMXULContainerItemElement node.
    */
   static PRInt32 GetLevelForXULContainerItem(nsIContent *aContent);
 
   /**
    * Set container-foo live region attributes for the given node.
    *
    * @param aAttributes    where to store the attributes
--- a/accessible/src/base/nsAccessNode.cpp
+++ b/accessible/src/base/nsAccessNode.cpp
@@ -112,22 +112,16 @@ void nsAccessNode::LastRelease()
   // ... then die.
   delete this;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessNode public
 
 bool
-nsAccessNode::IsDefunct() const
-{
-  return !mContent;
-}
-
-bool
 nsAccessNode::Init()
 {
   return true;
 }
 
 
 void
 nsAccessNode::Shutdown()
@@ -213,17 +207,17 @@ void nsAccessNode::ShutdownXPAccessibili
   }
 
   NotifyA11yInitOrShutdown(false);
 }
 
 // nsAccessNode protected
 nsPresContext* nsAccessNode::GetPresContext()
 {
-  if (IsDefunct())
+  if (!mDoc)
     return nsnull;
 
   nsIPresShell* presShell(mDoc->PresShell());
 
   return presShell ? presShell->GetPresContext() : nsnull;
 }
 
 nsRootAccessible*
@@ -257,43 +251,43 @@ nsAccessNode::IsPrimaryForNode() const
 {
   return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void
 nsAccessNode::ScrollTo(PRUint32 aScrollType)
 {
-  if (IsDefunct())
+  if (!mDoc)
     return;
 
   nsIPresShell* shell = mDoc->PresShell();
   if (!shell)
     return;
 
   nsIFrame *frame = GetFrame();
   if (!frame)
     return;
 
   nsIContent* content = frame->GetContent();
   if (!content)
     return;
 
-  PRInt16 vPercent, hPercent;
-  nsCoreUtils::ConvertScrollTypeToPercents(aScrollType, &vPercent, &hPercent);
-  shell->ScrollContentIntoView(content, vPercent, hPercent,
+  nsIPresShell::ScrollAxis vertical, horizontal;
+  nsCoreUtils::ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
+  shell->ScrollContentIntoView(content, vertical, horizontal,
                                nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 }
 
 void
 nsAccessNode::Language(nsAString& aLanguage)
 {
   aLanguage.Truncate();
 
-  if (IsDefunct())
+  if (!mDoc)
     return;
 
   nsCoreUtils::GetLanguageFor(mContent, nsnull, aLanguage);
   if (aLanguage.IsEmpty()) { // Nothing found, so use document's language
     mContent->OwnerDoc()->GetHeaderData(nsGkAtoms::headerContentLanguage,
                                         aLanguage);
   }
 }
--- a/accessible/src/base/nsAccessNode.h
+++ b/accessible/src/base/nsAccessNode.h
@@ -101,21 +101,16 @@ public:
   virtual bool Init();
 
   /**
    * Shutdown the access node object.
    */
   virtual void Shutdown();
 
   /**
-   * Returns true when the accessible is defunct.
-   */
-  virtual bool IsDefunct() const;
-
-  /**
    * Return frame for the given access node object.
    */
   virtual nsIFrame* GetFrame() const;
   /**
    * Return DOM node associated with the accessible.
    */
   virtual nsINode* GetNode() const { return mContent; }
   nsIContent* GetContent() const { return mContent; }
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -592,16 +592,32 @@ nsAccessibilityService::UpdateText(nsIPr
                                    nsIContent* aContent)
 {
   nsDocAccessible* document = GetDocAccessible(aPresShell->GetDocument());
   if (document)
     document->UpdateText(aContent);
 }
 
 void
+nsAccessibilityService::TreeViewChanged(nsIPresShell* aPresShell,
+                                        nsIContent* aContent,
+                                        nsITreeView* aView)
+{
+  nsDocAccessible* document = GetDocAccessible(aPresShell->GetDocument());
+  if (document) {
+    nsAccessible* accessible = document->GetAccessible(aContent);
+    if (accessible) {
+      nsRefPtr<nsXULTreeAccessible> treeAcc = do_QueryObject(accessible);
+      if (treeAcc) 
+        treeAcc->TreeViewChanged(aView);
+    }
+  }
+}
+
+void
 nsAccessibilityService::UpdateListBullet(nsIPresShell* aPresShell,
                                          nsIContent* aHTMLListItemContent,
                                          bool aHasBullet)
 {
   nsDocAccessible* document = GetDocAccessible(aPresShell->GetDocument());
   if (document) {
     nsAccessible* accessible = document->GetAccessible(aHTMLListItemContent);
     if (accessible) {
@@ -671,20 +687,18 @@ nsAccessibilityService::PresShellActivat
   }
 }
 
 void
 nsAccessibilityService::RecreateAccessible(nsIPresShell* aPresShell,
                                            nsIContent* aContent)
 {
   nsDocAccessible* document = GetDocAccessible(aPresShell->GetDocument());
-  if (document) {
-    document->HandleNotification<nsDocAccessible, nsIContent>
-      (document, &nsDocAccessible::RecreateAccessible, aContent);
-  }
+  if (document)
+    document->RecreateAccessible(aContent);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIAccessibleRetrieval
 
 NS_IMETHODIMP
 nsAccessibilityService::GetApplicationAccessible(nsIAccessible **aAccessibleApplication)
 {
--- a/accessible/src/base/nsAccessibilityService.h
+++ b/accessible/src/base/nsAccessibilityService.h
@@ -44,16 +44,17 @@
 #include "a11yGeneric.h"
 #include "nsAccDocManager.h"
 
 #include "mozilla/a11y/FocusManager.h"
 
 #include "nsIObserver.h"
 
 class nsImageFrame;
+class nsITreeView;
 
 namespace mozilla {
 namespace a11y {
 
 /**
  * Return focus manager.
  */
 FocusManager* FocusMgr();
@@ -88,76 +89,82 @@ public:
   NS_DECL_NSIACCESSIBLERETRIEVAL
   NS_DECL_NSIOBSERVER
 
   // nsIAccessibilityService
   virtual nsAccessible* GetRootDocumentAccessible(nsIPresShell* aPresShell,
                                                   bool aCanCreate);
   already_AddRefed<nsAccessible>
     CreateHTMLButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLBRAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
     CreateHTMLCanvasAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLCaptionAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLCheckboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLComboboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
     CreateHTMLFileInputAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLGroupboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLHRAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLImageAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
   already_AddRefed<nsAccessible>
     CreateHTMLImageMapAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLLabelAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLLIAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLListboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLMediaAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLObjectFrameAccessible(nsObjectFrame* aFrame, nsIContent* aContent,
                                     nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLRadioButtonAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLTableAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLTableCellAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLTextAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHTMLTextFieldAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateHyperTextAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
-  virtual already_AddRefed<nsAccessible>
+  already_AddRefed<nsAccessible>
     CreateOuterDocAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
 
   virtual nsAccessible* AddNativeRootAccessible(void* aAtkAccessible);
   virtual void RemoveNativeRootAccessible(nsAccessible* aRootAccessible);
 
   virtual void ContentRangeInserted(nsIPresShell* aPresShell,
                                     nsIContent* aContainer,
                                     nsIContent* aStartChild,
                                     nsIContent* aEndChild);
 
   virtual void ContentRemoved(nsIPresShell* aPresShell, nsIContent* aContainer,
                               nsIContent* aChild);
 
   virtual void UpdateText(nsIPresShell* aPresShell, nsIContent* aContent);
 
   /**
+   * Update XUL:tree accessible tree when treeview is changed.
+   */
+  void TreeViewChanged(nsIPresShell* aPresShell, nsIContent* aContent,
+                       nsITreeView* aView);
+
+  /**
    * Update list bullet accessible.
    */
   virtual void UpdateListBullet(nsIPresShell* aPresShell,
                                 nsIContent* aHTMLListItemContent,
                                 bool aHasBullet);
 
   /**
    * Update the image map.
@@ -168,18 +175,20 @@ public:
 
   virtual void PresShellDestroyed(nsIPresShell* aPresShell);
 
   /**
    * Notify that presshell is activated.
    */
   virtual void PresShellActivated(nsIPresShell* aPresShell);
 
-  virtual void RecreateAccessible(nsIPresShell* aPresShell,
-                                  nsIContent* aContent);
+  /**
+   * Recreate an accessible for the given content node in the presshell.
+   */
+  void RecreateAccessible(nsIPresShell* aPresShell, nsIContent* aContent);
 
   virtual void FireAccessibleEvent(PRUint32 aEvent, nsAccessible* aTarget);
 
   // nsAccessibiltiyService
 
   /**
    * Return true if accessibility service has been shutdown.
    */
@@ -408,17 +417,18 @@ static const char kRoleNames[][20] = {
   "image map",           //ROLE_IMAGE_MAP
   "listbox option",      //ROLE_OPTION
   "listbox rich option", //ROLE_RICH_OPTION
   "listbox",             //ROLE_LISTBOX
   "flat equation",       //ROLE_FLAT_EQUATION
   "gridcell",            //ROLE_GRID_CELL
   "embedded object",     //ROLE_EMBEDDED_OBJECT
   "note",                //ROLE_NOTE
-  "figure"               //ROLE_FIGURE
+  "figure",              //ROLE_FIGURE
+  "check rich option"    //ROLE_CHECK_RICH_OPTION
 };
 
 /**
  * Map nsIAccessibleEvents constants to strings. Used by
  * nsIAccessibleRetrieval::getStringEventType() method.
  */
 static const char kEventTypeNames[][40] = {
   "unknown",                                 //
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -259,27 +259,16 @@ nsAccessible::GetRootDocument(nsIAccessi
   NS_ENSURE_ARG_POINTER(aRootDocument);
 
   nsRootAccessible* rootDocument = RootAccessible();
   NS_IF_ADDREF(*aRootDocument = rootDocument);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsAccessible::GetInnerHTML(nsAString& aInnerHTML)
-{
-  aInnerHTML.Truncate();
-
-  nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mContent);
-  NS_ENSURE_TRUE(htmlElement, NS_ERROR_NULL_POINTER);
-
-  return htmlElement->GetInnerHTML(aInnerHTML);
-}
-
-NS_IMETHODIMP
 nsAccessible::GetLanguage(nsAString& aLanguage)
 {
   Language(aLanguage);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAccessible::GetName(nsAString& aName)
@@ -1347,48 +1336,45 @@ nsAccessible::GetAttributes(nsIPersisten
   }
 
   return NS_OK;
 }
 
 nsresult
 nsAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
 {
+  // If the accessible isn't primary for its node (such as list item bullet or
+  // xul tree item then don't calculate content based attributes.
+  if (!IsPrimaryForNode())
+    return NS_OK;
+
   // Attributes set by this method will not be used to override attributes on a sub-document accessible
   // when there is a <frame>/<iframe> element that spawned the sub-document
-  nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mContent));
-
-  nsAutoString tagName;
-  element->GetTagName(tagName);
-  if (!tagName.IsEmpty()) {
-    nsAutoString oldValueUnused;
-    aAttributes->SetStringProperty(NS_LITERAL_CSTRING("tag"), tagName,
-                                   oldValueUnused);
-  }
 
   nsEventShell::GetEventAttributes(GetNode(), aAttributes);
  
   // Expose class because it may have useful microformat information
   // Let the class from an iframe's document be exposed, don't override from <iframe class>
   nsAutoString _class;
   if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::_class, _class))
     nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::_class, _class);
 
   // Get container-foo computed live region properties based on the closest container with
   // the live region attribute. 
   // Inner nodes override outer nodes within the same document --
   //   The inner nodes can be used to override live region behavior on more general outer nodes
   // However, nodes in outer documents override nodes in inner documents:
   //   Outer doc author may want to override properties on a widget they used in an iframe
-  nsIContent *startContent = mContent;
-  while (true) {
-    NS_ENSURE_STATE(startContent);
-    nsIDocument *doc = startContent->GetDocument();
+  nsIContent* startContent = mContent;
+  while (startContent) {
+    nsIDocument* doc = startContent->GetDocument();
     nsIContent* rootContent = nsCoreUtils::GetRoleContent(doc);
-    NS_ENSURE_STATE(rootContent);
+    if (!rootContent)
+      return NS_OK;
+
     nsAccUtils::SetLiveContainerAttributes(aAttributes, startContent,
                                            rootContent);
 
     // Allow ARIA live region markup from outer documents to override
     nsCOMPtr<nsISupports> container = doc->GetContainer(); 
     nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
       do_QueryInterface(container);
     if (!docShellTreeItem)
@@ -1404,31 +1390,35 @@ nsAccessible::GetAttributesInternal(nsIP
       break;
 
     startContent = parentDoc->FindContentForSubDocument(doc);      
   }
 
   if (!mContent->IsElement())
     return NS_OK;
 
+  // Expose tag.
+  nsAutoString tagName;
+  mContent->NodeInfo()->GetName(tagName);
+  nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::tag, tagName);
+
   // Expose draggable object attribute?
   nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mContent);
   if (htmlElement) {
     bool draggable = false;
     htmlElement->GetDraggable(&draggable);
     if (draggable) {
       nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::draggable,
                              NS_LITERAL_STRING("true"));
     }
   }
 
   // Don't calculate CSS-based object attributes when no frame (i.e.
-  // the accessible is not unattached form three) or when the accessible is not
-  // primary for node (like list bullet or XUL tree items).
-  if (!mContent->GetPrimaryFrame() || !IsPrimaryForNode())
+  // the accessible is unattached from the tree).
+  if (!mContent->GetPrimaryFrame())
     return NS_OK;
 
   // CSS style based object attributes.
   nsAutoString value;
   StyleInfo styleInfo(mContent->AsElement(), mDoc->PresShell());
 
   // Expose 'display' attribute.
   styleInfo.Display(value);
@@ -1798,57 +1788,54 @@ nsAccessible::GetKeyBindings(PRUint8 aAc
   if (!defaultKey.IsEmpty())
     keyBindings->Add(defaultKey);
 
   NS_ADDREF(*aKeyBindings = keyBindings);
   return NS_OK;
 }
 
 role
-nsAccessible::ARIARoleInternal()
+nsAccessible::ARIATransformRole(role aRole)
 {
-  NS_PRECONDITION(mRoleMapEntry && mRoleMapEntry->roleRule == kUseMapRole,
-                  "ARIARoleInternal should only be called when ARIA role overrides!");
-
   // XXX: these unfortunate exceptions don't fit into the ARIA table. This is
   // where the accessible role depends on both the role and ARIA state.
-  if (mRoleMapEntry->role == roles::PUSHBUTTON) {
+  if (aRole == roles::PUSHBUTTON) {
     if (nsAccUtils::HasDefinedARIAToken(mContent, nsGkAtoms::aria_pressed)) {
       // For simplicity, any existing pressed attribute except "" or "undefined"
       // indicates a toggle.
       return roles::TOGGLE_BUTTON;
     }
 
     if (mContent->AttrValueIs(kNameSpaceID_None,
                               nsGkAtoms::aria_haspopup,
                               nsGkAtoms::_true,
                               eCaseMatters)) {
       // For button with aria-haspopup="true".
       return roles::BUTTONMENU;
     }
 
-  } else if (mRoleMapEntry->role == roles::LISTBOX) {
+  } else if (aRole == roles::LISTBOX) {
     // A listbox inside of a combobox needs a special role because of ATK
     // mapping to menu.
     if (mParent && mParent->Role() == roles::COMBOBOX) {
       return roles::COMBOBOX_LIST;
 
       Relation rel = RelationByType(nsIAccessibleRelation::RELATION_NODE_CHILD_OF);
       nsAccessible* targetAcc = nsnull;
       while ((targetAcc = rel.Next()))
         if (targetAcc->Role() == roles::COMBOBOX)
           return roles::COMBOBOX_LIST;
     }
 
-  } else if (mRoleMapEntry->role == roles::OPTION) {
+  } else if (aRole == roles::OPTION) {
     if (mParent && mParent->Role() == roles::COMBOBOX_LIST)
       return roles::COMBOBOX_OPTION;
   }
 
-  return mRoleMapEntry->role;
+  return aRole;
 }
 
 role
 nsAccessible::NativeRole()
 {
   return nsCoreUtils::IsXLink(mContent) ? roles::LINK : roles::NOTHING;
 }
 
@@ -2010,51 +1997,51 @@ nsAccessible::RelationByType(PRUint32 aT
 {
   // Relationships are defined on the same content node that the role would be
   // defined on.
   switch (aType) {
     case nsIAccessibleRelation::RELATION_LABEL_FOR: {
       Relation rel(new RelatedAccIterator(Document(), mContent,
                                           nsGkAtoms::aria_labelledby));
       if (mContent->Tag() == nsGkAtoms::label)
-        rel.AppendIter(new IDRefsIterator(mContent, mContent->IsHTML() ?
+        rel.AppendIter(new IDRefsIterator(mDoc, mContent, mContent->IsHTML() ?
                                           nsGkAtoms::_for :
                                           nsGkAtoms::control));
 
       return rel;
     }
     case nsIAccessibleRelation::RELATION_LABELLED_BY: {
-      Relation rel(new IDRefsIterator(mContent,
+      Relation rel(new IDRefsIterator(mDoc, mContent,
                                       nsGkAtoms::aria_labelledby));
       if (mContent->IsHTML()) {
         rel.AppendIter(new HTMLLabelIterator(Document(), this));
       } else if (mContent->IsXUL()) {
         rel.AppendIter(new XULLabelIterator(Document(), mContent));
       }
 
       return rel;
     }
     case nsIAccessibleRelation::RELATION_DESCRIBED_BY: {
-      Relation rel(new IDRefsIterator(mContent,
-                                        nsGkAtoms::aria_describedby));
+      Relation rel(new IDRefsIterator(mDoc, mContent,
+                                      nsGkAtoms::aria_describedby));
       if (mContent->IsXUL())
         rel.AppendIter(new XULDescriptionIterator(Document(), mContent));
 
       return rel;
     }
     case nsIAccessibleRelation::RELATION_DESCRIPTION_FOR: {
       Relation rel(new RelatedAccIterator(Document(), mContent,
                                           nsGkAtoms::aria_describedby));
 
       // This affectively adds an optional control attribute to xul:description,
       // which only affects accessibility, by allowing the description to be
       // tied to a control.
       if (mContent->Tag() == nsGkAtoms::description &&
           mContent->IsXUL())
-        rel.AppendIter(new IDRefsIterator(mContent,
+        rel.AppendIter(new IDRefsIterator(mDoc, mContent,
                                           nsGkAtoms::control));
 
       return rel;
     }
     case nsIAccessibleRelation::RELATION_NODE_CHILD_OF: {
       Relation rel(new RelatedAccIterator(Document(), mContent,
                                           nsGkAtoms::aria_owns));
       
@@ -2086,23 +2073,23 @@ nsAccessible::RelationByType(PRUint32 aT
       }
 
       return rel;
     }
     case nsIAccessibleRelation::RELATION_CONTROLLED_BY:
       return Relation(new RelatedAccIterator(Document(), mContent,
                                              nsGkAtoms::aria_controls));
     case nsIAccessibleRelation::RELATION_CONTROLLER_FOR: {
-      Relation rel(new IDRefsIterator(mContent,
+      Relation rel(new IDRefsIterator(mDoc, mContent,
                                       nsGkAtoms::aria_controls));
       rel.AppendIter(new HTMLOutputIterator(Document(), mContent));
       return rel;
     }
     case nsIAccessibleRelation::RELATION_FLOWS_TO:
-      return Relation(new IDRefsIterator(mContent,
+      return Relation(new IDRefsIterator(mDoc, mContent,
                                          nsGkAtoms::aria_flowto));
     case nsIAccessibleRelation::RELATION_FLOWS_FROM:
       return Relation(new RelatedAccIterator(Document(), mContent,
                                              nsGkAtoms::aria_flowto));
     case nsIAccessibleRelation::RELATION_DEFAULT_BUTTON: {
       if (mContent->IsHTML()) {
         // HTML form controls implements nsIFormControl interface.
         nsCOMPtr<nsIFormControl> control(do_QueryInterface(mContent));
@@ -2225,18 +2212,19 @@ void
 nsAccessible::DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex)
 {
   if (IsDefunct())
     return;
 
   nsIPresShell* presShell = mDoc->PresShell();
 
   // Scroll into view.
-  presShell->ScrollContentIntoView(aContent, NS_PRESSHELL_SCROLL_ANYWHERE,
-                                   NS_PRESSHELL_SCROLL_ANYWHERE,
+  presShell->ScrollContentIntoView(aContent,
+                                   nsIPresShell::ScrollAxis(),
+                                   nsIPresShell::ScrollAxis(),
                                    nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 
   // Fire mouse down and mouse up events.
   bool res = nsCoreUtils::DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, presShell,
                                                aContent);
   if (!res)
     return;
 
@@ -2512,18 +2500,20 @@ nsAccessible::AppendTextTo(nsAString& aT
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessNode public methods
 
 void
 nsAccessible::Shutdown()
 {
-  // Invalidate the child count and pointers to other accessibles, also make
-  // sure none of its children point to this parent
+  // Mark the accessible as defunct, invalidate the child count and pointers to 
+  // other accessibles, also make sure none of its children point to this parent
+  mFlags |= eIsDefunct;
+
   InvalidateChildren();
   if (mParent)
     mParent->RemoveChild(this);
 
   nsAccessNodeWrap::Shutdown();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/accessible/src/base/nsAccessible.h
+++ b/accessible/src/base/nsAccessible.h
@@ -61,25 +61,30 @@ class EmbeddedObjCollector;
 class KeyBinding;
 class nsAccessible;
 class nsHyperTextAccessible;
 class nsHTMLImageAccessible;
 class nsHTMLImageMapAccessible;
 class nsHTMLLIAccessible;
 struct nsRoleMapEntry;
 class Relation;
+namespace mozilla {
+namespace a11y {
+class TableAccessible;
+}
+}
 class nsTextAccessible;
 
 struct nsRect;
 class nsIContent;
 class nsIFrame;
 class nsIAtom;
 class nsIView;
 
-typedef nsRefPtrHashtable<nsVoidPtrHashKey, nsAccessible>
+typedef nsRefPtrHashtable<nsPtrHashKey<const void>, nsAccessible>
   nsAccessibleHashtable;
 
 // see nsAccessible::GetAttrValue
 #define NS_OK_NO_ARIA_VALUE \
 NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_GENERAL, 0x21)
 
 // see nsAccessible::GetNameInternal
 #define NS_OK_EMPTY_NAME \
@@ -168,19 +173,19 @@ public:
   virtual nsresult GetNameInternal(nsAString& aName);
 
   /**
    * Return enumerated accessible role (see constants in Role.h).
    */
   inline mozilla::a11y::role Role()
   {
     if (!mRoleMapEntry || mRoleMapEntry->roleRule != kUseMapRole)
-      return NativeRole();
+      return ARIATransformRole(NativeRole());
 
-    return ARIARoleInternal();
+    return ARIATransformRole(mRoleMapEntry->role);
   }
 
   /**
    * Return true if ARIA role is specified on the element.
    */
   inline bool HasARIARole() const
   {
     return mRoleMapEntry;
@@ -190,17 +195,17 @@ public:
    * Return accessible role specified by ARIA (see constants in
    * roles).
    */
   inline mozilla::a11y::role ARIARole()
   {
     if (!mRoleMapEntry || mRoleMapEntry->roleRule != kUseMapRole)
       return mozilla::a11y::roles::NOTHING;
 
-    return ARIARoleInternal();
+    return ARIATransformRole(mRoleMapEntry->role);
   }
 
   /**
    * Returns enumerated accessible role from native markup (see constants in
    * Role.h). Doesn't take into account ARIA roles.
    */
   virtual mozilla::a11y::role NativeRole();
 
@@ -466,16 +471,18 @@ public:
 
   inline bool IsMenuButton() const { return mFlags & eMenuButtonAccessible; }
 
   inline bool IsMenuPopup() const { return mFlags & eMenuPopupAccessible; }
 
   inline bool IsRoot() const { return mFlags & eRootAccessible; }
   nsRootAccessible* AsRoot();
 
+  virtual mozilla::a11y::TableAccessible* AsTable() { return nsnull; }
+
   inline bool IsTextLeaf() const { return mFlags & eTextLeafAccessible; }
   nsTextAccessible* AsTextLeaf();
 
   //////////////////////////////////////////////////////////////////////////////
   // ActionAccessible
 
   /**
    * Return the number of actions that can be performed on this accessible.
@@ -631,31 +638,36 @@ public:
    */
   virtual nsAccessible* ContainerWidget() const;
 
   /**
    * Return the localized string for the given key.
    */
   static void TranslateString(const nsAString& aKey, nsAString& aStringOut);
 
+  /**
+   * Return true if the accessible is defunct.
+   */
+  bool IsDefunct() const { return mFlags & eIsDefunct; }
+
 protected:
 
   //////////////////////////////////////////////////////////////////////////////
   // Initializing, cache and tree traverse methods
 
   /**
    * Cache accessible children.
    */
   virtual void CacheChildren();
 
   /**
    * Set accessible parent and index in parent.
    */
   virtual void BindToParent(nsAccessible* aParent, PRUint32 aIndexInParent);
-  void UnbindFromParent();
+  virtual void UnbindFromParent();
 
   /**
    * Return sibling accessible at the given offset.
    */
   virtual nsAccessible* GetSiblingAtOffset(PRInt32 aOffset,
                                            nsresult *aError = nsnull) const;
 
   /**
@@ -675,44 +687,52 @@ protected:
 
   /**
    * Set children flag.
    */
   inline void SetChildrenFlag(ChildrenFlags aFlag)
     { mFlags = (mFlags & ~kChildrenFlagsMask) | aFlag; }
 
   /**
-   * Flags describing the accessible itself.
+   * Flags used to describe the state of this accessible.
    * @note keep these flags in sync with ChildrenFlags
    */
+  enum StateFlags {
+    eIsDefunct = 1 << 2 // accessible is defunct
+  };
+
+  /**
+   * Flags describing the type of this accessible.
+   * @note keep these flags in sync with ChildrenFlags and StateFlags
+   */
   enum AccessibleTypes {
-    eApplicationAccessible = 1 << 2,
-    eAutoCompleteAccessible = 1 << 3,
-    eAutoCompletePopupAccessible = 1 << 4,
-    eComboboxAccessible = 1 << 5,
-    eDocAccessible = 1 << 6,
-    eHyperTextAccessible = 1 << 7,
-    eHTMLFileInputAccessible = 1 << 8,
-    eHTMLListItemAccessible = 1 << 9,
-    eImageAccessible = 1 << 10,
-    eImageMapAccessible = 1 << 11,
-    eListControlAccessible = 1 << 12,
-    eMenuButtonAccessible = 1 << 13,
-    eMenuPopupAccessible = 1 << 14,
-    eRootAccessible = 1 << 15,
-    eTextLeafAccessible = 1 << 16
+    eApplicationAccessible = 1 << 3,
+    eAutoCompleteAccessible = 1 << 4,
+    eAutoCompletePopupAccessible = 1 << 5,
+    eComboboxAccessible = 1 << 6,
+    eDocAccessible = 1 << 7,
+    eHyperTextAccessible = 1 << 8,
+    eHTMLFileInputAccessible = 1 << 9,
+    eHTMLListItemAccessible = 1 << 10,
+    eImageAccessible = 1 << 11,
+    eImageMapAccessible = 1 << 12,
+    eListControlAccessible = 1 << 13,
+    eMenuButtonAccessible = 1 << 14,
+    eMenuPopupAccessible = 1 << 15,
+    eRootAccessible = 1 << 16,
+    eTextLeafAccessible = 1 << 17
   };
 
   //////////////////////////////////////////////////////////////////////////////
   // Miscellaneous helpers
 
   /**
    * Return ARIA role (helper method).
    */
-  mozilla::a11y::role ARIARoleInternal();
+  mozilla::a11y::role ARIATransformRole(mozilla::a11y::role aRole);
 
   virtual nsIFrame* GetBoundsFrame();
   virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
 
   //////////////////////////////////////////////////////////////////////////////
   // Name helpers
 
   /**
--- a/accessible/src/base/nsApplicationAccessible.cpp
+++ b/accessible/src/base/nsApplicationAccessible.cpp
@@ -305,22 +305,16 @@ nsApplicationAccessible::GetPlatformVers
   AppendUTF8toUTF16(cversion, aVersion);
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessNode public methods
 
 bool
-nsApplicationAccessible::IsDefunct() const
-{
-  return nsAccessibilityService::IsShutdown();
-}
-
-bool
 nsApplicationAccessible::Init()
 {
   mAppInfo = do_GetService("@mozilla.org/xre/app-info;1");
   return true;
 }
 
 void
 nsApplicationAccessible::Shutdown()
@@ -443,23 +437,16 @@ NS_IMETHODIMP
 nsApplicationAccessible::GetRootDocument(nsIAccessibleDocument **aRootDocument)
 {
   NS_ENSURE_ARG_POINTER(aRootDocument);
   *aRootDocument = nsnull;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsApplicationAccessible::GetInnerHTML(nsAString &aInnerHTML)
-{
-  aInnerHTML.Truncate();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsApplicationAccessible::ScrollTo(PRUint32 aScrollType)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsApplicationAccessible::ScrollToPoint(PRUint32 aCoordinateType,
                                        PRInt32 aX, PRInt32 aY)
--- a/accessible/src/base/nsApplicationAccessible.h
+++ b/accessible/src/base/nsApplicationAccessible.h
@@ -68,17 +68,16 @@ public:
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIAccessible
   NS_SCRIPTABLE NS_IMETHOD GetDOMNode(nsIDOMNode** aDOMNode);
   NS_SCRIPTABLE NS_IMETHOD GetDocument(nsIAccessibleDocument** aDocument);
   NS_SCRIPTABLE NS_IMETHOD GetRootDocument(nsIAccessibleDocument** aRootDocument);
-  NS_SCRIPTABLE NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML);
   NS_SCRIPTABLE NS_IMETHOD ScrollTo(PRUint32 aScrollType);
   NS_SCRIPTABLE NS_IMETHOD ScrollToPoint(PRUint32 aCoordinateType, PRInt32 aX, PRInt32 aY);
   NS_SCRIPTABLE NS_IMETHOD GetLanguage(nsAString& aLanguage);
   NS_IMETHOD GetParent(nsIAccessible **aParent);
   NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
   NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
   NS_IMETHOD GetName(nsAString &aName);
   NS_IMETHOD GetValue(nsAString &aValue);
@@ -93,17 +92,16 @@ public:
   NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString &aName);
   NS_IMETHOD GetActionDescription(PRUint8 aIndex, nsAString &aDescription);
   NS_IMETHOD DoAction(PRUint8 aIndex);
 
   // nsIAccessibleApplication
   NS_DECL_NSIACCESSIBLEAPPLICATION
 
   // nsAccessNode
-  virtual bool IsDefunct() const;
   virtual bool Init();
   virtual void Shutdown();
   virtual bool IsPrimaryForNode() const;
 
   // nsAccessible
   virtual void ApplyARIAState(PRUint64* aState);
   virtual void Description(nsString& aDescription);
   virtual mozilla::a11y::role NativeRole();
--- a/accessible/src/base/nsBaseWidgetAccessible.cpp
+++ b/accessible/src/base/nsBaseWidgetAccessible.cpp
@@ -243,16 +243,26 @@ nsLinkableAccessible::BindToParent(nsAcc
     if (nsCoreUtils::HasClickListener(walkUpAcc->GetContent())) {
       mActionAcc = walkUpAcc;
       mIsOnclick = true;
       return;
     }
   }
 }
 
+void
+nsLinkableAccessible::UnbindFromParent()
+{
+  mActionAcc = nsnull;
+  mIsLink = false;
+  mIsOnclick = false;
+
+  nsAccessibleWrap::UnbindFromParent();
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // nsEnumRoleAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 nsEnumRoleAccessible::
   nsEnumRoleAccessible(nsIContent* aNode, nsDocAccessible* aDoc,
                        roles::Role aRole) :
   nsAccessibleWrap(aNode, aDoc), mRole(aRole)
--- a/accessible/src/base/nsBaseWidgetAccessible.h
+++ b/accessible/src/base/nsBaseWidgetAccessible.h
@@ -103,16 +103,17 @@ public:
   virtual KeyBinding AccessKey() const;
 
   // HyperLinkAccessible
   virtual already_AddRefed<nsIURI> AnchorURIAt(PRUint32 aAnchorIndex);
 
 protected:
   // nsAccessible
   virtual void BindToParent(nsAccessible* aParent, PRUint32 aIndexInParent);
+  virtual void UnbindFromParent();
 
   /**
    * Parent accessible that provides an action for this linkable accessible.
    */
   nsAccessible* mActionAcc;
   bool mIsLink;
   bool mIsOnclick;
 };
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -291,28 +291,29 @@ nsCoreUtils::IsAncestorOf(nsINode *aPoss
 }
 
 nsresult
 nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame,
                                nsIDOMNode *aStartNode, PRInt32 aStartIndex,
                                nsIDOMNode *aEndNode, PRInt32 aEndIndex,
                                PRUint32 aScrollType)
 {
-  PRInt16 vPercent, hPercent;
-  ConvertScrollTypeToPercents(aScrollType, &vPercent, &hPercent);
+  nsIPresShell::ScrollAxis vertical, horizontal;
+  ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
 
   return ScrollSubstringTo(aFrame, aStartNode, aStartIndex, aEndNode, aEndIndex,
-                           vPercent, hPercent);
+                           vertical, horizontal);
 }
 
 nsresult
 nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame,
                                nsIDOMNode *aStartNode, PRInt32 aStartIndex,
                                nsIDOMNode *aEndNode, PRInt32 aEndIndex,
-                               PRInt16 aVPercent, PRInt16 aHPercent)
+                               nsIPresShell::ScrollAxis aVertical,
+                               nsIPresShell::ScrollAxis aHorizontal)
 {
   if (!aFrame || !aStartNode || !aEndNode)
     return NS_ERROR_FAILURE;
 
   nsPresContext *presContext = aFrame->PresContext();
 
   nsRefPtr<nsIDOMRange> scrollToRange = new nsRange();
   nsCOMPtr<nsISelectionController> selCon;
@@ -325,18 +326,19 @@ nsCoreUtils::ScrollSubstringTo(nsIFrame 
   nsCOMPtr<nsISelection> selection;
   selCon->GetSelection(nsISelectionController::SELECTION_ACCESSIBILITY,
                        getter_AddRefs(selection));
 
   nsCOMPtr<nsISelectionPrivate> privSel(do_QueryInterface(selection));
   selection->RemoveAllRanges();
   selection->AddRange(scrollToRange);
 
-  privSel->ScrollIntoView(nsISelectionController::SELECTION_ANCHOR_REGION,
-                          true, aVPercent, aHPercent);
+  privSel->ScrollIntoViewInternal(
+    nsISelectionController::SELECTION_ANCHOR_REGION,
+    true, aVertical, aHorizontal);
 
   selection->CollapseToStart();
 
   return NS_OK;
 }
 
 void
 nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame,
@@ -360,49 +362,67 @@ nsCoreUtils::ScrollFrameToPoint(nsIFrame
   nsPoint scrollPoint = scrollableFrame->GetScrollPosition();
   scrollPoint -= deltaPoint;
 
   scrollableFrame->ScrollTo(scrollPoint, nsIScrollableFrame::INSTANT);
 }
 
 void
 nsCoreUtils::ConvertScrollTypeToPercents(PRUint32 aScrollType,
-                                         PRInt16 *aVPercent,
-                                         PRInt16 *aHPercent)
+                                         nsIPresShell::ScrollAxis *aVertical,
+                                         nsIPresShell::ScrollAxis *aHorizontal)
 {
+  PRInt16 whereY, whereX;
+  nsIPresShell::WhenToScroll whenY, whenX;
   switch (aScrollType)
   {
     case nsIAccessibleScrollType::SCROLL_TYPE_TOP_LEFT:
-      *aVPercent = NS_PRESSHELL_SCROLL_TOP;
-      *aHPercent = NS_PRESSHELL_SCROLL_LEFT;
+      whereY = nsIPresShell::SCROLL_TOP;
+      whenY  = nsIPresShell::SCROLL_ALWAYS;
+      whereX = nsIPresShell::SCROLL_LEFT;
+      whenX  = nsIPresShell::SCROLL_ALWAYS;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_BOTTOM_RIGHT:
-      *aVPercent = NS_PRESSHELL_SCROLL_BOTTOM;
-      *aHPercent = NS_PRESSHELL_SCROLL_RIGHT;
+      whereY = nsIPresShell::SCROLL_BOTTOM;
+      whenY  = nsIPresShell::SCROLL_ALWAYS;
+      whereX = nsIPresShell::SCROLL_RIGHT;
+      whenX  = nsIPresShell::SCROLL_ALWAYS;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_TOP_EDGE:
-      *aVPercent = NS_PRESSHELL_SCROLL_TOP;
-      *aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
+      whereY = nsIPresShell::SCROLL_TOP;
+      whenY  = nsIPresShell::SCROLL_ALWAYS;
+      whereX = nsIPresShell::SCROLL_MINIMUM;
+      whenX  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_BOTTOM_EDGE:
-      *aVPercent = NS_PRESSHELL_SCROLL_BOTTOM;
-      *aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
+      whereY = nsIPresShell::SCROLL_BOTTOM;
+      whenY  = nsIPresShell::SCROLL_ALWAYS;
+      whereX = nsIPresShell::SCROLL_MINIMUM;
+      whenX  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_LEFT_EDGE:
-      *aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
-      *aHPercent = NS_PRESSHELL_SCROLL_LEFT;
+      whereY = nsIPresShell::SCROLL_MINIMUM;
+      whenY  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
+      whereX = nsIPresShell::SCROLL_LEFT;
+      whenX  = nsIPresShell::SCROLL_ALWAYS;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_RIGHT_EDGE:
-      *aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
-      *aHPercent = NS_PRESSHELL_SCROLL_RIGHT;
+      whereY = nsIPresShell::SCROLL_MINIMUM;
+      whenY  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
+      whereX = nsIPresShell::SCROLL_RIGHT;
+      whenX  = nsIPresShell::SCROLL_ALWAYS;
       break;
     default:
-      *aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
-      *aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
+      whereY = nsIPresShell::SCROLL_MINIMUM;
+      whenY  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
+      whereX = nsIPresShell::SCROLL_MINIMUM;
+      whenX  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
   }
+  *aVertical = nsIPresShell::ScrollAxis(whereY, whenY);
+  *aHorizontal = nsIPresShell::ScrollAxis(whereX, whenX);
 }
 
 nsIntPoint
 nsCoreUtils::GetScreenCoordsForWindow(nsINode *aNode)
 {
   nsIntPoint coords(0, 0);
   nsCOMPtr<nsIDocShellTreeItem> treeItem(GetDocShellTreeItemFor(aNode));
   if (!treeItem)
--- a/accessible/src/base/nsCoreUtils.h
+++ b/accessible/src/base/nsCoreUtils.h
@@ -176,42 +176,43 @@ public:
   /** Helper method to scroll range into view, used for implementation of
    * nsIAccessibleText::scrollSubstringTo[Point]().
    *
    * @param aFrame        the frame for accessible the range belongs to.
    * @param aStartNode    start node of a range
    * @param aStartOffset  an offset inside the start node
    * @param aEndNode      end node of a range
    * @param aEndOffset    an offset inside the end node
-   * @param aVPercent     how to align vertically, specified in percents
-   * @param aHPercent     how to align horizontally, specified in percents
+   * @param aVertical     how to align vertically, specified in percents, and when.
+   * @param aHorizontal     how to align horizontally, specified in percents, and when.
    */
   static nsresult ScrollSubstringTo(nsIFrame *aFrame,
                                     nsIDOMNode *aStartNode, PRInt32 aStartIndex,
                                     nsIDOMNode *aEndNode, PRInt32 aEndIndex,
-                                    PRInt16 aVPercent, PRInt16 aHPercent);
+                                    nsIPresShell::ScrollAxis aVertical,
+                                    nsIPresShell::ScrollAxis aHorizontal);
 
   /**
    * Scrolls the given frame to the point, used for implememntation of
    * nsIAccessible::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint.
    *
    * @param aScrollableFrame  the scrollable frame
    * @param aFrame            the frame to scroll
    * @param aPoint            the point scroll to
    */
   static void ScrollFrameToPoint(nsIFrame *aScrollableFrame,
                                  nsIFrame *aFrame, const nsIntPoint& aPoint);
 
   /**
    * Converts scroll type constant defined in nsIAccessibleScrollType to
-   * vertical and horizontal percents.
+   * vertical and horizontal parameters.
    */
   static void ConvertScrollTypeToPercents(PRUint32 aScrollType,
-                                          PRInt16 *aVPercent,
-                                          PRInt16 *aHPercent);
+                                          nsIPresShell::ScrollAxis *aVertical,
+                                          nsIPresShell::ScrollAxis *aHorizontal);
 
   /**
    * Returns coordinates relative screen for the top level window.
    *
    * @param aNode  the DOM node hosted in the window.
    */
   static nsIntPoint GetScreenCoordsForWindow(nsINode *aNode);
 
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -688,22 +688,16 @@ nsDocAccessible::GetFrame() const
 {
   nsIFrame* root = nsnull;
   if (mPresShell)
     root = mPresShell->GetRootFrame();
 
   return root;
 }
 
-bool
-nsDocAccessible::IsDefunct() const
-{
-  return nsHyperTextAccessibleWrap::IsDefunct() || !mDocument;
-}
-
 // nsDocAccessible protected member
 void nsDocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame)
 {
   *aRelativeFrame = GetFrame();
 
   nsIDocument *document = mDocument;
   nsIDocument *parentDoc = nsnull;
 
@@ -1462,24 +1456,18 @@ nsDocAccessible::ContentRemoved(nsIConte
 void
 nsDocAccessible::RecreateAccessible(nsIContent* aContent)
 {
   // XXX: we shouldn't recreate whole accessible subtree, instead we should
   // subclass hide and show events to handle them separately and implement their
   // coalescence with normal hide and show events. Note, in this case they
   // should be coalesced with normal show/hide events.
 
-  // Check if the node is in accessible document.
-  nsAccessible* container = GetContainerAccessible(aContent);
-  if (container) {
-    // Remove and reinsert.
-    UpdateTree(container, aContent, false);
-    container->UpdateChildren();
-    UpdateTree(container, aContent, true);
-  }
+  ContentRemoved(aContent->GetParent(), aContent);
+  ContentInserted(aContent->GetParent(), aContent, aContent->GetNextSibling());
 }
 
 void
 nsDocAccessible::ProcessInvalidationList()
 {
   // Invalidate children of container accessible for each element in
   // invalidation list. Allow invalidation list insertions while container
   // children are recached.
@@ -1618,17 +1606,17 @@ nsDocAccessible::AddDependentIDsFor(nsAc
 
     } else if (relAttr == nsGkAtoms::control) {
       if (!aRelProvider->GetContent()->IsXUL() ||
           (aRelProvider->GetContent()->Tag() != nsGkAtoms::label &&
            aRelProvider->GetContent()->Tag() != nsGkAtoms::description))
         continue;
     }
 
-    IDRefsIterator iter(aRelProvider->GetContent(), relAttr);
+    IDRefsIterator iter(this, aRelProvider->GetContent(), relAttr);
     while (true) {
       const nsDependentSubstring id = iter.NextID();
       if (id.IsEmpty())
         break;
 
       AttrRelProviderArray* providers = mDependentIDsHash.Get(id);
       if (!providers) {
         providers = new AttrRelProviderArray();
@@ -1669,17 +1657,17 @@ void
 nsDocAccessible::RemoveDependentIDsFor(nsAccessible* aRelProvider,
                                        nsIAtom* aRelAttr)
 {
   for (PRUint32 idx = 0; idx < kRelationAttrsLen; idx++) {
     nsIAtom* relAttr = *kRelationAttrs[idx];
     if (aRelAttr && aRelAttr != *kRelationAttrs[idx])
       continue;
 
-    IDRefsIterator iter(aRelProvider->GetContent(), relAttr);
+    IDRefsIterator iter(this, aRelProvider->GetContent(), relAttr);
     while (true) {
       const nsDependentSubstring id = iter.NextID();
       if (id.IsEmpty())
         break;
 
       AttrRelProviderArray* providers = mDependentIDsHash.Get(id);
       if (providers) {
         for (PRUint32 jdx = 0; jdx < providers->Length(); ) {
@@ -1712,43 +1700,39 @@ nsDocAccessible::UpdateAccessibleOnAttrC
     if (mContent == aElement) {
       SetRoleMapEntry(nsAccUtils::GetRoleMapEntry(aElement));
       return true;
     }
 
     // Recreate the accessible when role is changed because we might require a
     // different accessible class for the new role or the accessible may expose
     // a different sets of interfaces (COM restriction).
-    HandleNotification<nsDocAccessible, nsIContent>
-      (this, &nsDocAccessible::RecreateAccessible, aElement);
+    RecreateAccessible(aElement);
 
     return true;
   }
 
   if (aAttribute == nsGkAtoms::href ||
       aAttribute == nsGkAtoms::onclick) {
     // Not worth the expense to ensure which namespace these are in. It doesn't
     // kill use to recreate the accessible even if the attribute was used in
     // the wrong namespace or an element that doesn't support it.
 
-    // Recreate accessible asynchronously to allow the content to handle
-    // the attribute change.
-    mNotificationController->ScheduleNotification<nsDocAccessible, nsIContent>
-      (this, &nsDocAccessible::RecreateAccessible, aElement);
-
+    // Make sure the accessible is recreated asynchronously to allow the content
+    // to handle the attribute change.
+    RecreateAccessible(aElement);
     return true;
   }
 
   if (aAttribute == nsGkAtoms::aria_multiselectable &&
       aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::role)) {
     // This affects whether the accessible supports SelectAccessible.
     // COM says we cannot change what interfaces are supported on-the-fly,
     // so invalidate this object. A new one will be created on demand.
-    HandleNotification<nsDocAccessible, nsIContent>
-      (this, &nsDocAccessible::RecreateAccessible, aElement);
+    RecreateAccessible(aElement);
 
     return true;
   }
 
   return false;
 }
 
 // nsDocAccessible public member
--- a/accessible/src/base/nsDocAccessible.h
+++ b/accessible/src/base/nsDocAccessible.h
@@ -111,17 +111,16 @@ public:
 
   // nsIDocumentObserver
   NS_DECL_NSIDOCUMENTOBSERVER
 
   // nsAccessNode
   virtual bool Init();
   virtual void Shutdown();
   virtual nsIFrame* GetFrame() const;
-  virtual bool IsDefunct() const;
   virtual nsINode* GetNode() const { return mDocument; }
   virtual nsIDocument* GetDocumentNode() const { return mDocument; }
 
   // nsAccessible
   virtual void Description(nsString& aDescription);
   virtual nsAccessible* FocusedChild();
   virtual mozilla::a11y::role NativeRole();
   virtual PRUint64 NativeState();
--- a/accessible/src/base/nsRootAccessible.cpp
+++ b/accessible/src/base/nsRootAccessible.cpp
@@ -224,18 +224,16 @@ const char* const docEvents[] = {
   "mouseover",
 #endif
   // capture Form change events 
   "select",
   // capture ValueChange events (fired whenever value changes, immediately after, whether focus moves or not)
   "ValueChange",
   // capture AlertActive events (fired whenever alert pops up)
   "AlertActive",
-  // add ourself as a TreeViewChanged listener (custom event fired in nsTreeBodyFrame.cpp)
-  "TreeViewChanged",
   "TreeRowCountChanged",
   "TreeInvalidated",
   // add ourself as a OpenStateChange listener (custom event fired in tree.xml)
   "OpenStateChange",
   // add ourself as a CheckboxStateChange listener (custom event fired in nsHTMLInputElement.cpp)
   "CheckboxStateChange",
   // add ourself as a RadioStateChange Listener ( custom event fired in in nsHTMLInputElement.cpp  & radio.xml)
   "RadioStateChange",
@@ -389,21 +387,16 @@ nsRootAccessible::ProcessDOMEvent(nsIDOM
 
 #ifdef MOZ_XUL
   nsRefPtr<nsXULTreeAccessible> treeAcc;
   if (targetNode->IsElement() &&
       targetNode->AsElement()->NodeInfo()->Equals(nsGkAtoms::tree,
                                                   kNameSpaceID_XUL)) {
     treeAcc = do_QueryObject(accessible);
     if (treeAcc) {
-      if (eventType.EqualsLiteral("TreeViewChanged")) {
-        treeAcc->TreeViewChanged();
-        return;
-      }
-
       if (eventType.EqualsLiteral("TreeRowCountChanged")) {
         HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc);
         return;
       }
 
       if (eventType.EqualsLiteral("TreeInvalidated")) {
         HandleTreeInvalidatedEvent(aDOMEvent, treeAcc);
         return;
--- a/accessible/src/base/nsRootAccessible.h
+++ b/accessible/src/base/nsRootAccessible.h
@@ -36,25 +36,23 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _nsRootAccessible_H_
 #define _nsRootAccessible_H_
 
 #include "nsCaretAccessible.h"
 #include "nsDocAccessibleWrap.h"
 
-#ifdef MOZ_XUL
-#include "nsXULTreeAccessible.h"
-#endif
 
 #include "nsHashtable.h"
 #include "nsCaretAccessible.h"
 #include "nsIDocument.h"
 #include "nsIDOMEventListener.h"
 
+class nsXULTreeAccessible;
 class Relation;
 
 #define NS_ROOTACCESSIBLE_IMPL_CID                      \
 {  /* eaba2cf0-21b1-4e2b-b711-d3a89dcd5e1a */           \
   0xeaba2cf0,                                           \
   0x21b1,                                               \
   0x4e2b,                                               \
   { 0xb7, 0x11, 0xd3, 0xa8, 0x9d, 0xcd, 0x5e, 0x1a }    \
--- a/accessible/src/base/nsTextEquivUtils.cpp
+++ b/accessible/src/base/nsTextEquivUtils.cpp
@@ -89,17 +89,17 @@ nsTextEquivUtils::GetTextEquivFromIDRefs
 {
   aTextEquiv.Truncate();
 
   nsIContent* content = aAccessible->GetContent();
   if (!content)
     return NS_OK;
 
   nsIContent* refContent = nsnull;
-  IDRefsIterator iter(content, aIDRefsAttr);
+  IDRefsIterator iter(aAccessible->Document(), content, aIDRefsAttr);
   while ((refContent = iter.NextElem())) {
     if (!aTextEquiv.IsEmpty())
       aTextEquiv += ' ';
 
     nsresult rv = AppendTextEquivFromContent(aAccessible, refContent,
                                              &aTextEquiv);
     NS_ENSURE_SUCCESS(rv, rv);
   }
@@ -113,35 +113,28 @@ nsTextEquivUtils::AppendTextEquivFromCon
                                              nsAString *aString)
 {
   // Prevent recursion which can cause infinite loops.
   if (gInitiatorAcc)
     return NS_OK;
 
   gInitiatorAcc = aInitiatorAcc;
 
-  nsIPresShell* shell = nsCoreUtils::GetPresShellFor(aContent);
-  if (!shell) {
-    NS_ASSERTION(true, "There is no presshell!");
-    gInitiatorAcc = nsnull;
-    return NS_ERROR_UNEXPECTED;
-  }
-
   // If the given content is not visible or isn't accessible then go down
   // through the DOM subtree otherwise go down through accessible subtree and
   // calculate the flat string.
   nsIFrame *frame = aContent->GetPrimaryFrame();
   bool isVisible = frame && frame->GetStyleVisibility()->IsVisible();
 
   nsresult rv = NS_ERROR_FAILURE;
   bool goThroughDOMSubtree = true;
 
   if (isVisible) {
     nsAccessible* accessible =
-      GetAccService()->GetAccessible(aContent, shell);
+      gInitiatorAcc->Document()->GetAccessible(aContent);
     if (accessible) {
       rv = AppendFromAccessible(accessible, aString);
       goThroughDOMSubtree = false;
     }
   }
 
   if (goThroughDOMSubtree)
     rv = AppendFromDOMNode(aContent, aString);
new file mode 100644
--- /dev/null
+++ b/accessible/src/generic/TableAccessible.h
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef TABLE_ACCESSIBLE_H
+#define TABLE_ACCESSIBLE_H
+
+#include "nsString.h"
+#include "nsTArray.h"
+#include "prtypes.h"
+
+class nsAccessible;
+
+namespace mozilla {
+namespace a11y {
+
+/**
+ * Accessible table interface.
+ */
+class TableAccessible
+{
+public:
+
+  /**
+   * Return the caption accessible if any for this table.
+   */
+  virtual nsAccessible* Caption() { return nsnull; }
+
+  /**
+   * Get the summary for this table.
+   */
+  virtual void Summary(nsString& aSummary) { aSummary.Truncate(); }
+
+  /**
+   * Return the number of columns in the table.
+   */
+  virtual PRUint32 ColCount() { return 0; }
+
+  /**
+   * Return the number of rows in the table.
+   */
+  virtual PRUint32 RowCount() { return 0; }
+
+  /**
+   * Return the accessible for the cell at the given row and column indices.
+   */
+  virtual nsAccessible* CellAt(PRUint32 aRowIdx, PRUint32 aColIdx) { return nsnull; }
+
+  /**
+   * Return the index of the cell at the given row and column.
+   */
+  virtual PRInt32 CellIndexAt(PRUint32 aRowIdx, PRUint32 aColIdx) { return -1; }
+
+  /**
+   * Return the column index of the cell with the given index.
+   */
+  virtual PRInt32 ColIndexAt(PRUint32 aCellIdx) { return -1; }
+
+  /**
+   * Return the row index of the cell with the given index.
+   */
+  virtual PRInt32 RowIndexAt(PRUint32 aCellIdx) { return -1; }
+
+  /**
+   * Get the row and column indices for the cell at the given index.
+   */
+  virtual void RowAndColIndicesAt(PRUint32 aCellIdx, PRInt32* aRowIdx,
+                                  PRInt32* aColIdx) {}
+
+  /**
+   * Return the number of columns occupied by the cell at the given row and
+   * column indices.
+   */
+  virtual PRUint32 ColExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx) { return 1; }
+
+  /**
+   * Return the number of rows occupied by the cell at the given row and column
+   * indices.
+   */
+  virtual PRUint32 RowExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx) { return 1; }
+
+  /**
+   * Get the description of the given column.
+   */
+  virtual void ColDescription(PRUint32 aColIdx, nsString& aDescription)
+    { aDescription.Truncate(); }
+
+  /**
+   * Get the description for the given row.
+   */
+  virtual void RowDescription(PRUint32 aRowIdx, nsString& aDescription)
+    { aDescription.Truncate(); }
+
+  /**
+   * Return true if the given column is selected.
+   */
+  virtual bool IsColSelected(PRUint32 aColIdx) { return false; }
+
+  /**
+   * Return true if the given row is selected.
+   */
+  virtual bool IsRowSelected(PRUint32 aRowIdx) { return false; }
+
+  /**
+   * Return true if the given cell is selected.
+   */
+  virtual bool IsCellSelected(PRUint32 aRowIdx, PRUint32 aColIdx) { return false; }
+
+  /**
+   * Return the number of selected cells.
+   */
+  virtual PRUint32 SelectedCellCount() { return 0; }
+
+  /**
+   * Return the number of selected columns.
+   */
+  virtual PRUint32 SelectedColCount() { return 0; }
+
+  /**
+   * Return the number of selected rows.
+   */
+  virtual PRUint32 SelectedRowCount() { return 0; }
+
+  /**
+   * Get the set of selected cells.
+   */
+  virtual void SelectedCells(nsTArray<nsAccessible*>* aCells) {}
+
+  /**
+   * Get the set of selected column indices.
+   */
+  virtual void SelectedColIndices(nsTArray<PRUint32>* aCols) {}
+
+  /**
+   * Get the set of selected row indices.
+   */
+  virtual void SelectedRowIndices(nsTArray<PRUint32>* aRows) {}
+
+  /**
+   * Select the given column unselecting any other selected columns.
+   */
+  virtual void SelectCol(PRUint32 aColIdx) {}
+
+  /**
+   * Select the given row unselecting all other previously selected rows.
+   */
+  virtual void SelectRow(PRUint32 aRowIdx) {}
+
+  /**
+   * Unselect the given column leaving other selected columns selected.
+   */
+  virtual void UnselectCol(PRUint32 aColIdx) {}
+
+  /**
+   * Unselect the given row leaving other selected rows selected.
+   */
+  virtual void UnselectRow(PRUint32 aRowIdx) {}
+
+  /**
+   * Return true if the table is probably for layout.
+   */
+  virtual bool IsProbablyLayoutTable() { return false; }
+};
+
+} // namespace a11y
+} // namespace mozilla
+
+#endif
--- a/accessible/src/html/Makefile.in
+++ b/accessible/src/html/Makefile.in
@@ -68,11 +68,13 @@ EXPORTS = \
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES = \
   -I$(srcdir)/../base \
+  -I$(srcdir)/../generic \
+  -I$(srcdir)/../xpcom \
   -I$(srcdir)/../../../layout/generic \
   -I$(srcdir)/../../../layout/xul/base/src \
   $(NULL)
--- a/accessible/src/html/nsHTMLImageMapAccessible.cpp
+++ b/accessible/src/html/nsHTMLImageMapAccessible.cpp
@@ -211,63 +211,16 @@ nsHTMLAreaAccessible::Description(nsStri
   aDescription.Truncate();
 
   // Still to do - follow IE's standard here
   nsCOMPtr<nsIDOMHTMLAreaElement> area(do_QueryInterface(mContent));
   if (area) 
     area->GetShape(aDescription);
 }
 
-NS_IMETHODIMP
-nsHTMLAreaAccessible::GetBounds(PRInt32 *aX, PRInt32 *aY,
-                                PRInt32 *aWidth, PRInt32 *aHeight)
-{
-  NS_ENSURE_ARG_POINTER(aX);
-  *aX = 0;
-  NS_ENSURE_ARG_POINTER(aY);
-  *aY = 0;
-  NS_ENSURE_ARG_POINTER(aWidth);
-  *aWidth = 0;
-  NS_ENSURE_ARG_POINTER(aHeight);
-  *aHeight = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  // Essentially this uses GetRect on mAreas of nsImageMap from nsImageFrame.
-  nsPresContext *presContext = GetPresContext();
-  NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
-
-  nsIFrame *frame = GetFrame();
-  NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
-  nsImageFrame *imageFrame = do_QueryFrame(frame);
-
-  nsImageMap* map = imageFrame->GetImageMap();
-  NS_ENSURE_TRUE(map, NS_ERROR_FAILURE);
-
-  nsRect rect;
-  nsresult rv = map->GetBoundsForAreaContent(mContent, rect);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aX = presContext->AppUnitsToDevPixels(rect.x);
-  *aY = presContext->AppUnitsToDevPixels(rect.y);
-
-  // XXX Areas are screwy; they return their rects as a pair of points, one pair
-  // stored into the width and height.
-  *aWidth  = presContext->AppUnitsToDevPixels(rect.width - rect.x);
-  *aHeight = presContext->AppUnitsToDevPixels(rect.height - rect.y);
-
-  // Put coords in absolute screen coords
-  nsIntRect orgRectPixels = frame->GetScreenRectExternal();
-  *aX += orgRectPixels.x;
-  *aY += orgRectPixels.y;
-
-  return NS_OK;
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLAreaAccessible: nsAccessNode public
 
 bool
 nsHTMLAreaAccessible::IsPrimaryForNode() const
 {
   // Make HTML area DOM element not accessible. HTML image map accessible
   // manages its tree itself.
@@ -321,8 +274,30 @@ nsHTMLAreaAccessible::EndOffset()
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLAreaAccessible: nsAccessible protected
 
 void
 nsHTMLAreaAccessible::CacheChildren()
 {
   // No children for aria accessible.
 }
+
+void
+nsHTMLAreaAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame)
+{
+  nsIFrame* frame = GetFrame();
+  if (!frame)
+    return;
+
+  nsImageFrame* imageFrame = do_QueryFrame(frame);
+  nsImageMap* map = imageFrame->GetImageMap();
+
+  nsresult rv = map->GetBoundsForAreaContent(mContent, aBounds);
+  if (NS_FAILED(rv))
+    return;
+
+  // XXX Areas are screwy; they return their rects as a pair of points, one pair
+  // stored into the width and height.
+  aBounds.width -= aBounds.x;
+  aBounds.height -= aBounds.y;
+
+  *aBoundingFrame = frame;
+}
--- a/accessible/src/html/nsHTMLImageMapAccessible.h
+++ b/accessible/src/html/nsHTMLImageMapAccessible.h
@@ -91,20 +91,16 @@ nsAccessible::AsImageMap()
  * Accessible for image map areas - must be child of image.
  */
 class nsHTMLAreaAccessible : public nsHTMLLinkAccessible
 {
 public:
 
   nsHTMLAreaAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
 
-  // nsIAccessible
-
-  NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
-
   // nsAccessNode
   virtual bool IsPrimaryForNode() const;
 
   // nsAccessible
   virtual void Description(nsString& aDescription);
   virtual nsresult GetNameInternal(nsAString& aName);
   virtual PRUint64 NativeState();
   virtual nsAccessible* ChildAtPoint(PRInt32 aX, PRInt32 aY,
@@ -113,11 +109,12 @@ public:
   // HyperLinkAccessible
   virtual PRUint32 StartOffset();
   virtual PRUint32 EndOffset();
 
 protected:
 
   // nsAccessible
   virtual void CacheChildren();
+  virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
 };
 
 #endif  
--- a/accessible/src/html/nsHTMLSelectAccessible.cpp
+++ b/accessible/src/html/nsHTMLSelectAccessible.cpp
@@ -342,41 +342,16 @@ nsHTMLSelectOptionAccessible::GetLevelIn
     parentContent->NodeInfo()->Equals(nsGkAtoms::optgroup) ? 2 : 1;
 
   if (level == 1 && Role() != roles::HEADING)
     level = 0; // In a single level list, the level is irrelevant
 
   return level;
 }
 
-void
-nsHTMLSelectOptionAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
-                                                         PRInt32 *aSetSize)
-{
-  PRInt32 posInSet = 0, setSize = 0;
-  bool isContentFound = false;
-
-  nsIContent* parentContent = mContent->GetParent();
-  for (nsIContent* childContent = parentContent->GetFirstChild(); childContent;
-       childContent = childContent->GetNextSibling()) {
-    if (childContent->NodeInfo()->Equals(mContent->NodeInfo())) {
-      if (!isContentFound) {
-        if (childContent == mContent)
-          isContentFound = true;
-
-        posInSet++;
-      }
-      setSize++;
-    }
-  }
-
-  *aSetSize = setSize;
-  *aPosInSet = posInSet;
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLSelectOptionAccessible: nsIAccessible
 
 /** select us! close combo box if necessary*/
 NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
 {
   if (aIndex == eAction_Select) {
     aName.AssignLiteral("select"); 
--- a/accessible/src/html/nsHTMLSelectAccessible.h
+++ b/accessible/src/html/nsHTMLSelectAccessible.h
@@ -117,18 +117,16 @@ public:
   NS_IMETHOD SetSelected(bool aSelect);
 
   // nsAccessible
   virtual nsresult GetNameInternal(nsAString& aName);
   virtual mozilla::a11y::role NativeRole();
   virtual PRUint64 NativeState();
 
   virtual PRInt32 GetLevelInternal();
-  virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
-                                          PRInt32 *aSetSize);
 
   // ActionAccessible
   virtual PRUint8 ActionCount();
 
   // Widgets
   virtual nsAccessible* ContainerWidget() const;
 
 protected:
--- a/accessible/src/html/nsHTMLTableAccessible.cpp
+++ b/accessible/src/html/nsHTMLTableAccessible.cpp
@@ -329,17 +329,17 @@ nsHTMLTableCellAccessible::GetCellIndexe
   return cellLayout->GetCellIndexes(aRowIndex, aColIndex);
 }
 
 nsresult
 nsHTMLTableCellAccessible::GetHeaderCells(PRInt32 aRowOrColumnHeaderCell,
                                           nsIArray **aHeaderCells)
 {
   // Get header cells from @header attribute.
-  IDRefsIterator iter(mContent, nsGkAtoms::headers);
+  IDRefsIterator iter(mDoc, mContent, nsGkAtoms::headers);
   nsIContent* headerCellElm = iter.NextElem();
   if (headerCellElm) {
     nsresult rv = NS_OK;
     nsCOMPtr<nsIMutableArray> headerCells =
       do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
     roles::Role desiredRole = static_cast<roles::Role>(-1) ;
     if (aRowOrColumnHeaderCell == nsAccUtils::eRowHeaderCells)
@@ -431,26 +431,36 @@ nsHTMLTableHeaderCellAccessible::NativeR
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLTableAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 nsHTMLTableAccessible::
   nsHTMLTableAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
-  nsAccessibleWrap(aContent, aDoc)
+  nsAccessibleWrap(aContent, aDoc), xpcAccessibleTable(this)
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLTableAccessible: nsISupports implementation
 
 NS_IMPL_ISUPPORTS_INHERITED2(nsHTMLTableAccessible, nsAccessible,
                              nsHTMLTableAccessible, nsIAccessibleTable)
 
+////////////////////////////////////////////////////////////////////////////////
+//nsAccessNode
+
+void
+nsHTMLTableAccessible::Shutdown()
+{
+  mTable = nsnull;
+  nsAccessibleWrap::Shutdown();
+}
+
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLTableAccessible: nsAccessible implementation
 
 void
 nsHTMLTableAccessible::CacheChildren()
 {
   // Move caption accessible so that it's the first child. Check for the first
@@ -506,19 +516,17 @@ nsHTMLTableAccessible::GetNameInternal(n
 }
 
 nsresult
 nsHTMLTableAccessible::GetAttributesInternal(nsIPersistentProperties *aAttributes)
 {
   nsresult rv = nsAccessibleWrap::GetAttributesInternal(aAttributes);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  bool isProbablyForLayout;
-  IsProbablyForLayout(&isProbablyForLayout);
-  if (isProbablyForLayout) {
+  if (IsProbablyLayoutTable()) {
     nsAutoString oldValueUnused;
     aAttributes->SetStringProperty(NS_LITERAL_CSTRING("layout-guess"),
                                    NS_LITERAL_STRING("true"), oldValueUnused);
   }
   
   return NS_OK;
 }
 
@@ -533,23 +541,21 @@ nsHTMLTableAccessible::RelationByType(PR
     rel.AppendTarget(Caption());
 
   return rel;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLTableAccessible: nsIAccessibleTable implementation
 
-NS_IMETHODIMP
-nsHTMLTableAccessible::GetCaption(nsIAccessible **aCaption)
+nsAccessible*
+nsHTMLTableAccessible::Caption()
 {
-  NS_ENSURE_ARG_POINTER(aCaption);
-
-  NS_IF_ADDREF(*aCaption = Caption());
-  return NS_OK;
+  nsAccessible* child = mChildren.SafeElementAt(0, nsnull);
+  return child && child->Role() == roles::CAPTION ? child : nsnull;
 }
 
 NS_IMETHODIMP
 nsHTMLTableAccessible::GetSummary(nsAString &aSummary)
 {
   nsCOMPtr<nsIDOMHTMLTableElement> table(do_QueryInterface(mContent));
   NS_ENSURE_TRUE(table, NS_ERROR_FAILURE);
 
@@ -1302,18 +1308,17 @@ nsHTMLTableAccessible::Description(nsStr
         mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::summary,
                           aDescription);
       }
     }
   }
 
 #ifdef SHOW_LAYOUT_HEURISTIC
   if (aDescription.IsEmpty()) {
-    bool isProbablyForLayout;
-    IsProbablyForLayout(&isProbablyForLayout);
+    bool isProbablyForLayout = IsProbablyLayoutTable();
     aDescription = mLayoutHeuristic;
   }
 #ifdef DEBUG_A11Y
   printf("\nTABLE: %s\n", NS_ConvertUTF16toUTF8(mLayoutHeuristic).get());
 #endif
 #endif
 }
 
@@ -1352,41 +1357,39 @@ nsHTMLTableAccessible::HasDescendant(con
   // performance problems only. Note, currently 'aAllowEmpty' flag is used for
   // caption element only. On another hand we create accessible object for
   // the first entry of caption element (see
   // nsHTMLTableAccessible::CacheChildren).
   nodeList->Item(1, getter_AddRefs(foundItem));
   return !!foundItem;
 }
 
-NS_IMETHODIMP
-nsHTMLTableAccessible::IsProbablyForLayout(bool *aIsProbablyForLayout)
+bool
+nsHTMLTableAccessible::IsProbablyLayoutTable()
 {
   // Implement a heuristic to determine if table is most likely used for layout
   // XXX do we want to look for rowspan or colspan, especialy that span all but a couple cells
   // at the beginning or end of a row/col, and especially when they occur at the edge of a table?
   // XXX expose this info via object attributes to AT-SPI
 
   // XXX For now debugging descriptions are always on via SHOW_LAYOUT_HEURISTIC
   // This will allow release trunk builds to be used by testers to refine the algorithm
   // Change to |#define SHOW_LAYOUT_HEURISTIC DEBUG| before final release
 #ifdef SHOW_LAYOUT_HEURISTIC
 #define RETURN_LAYOUT_ANSWER(isLayout, heuristic) \
-  { *aIsProbablyForLayout = isLayout; \
-    mLayoutHeuristic = isLayout ? NS_LITERAL_STRING("layout table: ") : NS_LITERAL_STRING("data table: "); \
-    mLayoutHeuristic += NS_LITERAL_STRING(heuristic); return NS_OK; }
+  { \
+    mLayoutHeuristic = isLayout ? \
+      NS_LITERAL_STRING("layout table: " heuristic) : \
+      NS_LITERAL_STRING("data table: " heuristic); \
+    return isLayout; \
+  }
 #else
-#define RETURN_LAYOUT_ANSWER(isLayout, heuristic) { *aIsProbablyForLayout = isLayout; return NS_OK; }
+#define RETURN_LAYOUT_ANSWER(isLayout, heuristic) { return isLayout; }
 #endif
 
-  *aIsProbablyForLayout = false;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   nsDocAccessible* docAccessible = Document();
   if (docAccessible) {
     PRUint64 docState = docAccessible->State();
     if (docState & states::EDITABLE) {  // Need to see all elements while document is being edited
       RETURN_LAYOUT_ANSWER(false, "In editable document");
     }
   }
 
--- a/accessible/src/html/nsHTMLTableAccessible.h
+++ b/accessible/src/html/nsHTMLTableAccessible.h
@@ -36,16 +36,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _nsHTMLTableAccessible_H_
 #define _nsHTMLTableAccessible_H_
 
 #include "nsHyperTextAccessibleWrap.h"
 #include "nsIAccessibleTable.h"
+#include "TableAccessible.h"
+#include "xpcAccessibleTable.h"
 
 class nsITableLayout;
 class nsITableCellLayout;
 
 /**
  * HTML table cell accessible (html:td).
  */
 class nsHTMLTableCellAccessible : public nsHyperTextAccessibleWrap,
@@ -116,40 +118,45 @@ public:
 {  /* 8d6d9c40-74bd-47ac-88dc-4a23516aa23d */           \
   0x8d6d9c40,                                           \
   0x74bd,                                               \
   0x47ac,                                               \
   { 0x88, 0xdc, 0x4a, 0x23, 0x51, 0x6a, 0xa2, 0x3d }    \
 }
 
 class nsHTMLTableAccessible : public nsAccessibleWrap,
-                              public nsIAccessibleTable
+                              public xpcAccessibleTable,
+                              public nsIAccessibleTable,
+                              public mozilla::a11y::TableAccessible
 {
 public:
   nsHTMLTableAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIACCESSIBLETABLE
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_TABLEACCESSIBLE_IMPL_CID)
 
+  // nsIAccessible Table
+  NS_DECL_OR_FORWARD_NSIACCESSIBLETABLE_WITH_XPCACCESSIBLETABLE
+
+  // TableAccessible
+  virtual nsAccessible* Caption();
+  virtual bool IsProbablyLayoutTable();
+
+  // nsAccessNode
+  virtual void Shutdown();
+
   // nsAccessible
+  virtual mozilla::a11y::TableAccessible* AsTable() { return this; }
   virtual void Description(nsString& aDescription);
   virtual nsresult GetNameInternal(nsAString& aName);
   virtual mozilla::a11y::role NativeRole();
   virtual PRUint64 NativeState();
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
   virtual Relation RelationByType(PRUint32 aRelationType);
 
-  // TableAccessible
-  inline nsAccessible* Caption() const
-  {
-    nsAccessible* child = mChildren.SafeElementAt(0, nsnull);
-    return child && child->Role() == mozilla::a11y::roles::CAPTION ? child : nsnull;
-  }
-
   // nsHTMLTableAccessible
 
   /**
    * Retun cell element at the given row and column index.
    */
   nsresult GetCellAt(PRInt32 aRowIndex, PRInt32 aColIndex,
                      nsIDOMElement* &aCell);
 
--- a/accessible/src/html/nsHTMLTextAccessible.cpp
+++ b/accessible/src/html/nsHTMLTextAccessible.cpp
@@ -199,17 +199,17 @@ nsHTMLOutputAccessible::
 
 NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLOutputAccessible, nsHyperTextAccessible)
 
 Relation
 nsHTMLOutputAccessible::RelationByType(PRUint32 aType)
 {
   Relation rel = nsAccessibleWrap::RelationByType(aType);
   if (aType == nsIAccessibleRelation::RELATION_CONTROLLED_BY)
-    rel.AppendIter(new IDRefsIterator(mContent, nsGkAtoms::_for));
+    rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::_for));
 
   return rel;
 }
 
 role
 nsHTMLOutputAccessible::NativeRole()
 {
   return roles::SECTION;
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -127,17 +127,17 @@ role
 nsHyperTextAccessible::NativeRole()
 {
   nsIAtom *tag = mContent->Tag();
 
   if (tag == nsGkAtoms::form)
     return roles::FORM;
 
   if (tag == nsGkAtoms::blockquote || tag == nsGkAtoms::div ||
-      tag == nsGkAtoms::nav)
+      tag == nsGkAtoms::section || tag == nsGkAtoms::nav)
     return roles::SECTION;
 
   if (tag == nsGkAtoms::h1 || tag == nsGkAtoms::h2 ||
       tag == nsGkAtoms::h3 || tag == nsGkAtoms::h4 ||
       tag == nsGkAtoms::h5 || tag == nsGkAtoms::h6)
     return roles::HEADING;
 
   if (tag == nsGkAtoms::article)
@@ -775,33 +775,32 @@ nsHyperTextAccessible::GetRelativeOffset
   const bool kIsVisualBidi = false;          // use visual order for bidi text
 
   EWordMovementType wordMovementType = aNeedsStart ? eStartWord : eEndWord;
   if (aAmount == eSelectLine) {
     aAmount = (aDirection == eDirNext) ? eSelectEndLine : eSelectBeginLine;
   }
 
   // Ask layout for the new node and offset, after moving the appropriate amount
-  nsPeekOffsetStruct pos;
 
   nsresult rv;
   PRInt32 contentOffset = aFromOffset;
   if (nsAccUtils::IsText(aFromAccessible)) {
     nsIFrame *frame = aFromAccessible->GetFrame();
     NS_ENSURE_TRUE(frame, -1);
 
     if (frame->GetType() == nsGkAtoms::textFrame) {
       rv = RenderedToContentOffset(frame, aFromOffset, &contentOffset);
       NS_ENSURE_SUCCESS(rv, -1);
     }
   }
 
-  pos.SetData(aAmount, aDirection, contentOffset,
-              0, kIsJumpLinesOk, kIsScrollViewAStop, kIsKeyboardSelect, kIsVisualBidi,
-              wordMovementType);
+  nsPeekOffsetStruct pos(aAmount, aDirection, contentOffset,
+                         0, kIsJumpLinesOk, kIsScrollViewAStop, kIsKeyboardSelect, kIsVisualBidi,
+                         wordMovementType);
   rv = aFromFrame->PeekOffset(&pos);
   if (NS_FAILED(rv)) {
     if (aDirection == eDirPrevious) {
       // Use passed-in frame as starting point in failure case for now,
       // this is a hack to deal with starting on a list bullet frame,
       // which fails in PeekOffset() because the line iterator doesn't see it.
       // XXX Need to look at our overall handling of list bullets, which are an odd case
       pos.mResultContent = aFromFrame->GetContent();
@@ -1219,32 +1218,35 @@ nsHyperTextAccessible::GetAttributesInte
   nsIFrame *frame = GetFrame();
   if (frame && frame->GetType() == nsGkAtoms::blockFrame) {
     nsAutoString oldValueUnused;
     aAttributes->SetStringProperty(NS_LITERAL_CSTRING("formatting"), NS_LITERAL_STRING("block"),
                                    oldValueUnused);
   }
 
   if (FocusMgr()->IsFocused(this)) {
-    PRInt32 lineNumber = GetCaretLineNumber();
+    PRInt32 lineNumber = CaretLineNumber();
     if (lineNumber >= 1) {
       nsAutoString strLineNumber;
       strLineNumber.AppendInt(lineNumber);
       nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::lineNumber,
                              strLineNumber);
     }
   }
 
   // For the html landmark elements we expose them like we do aria landmarks to
   // make AT navigation schemes "just work". Note html:header is redundant as
   // a landmark since it usually contains headings. We're not yet sure how the
   // web will use html:footer but our best bet right now is as contentinfo.
   if (mContent->Tag() == nsGkAtoms::nav)
     nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
                            NS_LITERAL_STRING("navigation"));
+  else if (mContent->Tag() == nsGkAtoms::section) 
+    nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
+                           NS_LITERAL_STRING("region"));
   else if (mContent->Tag() == nsGkAtoms::footer) 
     nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
                            NS_LITERAL_STRING("contentinfo"));
   else if (mContent->Tag() == nsGkAtoms::aside) 
     nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
                            NS_LITERAL_STRING("complementary"));
 
   return  NS_OK;
@@ -1675,17 +1677,17 @@ nsHyperTextAccessible::GetCaretOffset(PR
       return NS_OK;
   }
 
   DOMPointToHypertextOffset(focusNode, focusOffset, aCaretOffset);
   return NS_OK;
 }
 
 PRInt32
-nsHyperTextAccessible::GetCaretLineNumber()
+nsHyperTextAccessible::CaretLineNumber()
 {
   // Provide the line number for the caret, relative to the
   // currently focused node. Use a 1-based index
   nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
   if (!frameSelection)
     return -1;
 
   nsISelection* domSel =
--- a/accessible/src/html/nsHyperTextAccessible.h
+++ b/accessible/src/html/nsHyperTextAccessible.h
@@ -259,16 +259,32 @@ public:
    *
    * @param  aOffset  [in] the given text offset
    */
   nsAccessible* GetChildAtOffset(PRUint32 aOffset)
   {
     return GetChildAt(GetChildIndexAtOffset(aOffset));
   }
 
+  /**
+   * Return the bounds of the text between given start and end offset.
+   */
+  nsIntRect GetTextBounds(PRInt32 aStartOffset, PRInt32 aEndOffset)
+  {
+    nsIntRect bounds;
+    GetPosAndText(aStartOffset, aEndOffset, nsnull, nsnull, &bounds);
+    return bounds;
+  }
+
+  /**
+   * Provide the line number for the caret.
+   * @return 1-based index for the line number with the caret
+   */
+  PRInt32 CaretLineNumber();
+
   //////////////////////////////////////////////////////////////////////////////
   // EditableTextAccessible
 
   /**
    * Return the editor associated with the accessible.
    */
   virtual already_AddRefed<nsIEditor> GetEditor() const;
 
@@ -368,23 +384,16 @@ protected:
 
   /**
    * Return selection ranges within the accessible subtree.
    */
   void GetSelectionDOMRanges(PRInt16 aType, nsTArray<nsRange*>* aRanges);
 
   nsresult SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos);
 
-  /**
-   * Provide the line number for the caret, relative to the
-   * current DOM node.
-   * @return 1-based index for the line number with the caret
-   */
-  PRInt32 GetCaretLineNumber();
-
   // Helpers
   nsresult GetDOMPointByFrameOffset(nsIFrame *aFrame, PRInt32 aOffset,
                                     nsIAccessible *aAccessible,
                                     nsIDOMNode **aNode, PRInt32 *aNodeOffset);
 
   
   /**
    * Return hyper text offset for the specified bound of the given DOM range.
--- a/accessible/src/mac/mozAccessible.h
+++ b/accessible/src/mac/mozAccessible.h
@@ -39,16 +39,28 @@
 #include "nsAccessibleWrap.h"
 
 #import <Cocoa/Cocoa.h>
 
 #import "mozAccessibleProtocol.h"
 
 @class mozRootAccessible;
 
+/**
+ * All mozAccessibles are either abstract objects (that correspond to XUL
+ * widgets, HTML frames, etc) or are attached to a certain view; for example
+ * a document view. When we hand an object off to an AT, we always want
+ * to give it the represented view, in the latter case.
+ */
+inline id <mozAccessible>
+GetObjectOrRepresentedView(id <mozAccessible> aObject)
+{
+  return [aObject hasRepresentedView] ? [aObject representedView] : aObject;
+}
+
 @interface mozAccessible : NSObject <mozAccessible>
 {
   /**
    * Weak reference; it owns us.
    */
   nsAccessibleWrap* mGeckoAccessible;
   
   /**
@@ -119,16 +131,17 @@
 - (BOOL)canBeFocused;
 
 // returns NO if for some reason we were unable to focus the element.
 - (BOOL)focus;
 
 // notifications sent out to listening accessible providers.
 - (void)didReceiveFocus;
 - (void)valueDidChange;
+- (void)selectedTextDidChange;
 
 #pragma mark -
 
 // invalidates and removes all our children from our cached array.
 - (void)invalidateChildren;
 
 /** 
  * Append a child if they are already cached.
--- a/accessible/src/mac/mozAccessible.mm
+++ b/accessible/src/mac/mozAccessible.mm
@@ -66,31 +66,16 @@ using namespace mozilla::a11y;
 // of the screen), into a top-left screen point, that gecko can use.
 static inline void
 ConvertCocoaToGeckoPoint(NSPoint &aInPoint, nsPoint &aOutPoint)
 {
   float mainScreenHeight = [(NSView*)[[NSScreen screens] objectAtIndex:0] frame].size.height;
   aOutPoint.MoveTo ((nscoord)aInPoint.x, (nscoord)(mainScreenHeight - aInPoint.y));
 }
 
-// all mozAccessibles are either abstract objects (that correspond to XUL widgets, HTML frames, etc) or are
-// attached to a certain view; for example a document view. when we hand an object off to an AT, we always want
-// to give it the represented view, in the latter case.
-static inline id <mozAccessible>
-GetObjectOrRepresentedView(id <mozAccessible> anObject)
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  if ([anObject hasRepresentedView])
-    return [anObject representedView];
-  return anObject;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
-}
-
 // returns the passed in object if it is not ignored. if it's ignored, will return
 // the first unignored ancestor.
 static inline id
 GetClosestInterestingAccessible(id anObject)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   // this object is not ignored, so let's return it.
@@ -367,17 +352,17 @@ GetNativeFromGeckoAccessible(nsIAccessib
 
 - (id <mozAccessible>)parent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if (mParent)
     return mParent;
 
-  nsCOMPtr<nsIAccessible> accessibleParent(mGeckoAccessible->GetUnignoredParent());
+  nsAccessible* accessibleParent = mGeckoAccessible->GetUnignoredParent();
   if (accessibleParent) {
     id nativeParent = GetNativeFromGeckoAccessible(accessibleParent);
     if (nativeParent)
       return mParent = GetClosestInterestingAccessible(nativeParent);
   }
   
   // GetUnignoredParent() returns null when there is no unignored accessible all the way up to
   // the root accessible. so we'll have to return whatever native accessible is above our root accessible 
@@ -528,16 +513,21 @@ GetNativeFromGeckoAccessible(nsIAccessib
   NSLog(@"%@'s value changed!", self);
 #endif
   // sending out a notification is expensive, so we don't do it other than for really important objects,
   // like mozTextAccessible.
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
+- (void)selectedTextDidChange
+{
+  // Do nothing. mozTextAccessible will.
+}
+
 - (NSString*)customDescription
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if (mGeckoAccessible->IsDefunct())
     return nil;
 
   nsAutoString desc;
--- a/accessible/src/mac/mozTextAccessible.h
+++ b/accessible/src/mac/mozTextAccessible.h
@@ -5,18 +5,8 @@
 @interface mozTextAccessible : mozAccessible
 {
   // both of these are the same old mGeckoAccessible, but already
   // QI'd for us, to the right type, for convenience.
   nsHyperTextAccessible     *mGeckoTextAccessible;         // strong
   nsIAccessibleEditableText *mGeckoEditableTextAccessible; // strong
 }
 @end
-
-/* A combobox (in the mac world) is a textfield with an associated menu, for example
-   the location bar. */
-@interface mozComboboxAccessible : mozTextAccessible
-// equivalent to pressing return key in this textfield.
-- (void)confirm;
-
-// shows the menu for this combobox.
-- (void)showMenu;
-@end
--- a/accessible/src/mac/mozTextAccessible.mm
+++ b/accessible/src/mac/mozTextAccessible.mm
@@ -1,25 +1,54 @@
+/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
 #include "nsAccessibleWrap.h"
 
 #include "nsCocoaUtils.h"
 #include "nsObjCExceptions.h"
 
 #import "mozTextAccessible.h"
 
 using namespace mozilla::a11y;
 
-@interface mozTextAccessible (Private)
+inline bool
+ToNSRange(id aValue, NSRange* aRange)
+{
+  NS_PRECONDITION(aRange, "aRange is nil");
+
+  if ([aValue isKindOfClass:[NSValue class]] && 
+      strcmp([(NSValue*)aValue objCType], @encode(NSRange)) == 0) {
+    *aRange = [aValue rangeValue];
+    return true;
+  }
+
+  return false;
+}
+
+inline NSString*
+ToNSString(id aValue)
+{
+  if ([aValue isKindOfClass:[NSString class]]) {
+    return aValue;
+  }
+
+  return nil;
+}
+
+@interface mozTextAccessible ()
 - (NSString*)subrole;
 - (NSString*)selectedText;
 - (NSValue*)selectedTextRange;
+- (NSValue*)visibleCharacterRange;
 - (long)textLength;
 - (BOOL)isReadOnly;
+- (NSNumber*)caretLineNumber;
 - (void)setText:(NSString*)newText;
 - (NSString*)text;
+- (NSString*)stringFromRange:(NSRange*)range;
 @end
 
 @implementation mozTextAccessible
 
 - (id)initWithAccessible:(nsAccessibleWrap*)accessible
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
@@ -36,91 +65,230 @@ using namespace mozilla::a11y;
 {
   return mIsExpired;
 }
 
 - (NSArray*)accessibilityAttributeNames
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-  static NSArray *supportedAttributes = nil;
+  static NSMutableArray* supportedAttributes = nil;
   if (!supportedAttributes) {
-    // standard attributes that are shared and supported by all generic elements.
-    supportedAttributes = [[NSArray alloc] initWithObjects:NSAccessibilityParentAttribute, // required
-                                                           NSAccessibilityRoleAttribute,   // required
-                                                           NSAccessibilityTitleAttribute,
-                                                           NSAccessibilityValueAttribute, // required
-                                                           NSAccessibilitySubroleAttribute,
-                                                           NSAccessibilityRoleDescriptionAttribute,
-                                                           NSAccessibilityPositionAttribute, // required
-                                                           NSAccessibilitySizeAttribute, // required
-                                                           NSAccessibilityWindowAttribute, // required
-                                                           NSAccessibilityFocusedAttribute, // required
-                                                           NSAccessibilityEnabledAttribute, // required
-                                                           NSAccessibilityTopLevelUIElementAttribute, // required
-                                                           NSAccessibilityDescriptionAttribute, // required
-                                                           /* text-specific attributes */
-                                                           NSAccessibilitySelectedTextAttribute, // required
-                                                           NSAccessibilitySelectedTextRangeAttribute, // required
-                                                           NSAccessibilityNumberOfCharactersAttribute, // required
-                                                           // TODO: NSAccessibilityVisibleCharacterRangeAttribute, // required
-                                                           // TODO: NSAccessibilityInsertionPointLineNumberAttribute
-#if DEBUG
-                                                           @"AXMozDescription",
-#endif
-                                                           nil];
+    // text-specific attributes to supplement the standard one
+    supportedAttributes = [[NSMutableArray alloc] initWithObjects:
+      NSAccessibilitySelectedTextAttribute, // required
+      NSAccessibilitySelectedTextRangeAttribute, // required
+      NSAccessibilityNumberOfCharactersAttribute, // required
+      NSAccessibilityVisibleCharacterRangeAttribute, // required
+      NSAccessibilityInsertionPointLineNumberAttribute,
+      nil
+    ];
+    [supportedAttributes addObjectsFromArray:[super accessibilityAttributeNames]];
   }
   return supportedAttributes;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (id)accessibilityAttributeValue:(NSString*)attribute
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if ([attribute isEqualToString:NSAccessibilityNumberOfCharactersAttribute])
     return [NSNumber numberWithInt:[self textLength]];
+
+  if ([attribute isEqualToString:NSAccessibilityInsertionPointLineNumberAttribute])
+    return [self caretLineNumber];
+
   if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute])
     return [self selectedTextRange];
+
   if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute])
     return [self selectedText];
-  // Apple's SpeechSynthesisServer expects AXValue to return an AXStaticText
-  // object's AXSelectedText attribute.  See bug 674612.
-  // Also if there is no selected text, we return the full text.See bug 369710
-  if ([attribute isEqualToString:NSAccessibilityValueAttribute])
-    return [self selectedText] ? : [self text];
+
+  if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
+    // Apple's SpeechSynthesisServer expects AXValue to return an AXStaticText
+    // object's AXSelectedText attribute. See bug 674612 for details.
+    // Also if there is no selected text, we return the full text. 
+    // See bug 369710 for details.
+    if ([[self role] isEqualToString:NSAccessibilityStaticTextRole])
+      return [self selectedText] ? : [self text];
+
+    return [self text];
+  }
+
+  if ([attribute isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute])
+    return [self visibleCharacterRange];
 
   // let mozAccessible handle all other attributes
   return [super accessibilityAttributeValue:attribute];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
+- (NSArray*)accessibilityParameterizedAttributeNames
+{
+  static NSArray* supportedParametrizedAttributes = nil;
+  // text specific parametrized attributes
+  if (!supportedParametrizedAttributes) {
+    supportedParametrizedAttributes = [[NSArray alloc] initWithObjects:
+      NSAccessibilityStringForRangeParameterizedAttribute,
+      NSAccessibilityLineForIndexParameterizedAttribute,
+      NSAccessibilityRangeForLineParameterizedAttribute,
+      NSAccessibilityAttributedStringForRangeParameterizedAttribute,
+      NSAccessibilityBoundsForRangeParameterizedAttribute,
+#if DEBUG
+      NSAccessibilityRangeForPositionParameterizedAttribute,
+      NSAccessibilityRangeForIndexParameterizedAttribute,
+      NSAccessibilityRTFForRangeParameterizedAttribute,
+      NSAccessibilityStyleRangeForIndexParameterizedAttribute,
+#endif
+      nil
+    ];
+  }
+  return supportedParametrizedAttributes;
+}
+
+- (id)accessibilityAttributeValue:(NSString*)attribute forParameter:(id)parameter
+{
+  if (!mGeckoTextAccessible)
+    return nil;
+
+  if ([attribute isEqualToString:NSAccessibilityStringForRangeParameterizedAttribute]) {
+    NSRange range;
+    if (!ToNSRange(parameter, &range)) {
+#if DEBUG
+      NSLog(@"%@: range not set", attribute);
+#endif
+      return @"";
+    }
+
+    return [self stringFromRange:&range];
+  }
+
+  if ([attribute isEqualToString:NSAccessibilityRangeForLineParameterizedAttribute]) {
+    // XXX: actually get the integer value for the line #
+    return [NSValue valueWithRange:NSMakeRange(0, [self textLength])];
+  }
+
+  if ([attribute isEqualToString:NSAccessibilityAttributedStringForRangeParameterizedAttribute]) {
+    NSRange range;
+    if (!ToNSRange(parameter, &range)) {
+#if DEBUG
+      NSLog(@"%@: range not set", attribute);
+#endif
+      return @"";
+    }
+
+    return [[[NSAttributedString alloc] initWithString:[self stringFromRange:&range]] autorelease];
+  }
+
+  if ([attribute isEqualToString:NSAccessibilityLineForIndexParameterizedAttribute]) {
+    // XXX: actually return the line #
+    return [NSNumber numberWithInt:0];
+  }
+
+  if ([attribute isEqualToString:NSAccessibilityBoundsForRangeParameterizedAttribute]) {
+    NSRange range;
+    if (!ToNSRange(parameter, &range)) {
+#if DEBUG
+      NSLog(@"%@:no range", attribute);
+#endif
+      return nil;
+    }
+    
+    PRInt32 start = range.location;
+    PRInt32 end = start + range.length;
+    nsIntRect bounds = mGeckoTextAccessible->GetTextBounds(start, end);
+
+    return [NSValue valueWithRect:nsCocoaUtils::GeckoRectToCocoaRect(bounds)];
+  }
+
+#if DEBUG
+  NSLog(@"unhandled attribute:%@ forParameter:%@", attribute, parameter);
+#endif
+
+  return nil;
+}
+
 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   if ([attribute isEqualToString:NSAccessibilityValueAttribute])
     return [self isReadOnly];
   
+  if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute] ||
+      [attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute] ||
+      [attribute isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute])
+    return YES;
+
   return [super accessibilityIsAttributeSettable:attribute];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
 }
 
 - (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
+  if (!mGeckoTextAccessible)
+    return;
+
   if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
-    if ([value isKindOfClass:[NSString class]])
-      [self setText:(NSString*)value];
-  } else
-    [super accessibilitySetValue:value forAttribute:attribute];
+    [self setText:ToNSString(value)];
+    
+    return;
+  }
+
+  if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute]) {
+    NSString* stringValue = ToNSString(value);
+    if (!stringValue)
+      return;
+
+    PRInt32 start = 0;
+    PRInt32 end = 0;
+
+    nsresult rv = mGeckoTextAccessible->GetSelectionBounds(0, &start, &end);
+    NS_ENSURE_SUCCESS(rv,);
+    
+    rv = mGeckoTextAccessible->DeleteText(start, end - start);
+    NS_ENSURE_SUCCESS(rv,);
+
+    nsString text;
+    nsCocoaUtils::GetStringForNSString(stringValue, text);
+    rv = mGeckoTextAccessible->InsertText(text, start);
+    NS_ENSURE_SUCCESS(rv,);
+
+    return;
+  }
+
+  if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) {
+    NSRange range;
+    if (!ToNSRange(value, &range))
+      return;
+
+    nsresult rv = mGeckoTextAccessible->SetSelectionBounds(0, range.location, 
+                                                           range.location + range.length);
+    NS_ENSURE_SUCCESS(rv,);
+
+    return;
+  }
+
+  if ([attribute isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute]) {
+    NSRange range;
+    if (!ToNSRange(value, &range))
+      return;
+
+    mGeckoTextAccessible->ScrollSubstringTo(range.location, range.location + range.length,
+                                            nsIAccessibleScrollType::SCROLL_TYPE_TOP_EDGE);
+    return;
+  } 
+
+  [super accessibilitySetValue:value forAttribute:attribute];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (NSString*)subrole
 {
   // TODO: text accessibles have two different subroles in Cocoa: secure textfield (passwords) and search field
   return nil;
@@ -149,16 +317,24 @@ using namespace mozilla::a11y;
   if (mGeckoEditableTextAccessible)
     return (mGeckoAccessible->State() & states::READONLY) == 0;
 
   return NO;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
 }
 
+- (NSNumber*)caretLineNumber
+{
+  PRInt32 lineNumber = mGeckoTextAccessible ?
+    mGeckoTextAccessible->CaretLineNumber() - 1 : -1;
+
+  return (lineNumber >= 0) ? [NSNumber numberWithInt:lineNumber] : nil;
+}
+
 - (void)setText:(NSString*)newString
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (mGeckoEditableTextAccessible) {
     mGeckoEditableTextAccessible->SetTextContents(NS_ConvertUTF8toUTF16([newString UTF8String]));
   }
 
@@ -190,17 +366,19 @@ using namespace mozilla::a11y;
 
 - (long)selectedTextLength
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   if (mGeckoTextAccessible) {
     PRInt32 start, end;
     start = end = 0;
-    mGeckoTextAccessible->GetSelectionBounds(0, &start, &end);
+    nsresult rv = mGeckoTextAccessible->GetSelectionBounds(0, &start, &end);
+    NS_ENSURE_SUCCESS(rv, 0);
+
     return (end - start);
   }
   return 0;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
 }
 
 - (NSString*)selectedText
@@ -222,128 +400,68 @@ using namespace mozilla::a11y;
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (NSValue*)selectedTextRange
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if (mGeckoTextAccessible) {
-    PRInt32 start, end;
-    start = end = 0;
-    mGeckoTextAccessible->GetSelectionBounds(0, &start, &end);
-    return [NSValue valueWithRange:NSMakeRange(start, start-end)];
+    PRInt32 start = 0;
+    PRInt32 end = 0;
+    PRInt32 count = 0;
+
+    nsresult rv = mGeckoTextAccessible->GetSelectionCount(&count);
+    NS_ENSURE_SUCCESS(rv, nil);
+
+    if (count) {
+      rv = mGeckoTextAccessible->GetSelectionBounds(0, &start, &end);
+      NS_ENSURE_SUCCESS(rv, nil);
+
+      return [NSValue valueWithRange:NSMakeRange(start, end - start)];
+    }
+
+    rv = mGeckoTextAccessible->GetCaretOffset(&start);
+    NS_ENSURE_SUCCESS(rv, nil);
+    
+    return [NSValue valueWithRange:NSMakeRange(start != -1 ? start : 0, 0)]; 
   }
-  return nil;
+  return [NSValue valueWithRange:NSMakeRange(0, 0)];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
-#pragma mark -
+- (NSValue*)visibleCharacterRange
+{
+  // XXX this won't work with Textarea and such as we actually don't give
+  // the visible character range.
+  return [NSValue valueWithRange:
+    NSMakeRange(0, mGeckoTextAccessible ? 
+                mGeckoTextAccessible->CharacterCount() : 0)];
+}
 
 - (void)valueDidChange
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
-  NSAccessibilityPostNotification([self hasRepresentedView] ? [self representedView] : self, 
+  NSAccessibilityPostNotification(GetObjectOrRepresentedView(self),
                                   NSAccessibilityValueChangedNotification);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-@end
-
-@implementation mozComboboxAccessible
-
-- (NSArray*)accessibilityAttributeNames
+- (void)selectedTextDidChange
 {
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  static NSArray *supportedAttributes = nil;
-  if (!supportedAttributes) {
-    // standard attributes that are shared and supported by all generic elements.
-    supportedAttributes = [[NSArray alloc] initWithObjects:NSAccessibilityParentAttribute, // required
-                                                           NSAccessibilityRoleAttribute,   // required
-                                                           NSAccessibilityTitleAttribute,
-                                                           NSAccessibilityValueAttribute, // required
-                                                           NSAccessibilityHelpAttribute,
-                                                           NSAccessibilityRoleDescriptionAttribute,
-                                                           NSAccessibilityPositionAttribute, // required
-                                                           NSAccessibilitySizeAttribute, // required
-                                                           NSAccessibilityWindowAttribute, // required
-                                                           NSAccessibilityFocusedAttribute, // required
-                                                           NSAccessibilityEnabledAttribute, // required
-                                                           NSAccessibilityChildrenAttribute, // required
-                                                           NSAccessibilityHelpAttribute,
-                                                           // NSAccessibilityExpandedAttribute, // required
-                                                           NSAccessibilityTopLevelUIElementAttribute, // required
-                                                           NSAccessibilityDescriptionAttribute, // required
-                                                           /* text-specific attributes */
-                                                           NSAccessibilitySelectedTextAttribute, // required
-                                                           NSAccessibilitySelectedTextRangeAttribute, // required
-                                                           NSAccessibilityNumberOfCharactersAttribute, // required
-                                                           // TODO: NSAccessibilityVisibleCharacterRangeAttribute, // required
-                                                           // TODO: NSAccessibilityInsertionPointLineNumberAttribute
-#if DEBUG
-                                                           @"AXMozDescription",
-#endif
-                                                           nil];
-  }
-  return supportedAttributes;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
+  NSAccessibilityPostNotification(GetObjectOrRepresentedView(self),
+                                  NSAccessibilitySelectedTextChangedNotification);
 }
 
-- (NSArray *)accessibilityActionNames
+- (NSString*)stringFromRange:(NSRange*)range
 {
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  if ([self isEnabled]) {
-    return [NSArray arrayWithObjects:NSAccessibilityConfirmAction,
-                                     NSAccessibilityShowMenuAction,
-                                     nil];
-  }
-  return nil;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
-}
-
-- (NSString *)accessibilityActionDescription:(NSString *)action
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  if ([action isEqualToString:NSAccessibilityShowMenuAction])
-    return @"show menu";
-  if ([action isEqualToString:NSAccessibilityConfirmAction])
-    return @"confirm";
-    
-  return [super accessibilityActionDescription:action];
+  NS_PRECONDITION(mGeckoTextAccessible && range, "no Gecko text accessible or range");
 
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
-}
-
-- (void)accessibilityPerformAction:(NSString *)action
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  // both the ShowMenu and Click action do the same thing.
-  if ([self isEnabled]) {
-    if ([action isEqualToString:NSAccessibilityShowMenuAction])
-      [self showMenu];
-    if ([action isEqualToString:NSAccessibilityConfirmAction])
-      [self confirm];
-  }
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
-- (void)showMenu
-{
-  // currently unimplemented. waiting for support in bug 363697
-}
-
-- (void)confirm
-{
-  // should be the same as pressing enter/return in this textfield.
-  // not yet implemented
+  nsAutoString text;
+  mGeckoTextAccessible->GetText(range->location, 
+                                range->location + range->length, text);
+  return nsCocoaUtils::ToNSString(text);
 }
 
 @end
--- a/accessible/src/mac/nsAccessibleWrap.h
+++ b/accessible/src/mac/nsAccessibleWrap.h
@@ -95,17 +95,17 @@ public: // construction, destruction
   inline bool HasPopup () 
     { return (NativeState() & mozilla::a11y::states::HASPOPUP); }
   
   /**
    * Returns this accessible's all children, adhering to "flat" accessibles by 
    * not returning their children.
    */
   void GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> >& aChildrenArray);
-  virtual already_AddRefed<nsIAccessible> GetUnignoredParent();
+  nsAccessible* GetUnignoredParent() const;
     
 protected:
 
   virtual nsresult FirePlatformEvent(AccEvent* aEvent);
 
   /**
    * Return true if the parent doesn't have children to expose to AT.
    */
--- a/accessible/src/mac/nsAccessibleWrap.mm
+++ b/accessible/src/mac/nsAccessibleWrap.mm
@@ -105,19 +105,16 @@ nsAccessibleWrap::GetNativeType ()
     }
     
     case roles::PAGETAB:
       return [mozButtonAccessible class];
 
     case roles::CHECKBUTTON:
       return [mozCheckboxAccessible class];
       
-    case roles::AUTOCOMPLETE:
-      return [mozComboboxAccessible class];
-
     case roles::HEADING:
       return [mozHeadingAccessible class];
 
     case roles::PAGETABLIST:
       return [mozTabsAccessible class];
       
     case roles::ENTRY:
     case roles::STATICTEXT:
@@ -177,19 +174,22 @@ nsAccessibleWrap::HandleAccEvent(AccEven
 
 nsresult
 nsAccessibleWrap::FirePlatformEvent(AccEvent* aEvent)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   PRUint32 eventType = aEvent->GetEventType();
 
-  // ignore everything but focus-changed and value-changed events for now.
+  // ignore everything but focus-changed, value-changed, caret and selection
+  // events for now.
   if (eventType != nsIAccessibleEvent::EVENT_FOCUS &&
-      eventType != nsIAccessibleEvent::EVENT_VALUE_CHANGE)
+      eventType != nsIAccessibleEvent::EVENT_VALUE_CHANGE &&
+      eventType != nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED &&
+      eventType != nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED)
     return NS_OK;
 
   nsAccessible *accessible = aEvent->GetAccessible();
   NS_ENSURE_STATE(accessible);
 
   mozAccessible *nativeAcc = nil;
   accessible->GetNativeInterface((void**)&nativeAcc);
   if (!nativeAcc)
@@ -197,16 +197,20 @@ nsAccessibleWrap::FirePlatformEvent(AccE
 
   switch (eventType) {
     case nsIAccessibleEvent::EVENT_FOCUS:
       [nativeAcc didReceiveFocus];
       break;
     case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
       [nativeAcc valueDidChange];
       break;
+    case nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED:
+    case nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED:
+      [nativeAcc selectedTextDidChange];
+      break;
   }
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 void
@@ -279,31 +283,25 @@ nsAccessibleWrap::GetUnignoredChildren(n
         }
       }
     } else
       // simply add the element, since it's not ignored.
       aChildrenArray.AppendElement(childAcc);
   }
 }
 
-already_AddRefed<nsIAccessible>
-nsAccessibleWrap::GetUnignoredParent()
+nsAccessible*
+nsAccessibleWrap::GetUnignoredParent() const
 {
+  // Go up the chain to find a parent that is not ignored.
   nsAccessibleWrap* parentWrap = static_cast<nsAccessibleWrap*>(Parent());
-  if (!parentWrap)
-    return nsnull;
+  while (parentWrap && parentWrap->IsIgnored()) 
+    parentWrap = static_cast<nsAccessibleWrap*>(parentWrap->Parent());
     
-  // recursively return the parent, until we find one that is not ignored.
-  if (parentWrap->IsIgnored())
-    return parentWrap->GetUnignoredParent();
-  
-  nsIAccessible *outValue = nsnull;
-  NS_IF_ADDREF(outValue = parentWrap);
-  
-  return outValue;
+  return parentWrap;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessibleWrap protected
 
 bool
 nsAccessibleWrap::AncestorIsFlat()
 {
--- a/accessible/src/mac/nsRoleMap.h
+++ b/accessible/src/mac/nsRoleMap.h
@@ -37,135 +37,136 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #import <Cocoa/Cocoa.h>
 
 #include "nsIAccessible.h"
 
 static const NSString* AXRoles [] = {
-  NSAccessibilityUnknownRole,                   // ROLE_NOTHING
-  NSAccessibilityUnknownRole,                   // ROLE_TITLEBAR. (irrelevant on OS X; windows are always native.)
-  NSAccessibilityMenuBarRole,                   // ROLE_MENUBAR. (irrelevant on OS X; the menubar will always be native and on the top of the screen.)
-  NSAccessibilityScrollBarRole,                 // ROLE_SCROLLBAR. we might need to make this its own mozAccessible, to support the children objects (valueindicator, down/up buttons).
-  NSAccessibilitySplitterRole,                  // ROLE_GRIP
-  NSAccessibilityUnknownRole,                   // ROLE_SOUND. unused on OS X
-  NSAccessibilityUnknownRole,                   // ROLE_CURSOR. unused on OS X
-  NSAccessibilityUnknownRole,                   // ROLE_CARET. unused on OS X
-  NSAccessibilityWindowRole,                    // ROLE_ALERT
-  NSAccessibilityWindowRole,                    // ROLE_WINDOW. irrelevant on OS X; all window a11y is handled by the system.
-  NSAccessibilityScrollAreaRole,                // ROLE_INTERNAL_FRAME
-  NSAccessibilityMenuRole,                      // ROLE_MENUPOPUP. the parent of menuitems
-  NSAccessibilityMenuItemRole,                  // ROLE_MENUITEM.
-  @"AXHelpTag",                                 // ROLE_TOOLTIP. 10.4+ only, so we re-define the constant.
-  NSAccessibilityGroupRole,                     // ROLE_APPLICATION. unused on OS X. the system will take care of this.
-  @"AXWebArea",                                 // ROLE_DOCUMENT
-  NSAccessibilityGroupRole,                     // ROLE_PANE
-  NSAccessibilityUnknownRole,                   // ROLE_CHART
-  NSAccessibilityWindowRole,                    // ROLE_DIALOG. there's a dialog subrole.
-  NSAccessibilityUnknownRole,                   // ROLE_BORDER. unused on OS X
-  NSAccessibilityGroupRole,                     // ROLE_GROUPING
-  NSAccessibilityUnknownRole,                   // ROLE_SEPARATOR
-  NSAccessibilityToolbarRole,                   // ROLE_TOOLBAR
-  NSAccessibilityUnknownRole,                   // ROLE_STATUSBAR. doesn't exist on OS X (a status bar is its parts; a progressbar, a label, etc.)
-  NSAccessibilityGroupRole,                     // ROLE_TABLE
-  NSAccessibilityGroupRole,                     // ROLE_COLUMNHEADER
-  NSAccessibilityGroupRole,                     // ROLE_ROWHEADER
-  NSAccessibilityColumnRole,                    // ROLE_COLUMN
-  NSAccessibilityRowRole,                       // ROLE_ROW
-  NSAccessibilityGroupRole,                     // ROLE_CELL
-  @"AXLink",                                    // ROLE_LINK. 10.4+ the attr first define in SDK 10.4, so we define it here too. ROLE_LINK
-  @"AXHelpTag",                                 // ROLE_HELPBALLOON
-  NSAccessibilityUnknownRole,                   // ROLE_CHARACTER. unused on OS X
-  NSAccessibilityListRole,                      // ROLE_LIST
-  NSAccessibilityRowRole,                       // ROLE_LISTITEM
-  NSAccessibilityOutlineRole,                   // ROLE_OUTLINE
-  NSAccessibilityRowRole,                       // ROLE_OUTLINEITEM. XXX: use OutlineRow as subrole.
-  NSAccessibilityRadioButtonRole,               // ROLE_PAGETAB
-  NSAccessibilityGroupRole,                     // ROLE_PROPERTYPAGE
-  NSAccessibilityUnknownRole,                   // ROLE_INDICATOR
-  NSAccessibilityImageRole,                     // ROLE_GRAPHIC
-  NSAccessibilityStaticTextRole,                // ROLE_STATICTEXT
-  NSAccessibilityStaticTextRole,                // ROLE_TEXT_LEAF
-  NSAccessibilityButtonRole,                    // ROLE_PUSHBUTTON
-  NSAccessibilityCheckBoxRole,                  // ROLE_CHECKBUTTON
-  NSAccessibilityRadioButtonRole,               // ROLE_RADIOBUTTON
-  NSAccessibilityPopUpButtonRole,               // ROLE_COMBOBOX
-  NSAccessibilityPopUpButtonRole,               // ROLE_DROPLIST.
-  NSAccessibilityProgressIndicatorRole,         // ROLE_PROGRESSBAR
-  NSAccessibilityUnknownRole,                   // ROLE_DIAL
-  NSAccessibilityUnknownRole,                   // ROLE_HOTKEYFIELD
-  NSAccessibilitySliderRole,                    // ROLE_SLIDER
-  NSAccessibilityIncrementorRole,               // ROLE_SPINBUTTON. subroles: Increment/Decrement.
-  NSAccessibilityUnknownRole,                   // ROLE_DIAGRAM
-  NSAccessibilityUnknownRole,                   // ROLE_ANIMATION
-  NSAccessibilityUnknownRole,                   // ROLE_EQUATION
-  NSAccessibilityPopUpButtonRole,               // ROLE_BUTTONDROPDOWN.
-  NSAccessibilityMenuButtonRole,                // ROLE_BUTTONMENU
-  NSAccessibilityGroupRole,                     // ROLE_BUTTONDROPDOWNGRID
-  NSAccessibilityUnknownRole,                   // ROLE_WHITESPACE
-  NSAccessibilityTabGroupRole,                  // ROLE_PAGETABLIST
-  NSAccessibilityUnknownRole,                   // ROLE_CLOCK. unused on OS X
-  NSAccessibilityButtonRole,                    // ROLE_SPLITBUTTON
-  NSAccessibilityUnknownRole,                   // ROLE_IPADDRESS
-  NSAccessibilityStaticTextRole,                // ROLE_ACCEL_LABEL
-  NSAccessibilityUnknownRole,                   // ROLE_ARROW
-  NSAccessibilityImageRole,                     // ROLE_CANVAS
-  NSAccessibilityMenuItemRole,                  // ROLE_CHECK_MENU_ITEM
-  NSAccessibilityColorWellRole,                 // ROLE_COLOR_CHOOSER
-  NSAccessibilityUnknownRole,                   // ROLE_DATE_EDITOR
-  NSAccessibilityImageRole,                     // ROLE_DESKTOP_ICON
-  NSAccessibilityUnknownRole,                   // ROLE_DESKTOP_FRAME
-  NSAccessibilityBrowserRole,                   // ROLE_DIRECTORY_PANE
-  NSAccessibilityUnknownRole,                   // ROLE_FILE_CHOOSER. unused on OS X
-  NSAccessibilityUnknownRole,                   // ROLE_FONT_CHOOSER
-  NSAccessibilityUnknownRole,                   // ROLE_CHROME_WINDOW. unused on OS X
-  NSAccessibilityGroupRole,                     // ROLE_GLASS_PANE
-  NSAccessibilityUnknownRole,                   // ROLE_HTML_CONTAINER
-  NSAccessibilityImageRole,                     // ROLE_ICON
-  NSAccessibilityStaticTextRole,                // ROLE_LABEL
-  NSAccessibilityGroupRole,                     // ROLE_LAYERED_PANE
-  NSAccessibilityGroupRole,                     // ROLE_OPTION_PANE
-  NSAccessibilityTextFieldRole,                 // ROLE_PASSWORD_TEXT
-  NSAccessibilityUnknownRole,                   // ROLE_POPUP_MENU. unused
-  NSAccessibilityMenuItemRole,                  // ROLE_RADIO_MENU_ITEM
-  NSAccessibilityGroupRole,                     // ROLE_ROOT_PANE
-  NSAccessibilityScrollAreaRole,                // ROLE_SCROLL_PANE
-  NSAccessibilitySplitGroupRole,                // ROLE_SPLIT_PANE
-  NSAccessibilityUnknownRole,                   // ROLE_TABLE_COLUMN_HEADER
-  NSAccessibilityUnknownRole,                   // ROLE_TABLE_ROW_HEADER
-  NSAccessibilityMenuItemRole,                  // ROLE_TEAR_OFF_MENU_ITEM
-  NSAccessibilityUnknownRole,                   // ROLE_TERMINAL
-  NSAccessibilityGroupRole,                     // ROLE_TEXT_CONTAINER
-  NSAccessibilityButtonRole,                    // ROLE_TOGGLE_BUTTON
-  NSAccessibilityTableRole,                     // ROLE_TREE_TABLE
-  NSAccessibilityUnknownRole,                   // ROLE_VIEWPORT
-  NSAccessibilityGroupRole,                     // ROLE_HEADER
-  NSAccessibilityGroupRole,                     // ROLE_FOOTER
-  NSAccessibilityGroupRole,                     // ROLE_PARAGRAPH
-  @"AXRuler",                                   // ROLE_RULER. 10.4+ only, so we re-define the constant.
-  NSAccessibilityComboBoxRole,                  // ROLE_AUTOCOMPLETE
-  NSAccessibilityTextFieldRole,                 // ROLE_EDITBAR
-  NSAccessibilityTextFieldRole,                 // ROLE_ENTRY
-  NSAccessibilityStaticTextRole,                // ROLE_CAPTION
-  NSAccessibilityScrollAreaRole,                // ROLE_DOCUMENT_FRAME
-  @"AXHeading",                                 // ROLE_HEADING
-  NSAccessibilityGroupRole,                     // ROLE_PAG
-  NSAccessibilityGroupRole,                     // ROLE_SECTION
-  NSAccessibilityUnknownRole,                   // ROLE_REDUNDANT_OBJECT
-  NSAccessibilityGroupRole,                     // ROLE_FORM
-  NSAccessibilityUnknownRole,                   // ROLE_IME
-  NSAccessibilityUnknownRole,                   // ROLE_APP_ROOT. unused on OS X
-  NSAccessibilityMenuItemRole,                  // ROLE_PARENT_MENUITEM
-  NSAccessibilityGroupRole,                     // ROLE_CALENDAR
-  NSAccessibilityMenuRole,                      // ROLE_COMBOBOX_LIST
-  NSAccessibilityMenuItemRole,                  // ROLE_COMBOBOX_OPTION
-  NSAccessibilityImageRole,                     // ROLE_IMAGE_MAP
-  NSAccessibilityRowRole,                       // ROLE_OPTION
-  NSAccessibilityRowRole,                       // ROLE_RICH_OPTION
-  NSAccessibilityListRole,                      // ROLE_LISTBOX
-  NSAccessibilityUnknownRole,                   // ROLE_FLAT_EQUATION
-  NSAccessibilityGroupRole,                     // ROLE_GRID_CELL
-  NSAccessibilityGroupRole,                     // ROLE_EMBEDDED_OBJECT
-  NSAccessibilityGroupRole,                     // ROLE_NOTE
-  NSAccessibilityGroupRole,                     // ROLE_FIGURE
-  @"ROLE_LAST_ENTRY"                            // ROLE_LAST_ENTRY. bogus role that will never be shown (just marks the end of this array)!
+  NSAccessibilityUnknownRole,                   // roles::NOTHING              0
+  NSAccessibilityUnknownRole,                   // roles::TITLEBAR             1      Irrelevant on OS X; windows are always native.
+  NSAccessibilityScrollBarRole,                 // roles::SCROLLBAR            3      We might need to make this its own mozAccessible, to support the children objects (valueindicator, down/up buttons).
+  NSAccessibilityMenuBarRole,                   // roles::MENUBAR              2      Irrelevant on OS X; the menubar will always be native and on the top of the screen.
+  NSAccessibilitySplitterRole,                  // roles::GRIP                 4
+  NSAccessibilityUnknownRole,                   // roles::SOUND                5      Unused on OS X.
+  NSAccessibilityUnknownRole,                   // roles::CURSOR               6      Unused on OS X.
+  NSAccessibilityUnknownRole,                   // roles::CARET                7      Unused on OS X.
+  NSAccessibilityWindowRole,                    // roles::ALERT                8
+  NSAccessibilityWindowRole,                    // roles::WINDOW               9      Irrelevant on OS X; all window a11y is handled by the system.
+  NSAccessibilityScrollAreaRole,                // roles::INTERNAL_FRAME       10
+  NSAccessibilityMenuRole,                      // roles::MENUPOPUP            11     The parent of menuitems.
+  NSAccessibilityMenuItemRole,                  // roles::MENUITEM             12
+  @"AXHelpTag",                                 // roles::TOOLTIP              13     10.4+ only, so we re-define the constant.
+  NSAccessibilityGroupRole,                     // roles::APPLICATION          14     Unused on OS X. the system will take care of this.
+  @"AXWebArea",                                 // roles::DOCUMENT             15
+  NSAccessibilityGroupRole,                     // roles::PANE                 16
+  NSAccessibilityUnknownRole,                   // roles::CHART                17
+  NSAccessibilityWindowRole,                    // roles::DIALOG               18     There's a dialog subrole.
+  NSAccessibilityUnknownRole,                   // roles::BORDER               19     Unused on OS X.
+  NSAccessibilityGroupRole,                     // roles::GROUPING             20
+  NSAccessibilityUnknownRole,                   // roles::SEPARATOR            21
+  NSAccessibilityToolbarRole,                   // roles::TOOLBAR              22
+  NSAccessibilityUnknownRole,                   // roles::STATUSBAR            23     Doesn't exist on OS X (a status bar is its parts; a progressbar, a label, etc.)
+  NSAccessibilityGroupRole,                     // roles::TABLE                24
+  NSAccessibilityGroupRole,                     // roles::COLUMNHEADER         25
+  NSAccessibilityGroupRole,                     // roles::ROWHEADER            26
+  NSAccessibilityColumnRole,                    // roles::COLUMN               27
+  NSAccessibilityRowRole,                       // roles::ROW                  28
+  NSAccessibilityGroupRole,                     // roles::CELL                 29
+  @"AXLink",                                    // roles::LINK                 30     10.4+ the attr first define in SDK 10.4, so we define it here too. ROLE_LINK
+  @"AXHelpTag",                                 // roles::HELPBALLOON          31
+  NSAccessibilityUnknownRole,                   // roles::CHARACTER            32     Unused on OS X.
+  NSAccessibilityListRole,                      // roles::LIST                 33
+  NSAccessibilityRowRole,                       // roles::LISTITEM             34
+  NSAccessibilityOutlineRole,                   // roles::OUTLINE              35
+  NSAccessibilityRowRole,                       // roles::OUTLINEITEM          36     XXX: use OutlineRow as subrole.
+  NSAccessibilityRadioButtonRole,               // roles::PAGETAB              37
+  NSAccessibilityGroupRole,                     // roles::PROPERTYPAGE         38
+  NSAccessibilityUnknownRole,                   // roles::INDICATOR            39
+  NSAccessibilityImageRole,                     // roles::GRAPHIC              40
+  NSAccessibilityStaticTextRole,                // roles::STATICTEXT           41
+  NSAccessibilityStaticTextRole,                // roles::TEXT_LEAF            42
+  NSAccessibilityButtonRole,                    // roles::PUSHBUTTON           43
+  NSAccessibilityCheckBoxRole,                  // roles::CHECKBUTTON          44
+  NSAccessibilityRadioButtonRole,               // roles::RADIOBUTTON          45
+  NSAccessibilityPopUpButtonRole,               // roles::COMBOBOX             46
+  NSAccessibilityPopUpButtonRole,               // roles::DROPLIST             47
+  NSAccessibilityProgressIndicatorRole,         // roles::PROGRESSBAR          48
+  NSAccessibilityUnknownRole,                   // roles::DIAL                 49
+  NSAccessibilityUnknownRole,                   // roles::HOTKEYFIELD          50
+  NSAccessibilitySliderRole,                    // roles::SLIDER               51
+  NSAccessibilityIncrementorRole,               // roles::SPINBUTTON           52     Subroles: Increment/Decrement.
+  NSAccessibilityUnknownRole,                   // roles::DIAGRAM              53
+  NSAccessibilityUnknownRole,                   // roles::ANIMATION            54
+  NSAccessibilityUnknownRole,                   // roles::EQUATION             55
+  NSAccessibilityPopUpButtonRole,               // roles::BUTTONDROPDOWN       56
+  NSAccessibilityMenuButtonRole,                // roles::BUTTONMENU           57
+  NSAccessibilityGroupRole,                     // roles::BUTTONDROPDOWNGRID   58
+  NSAccessibilityUnknownRole,                   // roles::WHITESPACE           59
+  NSAccessibilityTabGroupRole,                  // roles::PAGETABLIST          60
+  NSAccessibilityUnknownRole,                   // roles::CLOCK                61     Unused on OS X
+  NSAccessibilityButtonRole,                    // roles::SPLITBUTTON          62
+  NSAccessibilityUnknownRole,                   // roles::IPADDRESS            63
+  NSAccessibilityStaticTextRole,                // roles::ACCEL_LABEL          64
+  NSAccessibilityUnknownRole,                   // roles::ARROW                65
+  NSAccessibilityImageRole,                     // roles::CANVAS               66
+  NSAccessibilityMenuItemRole,                  // roles::CHECK_MENU_ITEM      67
+  NSAccessibilityColorWellRole,                 // roles::COLOR_CHOOSER        68
+  NSAccessibilityUnknownRole,                   // roles::DATE_EDITOR          69 
+  NSAccessibilityImageRole,                     // roles::DESKTOP_ICON         70
+  NSAccessibilityUnknownRole,                   // roles::DESKTOP_FRAME        71
+  NSAccessibilityBrowserRole,                   // roles::DIRECTORY_PANE       72
+  NSAccessibilityUnknownRole,                   // roles::FILE_CHOOSER         73     Unused on OS X
+  NSAccessibilityUnknownRole,                   // roles::FONT_CHOOSER         74
+  NSAccessibilityUnknownRole,                   // roles::CHROME_WINDOW        75     Unused on OS X
+  NSAccessibilityGroupRole,                     // roles::GLASS_PANE           76
+  NSAccessibilityUnknownRole,                   // roles::HTML_CONTAINER       77
+  NSAccessibilityImageRole,                     // roles::ICON                 78
+  NSAccessibilityStaticTextRole,                // roles::LABEL                79
+  NSAccessibilityGroupRole,                     // roles::LAYERED_PANE         80
+  NSAccessibilityGroupRole,                     // roles::OPTION_PANE          81
+  NSAccessibilityTextFieldRole,                 // roles::PASSWORD_TEXT        82
+  NSAccessibilityUnknownRole,                   // roles::POPUP_MENU           83     Unused
+  NSAccessibilityMenuItemRole,                  // roles::RADIO_MENU_ITEM      84
+  NSAccessibilityGroupRole,                     // roles::ROOT_PANE            85
+  NSAccessibilityScrollAreaRole,                // roles::SCROLL_PANE          86
+  NSAccessibilitySplitGroupRole,                // roles::SPLIT_PANE           87
+  NSAccessibilityUnknownRole,                   // roles::TABLE_COLUMN_HEADER  88
+  NSAccessibilityUnknownRole,                   // roles::TABLE_ROW_HEADER     89
+  NSAccessibilityMenuItemRole,                  // roles::TEAR_OFF_MENU_ITEM   90
+  NSAccessibilityUnknownRole,                   // roles::TERMINAL             91
+  NSAccessibilityGroupRole,                     // roles::TEXT_CONTAINER       92
+  NSAccessibilityButtonRole,                    // roles::TOGGLE_BUTTON        93
+  NSAccessibilityTableRole,                     // roles::TREE_TABLE           94
+  NSAccessibilityUnknownRole,                   // roles::VIEWPORT             95
+  NSAccessibilityGroupRole,                     // roles::HEADER               96
+  NSAccessibilityGroupRole,                     // roles::FOOTER               97
+  NSAccessibilityGroupRole,                     // roles::PARAGRAPH            98
+  @"AXRuler",                                   // roles::RULER                99     10.4+ only, so we re-define the constant.
+  NSAccessibilityComboBoxRole,                  // roles::AUTOCOMPLETE         100
+  NSAccessibilityTextFieldRole,                 // roles::EDITBAR              101
+  NSAccessibilityTextFieldRole,                 // roles::ENTRY                102
+  NSAccessibilityStaticTextRole,                // roles::CAPTION              103
+  NSAccessibilityScrollAreaRole,                // roles::DOCUMENT_FRAME       104
+  @"AXHeading",                                 // roles::HEADING              105
+  NSAccessibilityGroupRole,                     // roles::PAGE                 106
+  NSAccessibilityGroupRole,                     // roles::SECTION              107
+  NSAccessibilityUnknownRole,                   // roles::REDUNDANT_OBJECT     108
+  NSAccessibilityGroupRole,                     // roles::FORM                 109
+  NSAccessibilityUnknownRole,                   // roles::IME                  110
+  NSAccessibilityUnknownRole,                   // roles::APP_ROOT             111    Unused on OS X
+  NSAccessibilityMenuItemRole,                  // roles::PARENT_MENUITEM      112
+  NSAccessibilityGroupRole,                     // roles::CALENDAR             113
+  NSAccessibilityMenuRole,                      // roles::COMBOBOX_LIST        114
+  NSAccessibilityMenuItemRole,                  // roles::COMBOBOX_OPTION      115
+  NSAccessibilityImageRole,                     // roles::IMAGE_MAP            116
+  NSAccessibilityRowRole,                       // roles::OPTION               117
+  NSAccessibilityRowRole,                       // roles::RICH_OPTION          118
+  NSAccessibilityListRole,                      // roles::LISTBOX              119
+  NSAccessibilityUnknownRole,                   // roles::FLAT_EQUATION        120
+  NSAccessibilityGroupRole,                     // roles::GRID_CELL            121
+  NSAccessibilityGroupRole,                     // roles::EMBEDDED_OBJECT      122
+  NSAccessibilityGroupRole,                     // roles::NOTE                 123
+  NSAccessibilityGroupRole,                     // roles::FIGURE               124
+  NSAccessibilityCheckBoxRole,                  // roles::CHECK_RICH_OPTION    125
+  @"ROLE_LAST_ENTRY"                            // roles::LAST_ENTRY                  Bogus role that will never be shown (just marks the end of this array)!
 };
--- a/accessible/src/msaa/CAccessibleHyperlink.cpp
+++ b/accessible/src/msaa/CAccessibleHyperlink.cpp
@@ -59,17 +59,17 @@ CAccessibleHyperlink::QueryInterface(REF
     if (!thisObj->IsLink())
       return E_NOINTERFACE;
 
     *ppv = static_cast<IAccessibleHyperlink*>(this);
     (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
     return S_OK;
   }
 
-  return CAccessibleAction::QueryInterface(iid, ppv);
+  return ia2AccessibleAction::QueryInterface(iid, ppv);
 }
 
 // IAccessibleHyperlink
 
 STDMETHODIMP
 CAccessibleHyperlink::get_anchor(long aIndex, VARIANT *aAnchor)
 {
 __try {
--- a/accessible/src/msaa/CAccessibleHyperlink.h
+++ b/accessible/src/msaa/CAccessibleHyperlink.h
@@ -38,29 +38,29 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _ACCESSIBLE_HYPERLINK_H
 #define _ACCESSIBLE_HYPERLINK_H
 
 #include "nsISupports.h"
 
-#include "CAccessibleAction.h"
+#include "ia2AccessibleAction.h"
 #include "AccessibleHyperlink.h"
 
-class CAccessibleHyperlink: public CAccessibleAction,
+class CAccessibleHyperlink: public ia2AccessibleAction,
                             public IAccessibleHyperlink
 {
 public:
 
   // IUnknown
   STDMETHODIMP QueryInterface(REFIID, void**);
 
   // IAccessibleAction
-  FORWARD_IACCESSIBLEACTION(CAccessibleAction)
+  FORWARD_IACCESSIBLEACTION(ia2AccessibleAction)
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_anchor(
       /* [in] */ long index,
       /* [retval][out] */ VARIANT *anchor);
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_anchorTarget(
       /* [in] */ long index,
       /* [retval][out] */ VARIANT *anchorTarget);
--- a/accessible/src/msaa/Makefile.in
+++ b/accessible/src/msaa/Makefile.in
@@ -58,17 +58,17 @@ CPPSRCS = \
   nsXULMenuAccessibleWrap.cpp \
   nsXULListboxAccessibleWrap.cpp \
   nsXULTreeGridAccessibleWrap.cpp \
   nsHyperTextAccessibleWrap.cpp \
   nsHTMLImageAccessibleWrap.cpp \
   nsHTMLTableAccessibleWrap.cpp \
   nsApplicationAccessibleWrap.cpp \
   nsWinUtils.cpp \
-  CAccessibleAction.cpp \
+  ia2AccessibleAction.cpp \
   CAccessibleImage.cpp \
   CAccessibleComponent.cpp \
   CAccessibleText.cpp \
   CAccessibleEditableText.cpp \
   CAccessibleHyperlink.cpp \
   CAccessibleHypertext.cpp \
   ia2AccessibleRelation.cpp \
   CAccessibleTable.cpp \
@@ -87,17 +87,17 @@ EXPORTS = \
   nsARIAGridAccessibleWrap.h \
   nsXULMenuAccessibleWrap.h \
   nsXULListboxAccessibleWrap.h \
   nsXULTreeGridAccessibleWrap.h \
   nsHyperTextAccessibleWrap.h \
   nsHTMLImageAccessibleWrap.h \
   nsHTMLTableAccessibleWrap.h \
   nsApplicationAccessibleWrap.h \
-  CAccessibleAction.h \
+  ia2AccessibleAction.h \
   CAccessibleImage.h \
   CAccessibleComponent.h \
   CAccessibleText.h \
   CAccessibleEditableText.h \
   CAccessibleHyperlink.h \
   CAccessibleHypertext.h \
   CAccessibleTable.h \
   CAccessibleTableCell.h \
@@ -109,13 +109,15 @@ FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES += \
   -I$(srcdir) \
   -I$(srcdir)/../base \
+  -I$(srcdir)/../generic \
   -I$(srcdir)/../html \
+  -I$(srcdir)/../xpcom \
   -I$(srcdir)/../xul \
   -I$(srcdir)/../../../content/base/src \
   -I$(srcdir)/../../../content/events/src \
   $(NULL)
rename from accessible/src/msaa/CAccessibleAction.cpp
rename to accessible/src/msaa/ia2AccessibleAction.cpp
--- a/accessible/src/msaa/CAccessibleAction.cpp
+++ b/accessible/src/msaa/ia2AccessibleAction.cpp
@@ -33,84 +33,84 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "CAccessibleAction.h"
+#include "ia2AccessibleAction.h"
 
 #include "AccessibleAction_i.c"
 
-#include "nsAccessible.h"
+#include "nsAccessibleWrap.h"
 
 // IUnknown
 
 STDMETHODIMP
-CAccessibleAction::QueryInterface(REFIID iid, void** ppv)
+ia2AccessibleAction::QueryInterface(REFIID iid, void** ppv)
 {
   *ppv = NULL;
 
   if (IID_IAccessibleAction == iid) {
     *ppv = static_cast<IAccessibleAction*>(this);
     (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
     return S_OK;
   }
 
   return E_NOINTERFACE;
 }
 
 // IAccessibleAction
 
 STDMETHODIMP
-CAccessibleAction::nActions(long* aActionCount)
+ia2AccessibleAction::nActions(long* aActionCount)
 {
 __try {
   if (!aActionCount)
     return E_INVALIDARG;
 
   *aActionCount = 0;
 
-  nsRefPtr<nsAccessible> acc(do_QueryObject(this));
-  if (!acc || acc->IsDefunct())
+  nsAccessibleWrap* acc = static_cast<nsAccessibleWrap*>(this);
+  if (acc->IsDefunct())
     return E_FAIL;
 
   *aActionCount = acc->ActionCount();
   return S_OK;
 
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
-CAccessibleAction::doAction(long aActionIndex)
+ia2AccessibleAction::doAction(long aActionIndex)
 {
 __try {
-  nsCOMPtr<nsIAccessible> acc(do_QueryObject(this));
-  if (!acc)
+  nsAccessibleWrap* acc = static_cast<nsAccessibleWrap*>(this);
+  if (acc->IsDefunct())
     return E_FAIL;
 
   PRUint8 index = static_cast<PRUint8>(aActionIndex);
   nsresult rv = acc->DoAction(index);
   return GetHRESULT(rv);
 
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
-CAccessibleAction::get_description(long aActionIndex, BSTR *aDescription)
+ia2AccessibleAction::get_description(long aActionIndex, BSTR *aDescription)
 {
 __try {
   *aDescription = NULL;
 
-  nsCOMPtr<nsIAccessible> acc(do_QueryObject(this));
-  if (!acc)
+  nsAccessibleWrap* acc = static_cast<nsAccessibleWrap*>(this);
+  if (acc->IsDefunct())
     return E_FAIL;
 
   nsAutoString description;
   PRUint8 index = static_cast<PRUint8>(aActionIndex);
   nsresult rv = acc->GetActionDescription(index, description);
   if (NS_FAILED(rv))
     return GetHRESULT(rv);
 
@@ -121,34 +121,34 @@ CAccessibleAction::get_description(long 
                                       description.Length());
   return *aDescription ? S_OK : E_OUTOFMEMORY;
 
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
-CAccessibleAction::get_keyBinding(long aActionIndex, long aNumMaxBinding,
+ia2AccessibleAction::get_keyBinding(long aActionIndex, long aNumMaxBinding,
                                   BSTR **aKeyBinding,
                                   long *aNumBinding)
 {
 __try {
   if (!aKeyBinding)
     return E_INVALIDARG;
   *aKeyBinding = NULL;
 
   if (!aNumBinding)
     return E_INVALIDARG;
   *aNumBinding = 0;
 
   if (aActionIndex != 0 || aNumMaxBinding < 1)
     return E_INVALIDARG;
 
-  nsRefPtr<nsAccessible> acc(do_QueryObject(this));
-  if (!acc || acc->IsDefunct())
+  nsAccessibleWrap* acc = static_cast<nsAccessibleWrap*>(this);
+  if (acc->IsDefunct())
     return E_FAIL;
 
   // Expose keyboard shortcut if it's not exposed via MSAA keyboard shortcut.
   KeyBinding keyBinding = acc->AccessKey();
   if (keyBinding.IsEmpty())
     return S_FALSE;
 
   keyBinding = acc->KeyboardShortcut();
@@ -171,23 +171,23 @@ CAccessibleAction::get_keyBinding(long a
   *aNumBinding = 1;
   return S_OK;
 
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
-CAccessibleAction::get_name(long aActionIndex, BSTR *aName)
+ia2AccessibleAction::get_name(long aActionIndex, BSTR *aName)
 {
 __try {
   *aName = NULL;
 
-  nsCOMPtr<nsIAccessible> acc(do_QueryObject(this));
-  if (!acc)
+  nsAccessibleWrap* acc = static_cast<nsAccessibleWrap*>(this);
+  if (acc->IsDefunct())
     return E_FAIL;
 
   nsAutoString name;
   PRUint8 index = static_cast<PRUint8>(aActionIndex);
   nsresult rv = acc->GetActionName(index, name);
   if (NS_FAILED(rv))
     return GetHRESULT(rv);
 
@@ -197,17 +197,17 @@ CAccessibleAction::get_name(long aAction
   *aName = ::SysAllocStringLen(name.get(), name.Length());
   return *aName ? S_OK : E_OUTOFMEMORY;
 
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
-CAccessibleAction::get_localizedName(long aActionIndex, BSTR *aLocalizedName)
+ia2AccessibleAction::get_localizedName(long aActionIndex, BSTR *aLocalizedName)
 {
 __try {
   *aLocalizedName = NULL;
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
 
   return E_NOTIMPL;
 }
 
rename from accessible/src/msaa/CAccessibleAction.h
rename to accessible/src/msaa/ia2AccessibleAction.h
--- a/accessible/src/msaa/CAccessibleAction.h
+++ b/accessible/src/msaa/ia2AccessibleAction.h
@@ -40,17 +40,17 @@
 
 #ifndef _ACCESSIBLE_ACTION_H
 #define _ACCESSIBLE_ACTION_H
 
 #include "nsISupports.h"
 
 #include "AccessibleAction.h"
 
-class CAccessibleAction: public IAccessibleAction
+class ia2AccessibleAction: public IAccessibleAction
 {
 public:
 
   // IUnknown
   STDMETHODIMP QueryInterface(REFIID, void**);
 
   // IAccessibleAction
   virtual HRESULT STDMETHODCALLTYPE nActions(
@@ -72,19 +72,16 @@ public:
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_name(
       /* [in] */ long actionIndex,
       /* [retval][out] */ BSTR *name);
 
   virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_localizedName(
       /* [in] */ long actionIndex,
       /* [retval][out] */ BSTR *localizedName);
 
-  // nsISupports
-  NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
-
 };
 
 
 #define FORWARD_IACCESSIBLEACTION(Class)                                       \
 virtual HRESULT STDMETHODCALLTYPE nActions(long *nActions)                     \
 {                                                                              \
   return Class::nActions(nActions);                                            \
 }                                                                              \
--- a/accessible/src/msaa/nsAccessNodeWrap.cpp
+++ b/accessible/src/msaa/nsAccessNodeWrap.cpp
@@ -210,20 +210,21 @@ STDMETHODIMP nsAccessNodeWrap::get_nodeI
     /* [out] */ unsigned int __RPC_FAR *aNumChildren,
     /* [out] */ unsigned int __RPC_FAR *aUniqueID,
     /* [out] */ unsigned short __RPC_FAR *aNodeType)
 {
 __try{
   *aNodeName = nsnull;
   *aNodeValue = nsnull;
 
-  if (IsDefunct())
+  nsINode* node = GetNode();
+  if (!node)
     return E_FAIL;
 
-  nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(GetNode()));
+  nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(node));
 
   PRUint16 nodeType = 0;
   DOMNode->GetNodeType(&nodeType);
   *aNodeType=static_cast<unsigned short>(nodeType);
 
   if (*aNodeType !=  NODETYPE_TEXT) {
     nsAutoString nodeName;
     DOMNode->GetNodeName(nodeName);
@@ -239,17 +240,17 @@ STDMETHODIMP nsAccessNodeWrap::get_nodeI
     static_cast<short>(mContent->GetNameSpaceID()) : 0;
 
   // This is a unique ID for every content node.  The 3rd party
   // accessibility application can compare this to the childID we
   // return for events such as focus events, to correlate back to
   // data nodes in their internal object model.
   *aUniqueID = - NS_PTR_TO_INT32(UniqueID());
 
-  *aNumChildren = GetNode()->GetChildCount();
+  *aNumChildren = node->GetChildCount();
 
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return S_OK;
 }
 
 
        
 STDMETHODIMP nsAccessNodeWrap::get_attributes( 
@@ -257,17 +258,17 @@ STDMETHODIMP nsAccessNodeWrap::get_attri
     /* [length_is][size_is][out] */ BSTR __RPC_FAR *aAttribNames,
     /* [length_is][size_is][out] */ short __RPC_FAR *aNameSpaceIDs,
     /* [length_is][size_is][out] */ BSTR __RPC_FAR *aAttribValues,
     /* [out] */ unsigned short __RPC_FAR *aNumAttribs)
 {
 __try{
   *aNumAttribs = 0;
 
-  if (IsDefunct() || IsDocumentNode())
+  if (!mContent || IsDocumentNode())
     return E_FAIL;
 
   PRUint32 numAttribs = mContent->GetAttrCount();
   if (numAttribs > aMaxAttribs)
     numAttribs = aMaxAttribs;
   *aNumAttribs = static_cast<unsigned short>(numAttribs);
 
   for (PRUint32 index = 0; index < numAttribs; index++) {
@@ -288,17 +289,17 @@ STDMETHODIMP nsAccessNodeWrap::get_attri
 
 STDMETHODIMP nsAccessNodeWrap::get_attributesForNames( 
     /* [in] */ unsigned short aNumAttribs,
     /* [length_is][size_is][in] */ BSTR __RPC_FAR *aAttribNames,
     /* [length_is][size_is][in] */ short __RPC_FAR *aNameSpaceID,
     /* [length_is][size_is][retval] */ BSTR __RPC_FAR *aAttribValues)
 {
 __try {
-  if (IsDefunct() || !IsElement())
+  if (!mContent || !IsElement())
     return E_FAIL;
 
   nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(mContent));
   nsCOMPtr<nsINameSpaceManager> nameSpaceManager =
     do_GetService(NS_NAMESPACEMANAGER_CONTRACTID);
 
   PRInt32 index;
 
@@ -330,17 +331,17 @@ STDMETHODIMP nsAccessNodeWrap::get_compu
     /* [in] */ boolean aUseAlternateView,
     /* [length_is][size_is][out] */ BSTR __RPC_FAR *aStyleProperties,
     /* [length_is][size_is][out] */ BSTR __RPC_FAR *aStyleValues,
     /* [out] */ unsigned short __RPC_FAR *aNumStyleProperties)
 {
 __try{
   *aNumStyleProperties = 0;
 
-  if (IsDefunct() || IsDocumentNode())
+  if (!mContent || IsDocumentNode())
     return E_FAIL;
 
   nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl =
     nsWinUtils::GetComputedStyleDeclaration(mContent);
   NS_ENSURE_TRUE(cssDecl, E_FAIL);
 
   PRUint32 length;
   cssDecl->GetLength(&length);
@@ -365,17 +366,17 @@ STDMETHODIMP nsAccessNodeWrap::get_compu
 
 STDMETHODIMP nsAccessNodeWrap::get_computedStyleForProperties( 
     /* [in] */ unsigned short aNumStyleProperties,
     /* [in] */ boolean aUseAlternateView,
     /* [length_is][size_is][in] */ BSTR __RPC_FAR *aStyleProperties,
     /* [length_is][size_is][out] */ BSTR __RPC_FAR *aStyleValues)
 {
 __try {
-  if (IsDefunct() || IsDocumentNode())
+  if (!mContent || IsDocumentNode())
     return E_FAIL;
  
   nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl =
     nsWinUtils::GetComputedStyleDeclaration(mContent);
   NS_ENSURE_TRUE(cssDecl, E_FAIL);
 
   PRUint32 index;
   for (index = 0; index < aNumStyleProperties; index ++) {
@@ -437,89 +438,95 @@ nsAccessNodeWrap::MakeAccessNode(nsINode
 
   return iNode;
 }
 
 
 STDMETHODIMP nsAccessNodeWrap::get_parentNode(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
 {
 __try {
-  if (IsDefunct())
+  nsINode* node = GetNode();
+  if (!node)
     return E_FAIL;
 
-  *aNode = MakeAccessNode(GetNode()->GetNodeParent());
+  *aNode = MakeAccessNode(node->GetNodeParent());
 
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
 
   return S_OK;
 }
 
 STDMETHODIMP nsAccessNodeWrap::get_firstChild(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
 {
 __try {
-  if (IsDefunct())
+  nsINode* node = GetNode();
+  if (!node)
     return E_FAIL;
 
-  *aNode = MakeAccessNode(GetNode()->GetFirstChild());
+  *aNode = MakeAccessNode(node->GetFirstChild());
 
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
 
   return S_OK;
 }
 
 STDMETHODIMP nsAccessNodeWrap::get_lastChild(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
 {
 __try {
-  if (IsDefunct())
+  nsINode* node = GetNode();
+  if (!node)
     return E_FAIL;
 
-  *aNode = MakeAccessNode(GetNode()->GetLastChild());
+  *aNode = MakeAccessNode(node->GetLastChild());
 
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
 
   return S_OK;
 }
 
 STDMETHODIMP nsAccessNodeWrap::get_previousSibling(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
 {
 __try {
-  if (IsDefunct())
+  nsINode* node = GetNode();
+  if (!node)
     return E_FAIL;
 
-  *aNode = MakeAccessNode(GetNode()->GetPreviousSibling());
+  *aNode = MakeAccessNode(node->GetPreviousSibling());
 
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
 
   return S_OK;
 }
 
 STDMETHODIMP nsAccessNodeWrap::get_nextSibling(ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
 {
 __try {
-  if (IsDefunct())
+  nsINode* node = GetNode();
+  if (!node)
     return E_FAIL;
 
-  *aNode = MakeAccessNode(GetNode()->GetNextSibling());
+  *aNode = MakeAccessNode(node->GetNextSibling());
 
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
 
   return S_OK;
 }
 
 STDMETHODIMP 
 nsAccessNodeWrap::get_childAt(unsigned aChildIndex,
                               ISimpleDOMNode __RPC_FAR *__RPC_FAR *aNode)
 {
 __try {
   *aNode = nsnull;
 
-  if (IsDefunct())
+  nsINode* node = GetNode();
+  if (!node)
     return E_FAIL;
 
-  *aNode = MakeAccessNode(GetNode()->GetChildAt(aChildIndex));
+  *aNode = MakeAccessNode(node->GetChildAt(aChildIndex));
 
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
 
   return S_OK;
 }
 
 STDMETHODIMP 
 nsAccessNodeWrap::get_innerHTML(BSTR __RPC_FAR *aInnerHTML)
@@ -631,17 +638,17 @@ GetHRESULT(nsresult aResult)
     case NS_ERROR_NOT_IMPLEMENTED:
       return E_NOTIMPL;
 
     default:
       return E_FAIL;
   }
 }
 
-nsRefPtrHashtable<nsVoidPtrHashKey, nsDocAccessible> nsAccessNodeWrap::sHWNDCache;
+nsRefPtrHashtable<nsPtrHashKey<void>, nsDocAccessible> nsAccessNodeWrap::sHWNDCache;
 
 LRESULT CALLBACK
 nsAccessNodeWrap::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
   // Note, this window's message handling should not invoke any call that
   // may result in a cross-process ipc call. Doing so may violate RPC
   // message semantics.
 
--- a/accessible/src/msaa/nsAccessNodeWrap.h
+++ b/accessible/src/msaa/nsAccessNodeWrap.h
@@ -147,17 +147,17 @@ public: // construction, destruction
     static void InitAccessibility();
     static void ShutdownAccessibility();
 
     static int FilterA11yExceptions(unsigned int aCode, EXCEPTION_POINTERS *aExceptionInfo);
 
   static LRESULT CALLBACK WindowProc(HWND hWnd, UINT Msg,
                                      WPARAM WParam, LPARAM lParam);
 
-  static nsRefPtrHashtable<nsVoidPtrHashKey, nsDocAccessible> sHWNDCache;
+  static nsRefPtrHashtable<nsPtrHashKey<void>, nsDocAccessible> sHWNDCache;
 
 protected:
 
   /**
    * Return ISimpleDOMNode instance for existing accessible object or
    * creates new nsAccessNode instance if the accessible doesn't exist.
    *
    * @note ISimpleDOMNode is returned addrefed
--- a/accessible/src/msaa/nsHTMLWin32ObjectAccessible.cpp
+++ b/accessible/src/msaa/nsHTMLWin32ObjectAccessible.cpp
@@ -96,16 +96,20 @@ nsHTMLWin32ObjectOwnerAccessible::CacheC
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLWin32ObjectAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 nsHTMLWin32ObjectAccessible::nsHTMLWin32ObjectAccessible(void* aHwnd):
 nsLeafAccessible(nsnull, nsnull)
 {
+  // XXX: Mark it as defunct to make sure no single nsAccessible method is
+  // running on it. We need to allow accessible without DOM nodes.
+  mFlags |= eIsDefunct;
+
   mHwnd = aHwnd;
   if (mHwnd) {
     // The plugin is not windowless. In this situation we use 
     // use its inner child owned by the plugin so that we don't get
     // in an infinite loop, where the WM_GETOBJECT's get forwarded
     // back to us and create another nsHTMLWin32ObjectAccessible
     HWND childWnd = ::GetWindow((HWND)aHwnd, GW_CHILD);
     if (childWnd) {
--- a/accessible/src/msaa/nsRoleMap.h
+++ b/accessible/src/msaa/nsRoleMap.h
@@ -444,12 +444,15 @@ static const WindowsRoleMapItem gWindows
   { USE_ROLE_STRING, IA2_ROLE_EMBEDDED_OBJECT },
 
   // roles::NOTE
   { USE_ROLE_STRING, IA2_ROLE_NOTE },
 
   // roles::FIGURE
   { ROLE_SYSTEM_GROUPING, ROLE_SYSTEM_GROUPING },
 
+  // roles::CHECK_RICH_OPTION
+  { ROLE_SYSTEM_CHECKBUTTON, ROLE_SYSTEM_CHECKBUTTON },
+
   // roles::LAST_ENTRY
   { ROLE_WINDOWS_LAST_ENTRY, ROLE_WINDOWS_LAST_ENTRY }
 };
 
--- a/accessible/src/xpcom/Makefile.in
+++ b/accessible/src/xpcom/Makefile.in
@@ -45,18 +45,20 @@ include $(DEPTH)/config/autoconf.mk
 
 MODULE = accessibility
 LIBRARY_NAME = accessibility_xpcom_s
 LIBXUL_LIBRARY = 1
 
 CPPSRCS = \
   nsAccEvent.cpp \
   nsAccessibleRelation.cpp \
+  xpcAccessibleTable.cpp \
   $(NULL)
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES = \
   -I$(srcdir)/../base \
+  -I$(srcdir)/../generic \
   $(NULL)
new file mode 100644
--- /dev/null
+++ b/accessible/src/xpcom/xpcAccessibleTable.cpp
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "xpcAccessibleTable.h"
+
+#include "nsAccessible.h"
+#include "TableAccessible.h"
+
+nsresult
+xpcAccessibleTable::GetCaption(nsIAccessible** aCaption)
+{
+  NS_ENSURE_ARG_POINTER(aCaption);
+  *aCaption = nsnull;
+  if (!mTable)
+    return NS_ERROR_FAILURE;
+
+  NS_IF_ADDREF(*aCaption = mTable->Caption());
+  return NS_OK;
+}
+
+nsresult
+xpcAccessibleTable::IsProbablyForLayout(bool* aResult)
+{
+  NS_ENSURE_ARG_POINTER(aResult);
+  *aResult = false;
+  if (!mTable)
+    return NS_ERROR_FAILURE;
+
+  *aResult = mTable->IsProbablyLayoutTable();
+  return NS_OK;
+}
new file mode 100644
--- /dev/null
+++ b/accessible/src/xpcom/xpcAccessibleTable.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
+#define MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
+
+#include "nscore.h"
+
+class nsIAccessible;
+namespace mozilla {
+namespace a11y {
+class TableAccessible;
+}
+}
+
+class xpcAccessibleTable
+{
+public:
+  xpcAccessibleTable(mozilla::a11y::TableAccessible* aTable) : mTable(aTable) { }
+
+  nsresult GetCaption(nsIAccessible** aCaption);
+  nsresult IsProbablyForLayout(bool* aIsForLayout);
+
+protected:
+  mozilla::a11y::TableAccessible* mTable;
+};
+
+#define NS_DECL_OR_FORWARD_NSIACCESSIBLETABLE_WITH_XPCACCESSIBLETABLE \
+  NS_IMETHOD GetCaption(nsIAccessible** aCaption) \
+    { return xpcAccessibleTable::GetCaption(aCaption); } \
+  NS_SCRIPTABLE NS_IMETHOD GetSummary(nsAString & aSummary); \
+  NS_SCRIPTABLE NS_IMETHOD GetColumnCount(PRInt32 *aColumnCount); \
+  NS_SCRIPTABLE NS_IMETHOD GetRowCount(PRInt32 *aRowCount); \
+  NS_SCRIPTABLE NS_IMETHOD GetCellAt(PRInt32 rowIndex, PRInt32 columnIndex, nsIAccessible * *_retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetCellIndexAt(PRInt32 rowIndex, PRInt32 columnIndex, PRInt32 *_retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetColumnIndexAt(PRInt32 cellIndex, PRInt32 *_retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetRowIndexAt(PRInt32 cellIndex, PRInt32 *_retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetRowAndColumnIndicesAt(PRInt32 cellIndex, PRInt32 *rowIndex NS_OUTPARAM, PRInt32 *columnIndex NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetColumnExtentAt(PRInt32 row, PRInt32 column, PRInt32 *_retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetRowExtentAt(PRInt32 row, PRInt32 column, PRInt32 *_retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetColumnDescription(PRInt32 columnIndex, nsAString & _retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetRowDescription(PRInt32 rowIndex, nsAString & _retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD IsColumnSelected(PRInt32 columnIndex, bool *_retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD IsRowSelected(PRInt32 rowIndex, bool *_retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD IsCellSelected(PRInt32 rowIndex, PRInt32 columnIndex, bool *_retval NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedCellCount(PRUint32 *aSelectedCellCount); \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedColumnCount(PRUint32 *aSelectedColumnCount); \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedRowCount(PRUint32 *aSelectedRowCount); \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedCells(nsIArray * *aSelectedCells); \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedCellIndices(PRUint32 *cellsArraySize NS_OUTPARAM, PRInt32 **cellsArray NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedColumnIndices(PRUint32 *rowsArraySize NS_OUTPARAM, PRInt32 **rowsArray NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD GetSelectedRowIndices(PRUint32 *rowsArraySize NS_OUTPARAM, PRInt32 **rowsArray NS_OUTPARAM); \
+  NS_SCRIPTABLE NS_IMETHOD SelectRow(PRInt32 rowIndex); \
+  NS_SCRIPTABLE NS_IMETHOD SelectColumn(PRInt32 columnIndex); \
+  NS_SCRIPTABLE NS_IMETHOD UnselectColumn(PRInt32 columnIndex); \
+  NS_IMETHOD UnselectRow(PRInt32 aRowIdx); \
+  NS_IMETHOD IsProbablyForLayout(bool* aResult) \
+  { return xpcAccessibleTable::IsProbablyForLayout(aResult); } \
+
+#endif // MOZILLA_A11Y_XPCOM_XPACCESSIBLETABLE_H_
--- a/accessible/src/xul/Makefile.in
+++ b/accessible/src/xul/Makefile.in
@@ -67,12 +67,14 @@ CPPSRCS = \
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES = \
   -I$(srcdir) \
   -I$(srcdir)/../base \
+  -I$(srcdir)/../generic \
   -I$(srcdir)/../html \
+  -I$(srcdir)/../xpcom \
   -I$(srcdir)/../../../layout/generic \
   -I$(srcdir)/../../../layout/xul/base/src \
   $(NULL)
--- a/accessible/src/xul/nsXULFormControlAccessible.cpp
+++ b/accessible/src/xul/nsXULFormControlAccessible.cpp
@@ -522,24 +522,16 @@ nsXULRadioButtonAccessible::NativeState(
     if (selected) {
       state |= states::CHECKED;
     }
   }
 
   return state;
 }
 
-void
-nsXULRadioButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
-                                                       PRInt32 *aSetSize)
-{
-  nsAccUtils::GetPositionAndSizeForXULSelectControlItem(mContent, aPosInSet,
-                                                        aSetSize);
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULRadioButtonAccessible: Widgets
 
 nsAccessible*
 nsXULRadioButtonAccessible::ContainerWidget() const
 {
   return mParent;
 }
--- a/accessible/src/xul/nsXULFormControlAccessible.h
+++ b/accessible/src/xul/nsXULFormControlAccessible.h
@@ -157,18 +157,16 @@ public:
  */
 class nsXULRadioButtonAccessible : public nsRadioButtonAccessible
 {
 
 public:
   nsXULRadioButtonAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
 
   // nsAccessible
-  virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
-                                          PRInt32 *aSetSize);
   virtual PRUint64 NativeState();
 
   // Widgets
   virtual nsAccessible* ContainerWidget() const;
 };
 
 /**
  * Used for XUL radiogroup element.
--- a/accessible/src/xul/nsXULListboxAccessible.cpp
+++ b/accessible/src/xul/nsXULListboxAccessible.cpp
@@ -129,17 +129,17 @@ nsXULColumnItemAccessible::DoAction(PRUi
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULListboxAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 nsXULListboxAccessible::
   nsXULListboxAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
-  XULSelectControlAccessible(aContent, aDoc)
+  XULSelectControlAccessible(aContent, aDoc), xpcAccessibleTable(this)
 {
   nsIContent* parentContent = mContent->GetParent();
   if (parentContent) {
     nsCOMPtr<nsIAutoCompletePopup> autoCompletePopupElm =
       do_QueryInterface(parentContent);
     if (autoCompletePopupElm)
       mFlags |= eAutoCompletePopupAccessible;
   }
@@ -159,16 +159,26 @@ nsXULListboxAccessible::QueryInterface(R
     *aInstancePtr = static_cast<nsIAccessibleTable*>(this);