summaryrefslogtreecommitdiff
path: root/Source/WebCore/editing/atk/FrameSelectionAtk.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/editing/atk/FrameSelectionAtk.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/editing/atk/FrameSelectionAtk.cpp')
-rw-r--r--Source/WebCore/editing/atk/FrameSelectionAtk.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/Source/WebCore/editing/atk/FrameSelectionAtk.cpp b/Source/WebCore/editing/atk/FrameSelectionAtk.cpp
index 03a23a7e4..51839a990 100644
--- a/Source/WebCore/editing/atk/FrameSelectionAtk.cpp
+++ b/Source/WebCore/editing/atk/FrameSelectionAtk.cpp
@@ -25,14 +25,10 @@
#include "AXObjectCache.h"
#include "Document.h"
#include "Frame.h"
+#include "RenderListItem.h"
#include "WebKitAccessibleWrapperAtk.h"
-
-#if PLATFORM(EFL)
#include <glib.h>
-#else
-#include <gtk/gtk.h>
-#endif
-
+#include <wtf/NeverDestroyed.h>
#include <wtf/RefPtr.h>
namespace WebCore {
@@ -43,29 +39,34 @@ static void emitTextSelectionChange(AccessibilityObject* object, VisibleSelectio
if (!axObject || !ATK_IS_TEXT(axObject))
return;
+ // We need to adjust the offset for the list item marker in Left-To-Right text because
+ // the list item marker is exposed through the text of the accessible list item rather
+ // than through a separate accessible object.
+ RenderObject* renderer = object->renderer();
+ if (is<RenderListItem>(renderer) && renderer->style().direction() == LTR)
+ offset += downcast<RenderListItem>(*renderer).markerTextWithSuffix().length();
+
g_signal_emit_by_name(axObject, "text-caret-moved", offset);
if (selection.isRange())
g_signal_emit_by_name(axObject, "text-selection-changed");
}
-static void maybeEmitTextFocusChange(PassRefPtr<AccessibilityObject> prpObject)
+static void maybeEmitTextFocusChange(RefPtr<AccessibilityObject>&& object)
{
// This static variable is needed to keep track of the old object
// as per previous calls to this function, in order to properly
// decide whether to emit some signals or not.
- DEFINE_STATIC_LOCAL(RefPtr<AccessibilityObject>, oldObject, ());
-
- RefPtr<AccessibilityObject> object = prpObject;
+ static NeverDestroyed<RefPtr<AccessibilityObject>> oldObject;
// Ensure the oldObject belongs to the same document that the
// current object so further comparisons make sense. Otherwise,
// just reset oldObject to 0 so it won't be taken into account in
// the immediately following call to this function.
- if (object && oldObject && oldObject->document() != object->document())
- oldObject = 0;
+ if (object && oldObject.get() && oldObject.get()->document() != object->document())
+ oldObject.get() = nullptr;
AtkObject* axObject = object ? object->wrapper() : 0;
- AtkObject* oldAxObject = oldObject ? oldObject->wrapper() : 0;
+ AtkObject* oldAxObject = oldObject.get() ? oldObject.get()->wrapper() : nullptr;
if (axObject != oldAxObject) {
if (oldAxObject && ATK_IS_TEXT(oldAxObject)) {
@@ -79,11 +80,11 @@ static void maybeEmitTextFocusChange(PassRefPtr<AccessibilityObject> prpObject)
}
// Update pointer to last focused object.
- oldObject = object;
+ oldObject.get() = WTFMove(object);
}
-void FrameSelection::notifyAccessibilityForSelectionChange()
+void FrameSelection::notifyAccessibilityForSelectionChange(const AXTextStateChangeIntent&)
{
if (!AXObjectCache::accessibilityEnabled())
return;
@@ -91,12 +92,15 @@ void FrameSelection::notifyAccessibilityForSelectionChange()
if (!m_selection.start().isNotNull() || !m_selection.end().isNotNull())
return;
- RenderObject* focusedNode = m_selection.end().containerNode()->renderer();
+ Node* focusedNode = m_selection.end().containerNode();
+ if (!focusedNode)
+ return;
+
AXObjectCache* cache = m_frame->document()->existingAXObjectCache();
if (!cache)
return;
- AccessibilityObject* accessibilityObject = cache->getOrCreate(focusedNode);
+ AccessibilityObject* accessibilityObject = cache->getOrCreate(focusedNode->renderer());
if (!accessibilityObject)
return;
@@ -106,7 +110,7 @@ void FrameSelection::notifyAccessibilityForSelectionChange()
return;
emitTextSelectionChange(object.get(), m_selection, offset);
- maybeEmitTextFocusChange(object.release());
+ maybeEmitTextFocusChange(WTFMove(object));
}
} // namespace WebCore