diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp')
-rw-r--r-- | Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp | 72 |
1 files changed, 26 insertions, 46 deletions
diff --git a/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp b/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp index 8422d7045..5edcc98f3 100644 --- a/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp +++ b/Source/WebCore/accessibility/atk/WebKitAccessibleInterfaceText.cpp @@ -36,7 +36,7 @@ #include "AccessibilityObject.h" #include "Document.h" -#include "Font.h" +#include "FontCascade.h" #include "FrameView.h" #include "HTMLParserIdioms.h" #include "HostWindow.h" @@ -51,7 +51,7 @@ #include "WebKitAccessibleUtil.h" #include "WebKitAccessibleWrapperAtk.h" #include "htmlediting.h" -#include <wtf/gobject/GUniquePtr.h> +#include <wtf/glib/GUniquePtr.h> #include <wtf/text/CString.h> using namespace WebCore; @@ -84,9 +84,9 @@ static AtkAttributeSet* getAttributeSetForAccessibilityObject(const Accessibilit return 0; RenderObject* renderer = object->renderer(); - RenderStyle* style = &renderer->style(); + auto* style = &renderer->style(); - AtkAttributeSet* result = 0; + AtkAttributeSet* result = nullptr; GUniquePtr<gchar> buffer(g_strdup_printf("%i", style->fontSize())); result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_SIZE), buffer.get()); @@ -125,19 +125,19 @@ static AtkAttributeSet* getAttributeSetForAccessibilityObject(const Accessibilit } if (!style->textIndent().isUndefined()) { - int indentation = valueForLength(style->textIndent(), object->size().width(), &renderer->view()); + int indentation = valueForLength(style->textIndent(), object->size().width()); buffer.reset(g_strdup_printf("%i", indentation)); result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_INDENT), buffer.get()); } - String fontFamilyName = style->font().firstFamily(); + String fontFamilyName = style->fontCascade().firstFamily(); if (fontFamilyName.left(8) == "-webkit-") fontFamilyName = fontFamilyName.substring(8); result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_FAMILY_NAME), fontFamilyName.utf8().data()); int fontWeight = -1; - switch (style->font().weight()) { + switch (style->fontCascade().weight()) { case FontWeight100: fontWeight = 100; break; @@ -192,19 +192,19 @@ static AtkAttributeSet* getAttributeSetForAccessibilityObject(const Accessibilit result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_UNDERLINE), (style->textDecoration() & TextDecorationUnderline) ? "single" : "none"); - result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_STYLE), style->font().italic() ? "italic" : "normal"); + result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_STYLE), style->fontCascade().italic() ? "italic" : "normal"); result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_STRIKETHROUGH), (style->textDecoration() & TextDecorationLineThrough) ? "true" : "false"); result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_INVISIBLE), (style->visibility() == HIDDEN) ? "true" : "false"); - result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_EDITABLE), object->isReadOnly() ? "false" : "true"); + result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_EDITABLE), object->canSetValueAttribute() ? "true" : "false"); String language = object->language(); if (!language.isEmpty()) result = addToAtkAttributeSet(result, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE), language.utf8().data()); - String invalidStatus = object->invalidStatus().string(); + String invalidStatus = object->invalidStatus(); if (invalidStatus != "false") { // Register the custom attribute for 'aria-invalid' if not done yet. if (atkTextAttributeInvalid == ATK_TEXT_ATTR_INVALID) @@ -231,7 +231,7 @@ static AtkAttributeSet* attributeSetDifference(AtkAttributeSet* attributeSet1, A AtkAttributeSet* currentSet = attributeSet1; AtkAttributeSet* found; - AtkAttributeSet* toDelete = 0; + AtkAttributeSet* toDelete = nullptr; while (currentSet) { found = g_slist_find_custom(attributeSet2, currentSet->data, (GCompareFunc)compareAttribute); @@ -270,8 +270,8 @@ static guint accessibilityObjectLength(const AccessibilityObject* object) // for those cases when it's needed to take it into account // separately (as in getAccessibilityObjectForOffset) RenderObject* renderer = object->renderer(); - if (renderer && renderer->isListMarker()) { - RenderListMarker& marker = toRenderListMarker(*renderer); + if (is<RenderListMarker>(renderer)) { + auto& marker = downcast<RenderListMarker>(*renderer); return marker.text().length() + marker.suffix().length(); } @@ -318,7 +318,7 @@ static const AccessibilityObject* getAccessibilityObjectForOffset(const Accessib return result; } -static AtkAttributeSet* getRunAttributesFromAccesibilityObject(const AccessibilityObject* element, gint offset, gint* startOffset, gint* endOffset) +static AtkAttributeSet* getRunAttributesFromAccessibilityObject(const AccessibilityObject* element, gint offset, gint* startOffset, gint* endOffset) { const AccessibilityObject* child = getAccessibilityObjectForOffset(element, offset, startOffset, endOffset); if (!child) { @@ -363,8 +363,8 @@ static int offsetAdjustmentForListItem(const AccessibilityObject* object) // We need to adjust the offsets for the list item marker in // Left-To-Right text, since we expose it together with the text. RenderObject* renderer = object->renderer(); - if (renderer && renderer->isListItem() && renderer->style().direction() == LTR) - return toRenderListItem(renderer)->markerTextWithSuffix().length(); + if (is<RenderListItem>(renderer) && renderer->style().direction() == LTR) + return downcast<RenderListItem>(*renderer).markerTextWithSuffix().length(); return 0; } @@ -495,8 +495,8 @@ static gchar* webkitAccessibleTextGetText(AtkText* text, gint startOffset, gint int actualEndOffset = endOffset == -1 ? ret.length() : endOffset; if (coreObject->roleValue() == ListItemRole) { RenderObject* objRenderer = coreObject->renderer(); - if (objRenderer && objRenderer->isListItem()) { - String markerText = toRenderListItem(objRenderer)->markerTextWithSuffix(); + if (is<RenderListItem>(objRenderer)) { + String markerText = downcast<RenderListItem>(*objRenderer).markerTextWithSuffix(); ret = objRenderer->style().direction() == LTR ? markerText + ret : ret + markerText; if (endOffset == -1) actualEndOffset = ret.length() + markerText.length(); @@ -601,7 +601,7 @@ static VisibleSelection wordAtPositionForAtkBoundary(const AccessibilityObject* // as when at the beginning of a whitespace range between two "real" words, // since that whitespace is considered a "word" as well. And in case we are // already at the beginning of a "real" word we do not need to look backwards. - if (isStartOfWord(position) && isWhitespace(position.characterBefore())) + if (isStartOfWord(position) && deprecatedIsEditingWhitespace(position.characterBefore())) startPosition = position; else startPosition = previousWordPosition(position); @@ -729,7 +729,7 @@ static bool isWhiteSpaceBetweenSentences(const VisiblePosition& position) if (position.isNull()) return false; - if (!isWhitespace(position.characterAfter())) + if (!deprecatedIsEditingWhitespace(position.characterAfter())) return false; VisiblePosition startOfWhiteSpace = startOfWord(position, RightWordIfOnBoundary); @@ -764,12 +764,12 @@ static VisibleSelection sentenceAtPositionForAtkBoundary(const AccessibilityObje // startOfSentence returns a position after any white space previous to // the sentence, so we might need to adjust that offset for this boundary. - if (isWhitespace(startPosition.characterBefore())) + if (deprecatedIsEditingWhitespace(startPosition.characterBefore())) startPosition = startOfWord(startPosition, LeftWordIfOnBoundary); // endOfSentence returns a position after any white space after the // sentence, so we might need to adjust that offset for this boundary. - if (isWhitespace(endPosition.characterBefore())) + if (deprecatedIsEditingWhitespace(endPosition.characterBefore())) endPosition = startOfWord(endPosition, LeftWordIfOnBoundary); // Finally, do some additional adjustments that might be needed if @@ -1055,7 +1055,7 @@ static AtkAttributeSet* webkitAccessibleTextGetRunAttributes(AtkText* text, gint if (offset == -1) offset = atk_text_get_caret_offset(text); - result = getRunAttributesFromAccesibilityObject(coreObject, offset, startOffset, endOffset); + result = getRunAttributesFromAccessibilityObject(coreObject, offset, startOffset, endOffset); if (*startOffset < 0) { *startOffset = offset; @@ -1233,29 +1233,9 @@ static gboolean webkitAccessibleTextRemoveSelection(AtkText* text, gint selectio static gboolean webkitAccessibleTextSetCaretOffset(AtkText* text, gint offset) { - g_return_val_if_fail(ATK_TEXT(text), FALSE); - returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(text), FALSE); - - AccessibilityObject* coreObject = core(text); - if (!coreObject->isAccessibilityRenderObject()) - return FALSE; - - // We need to adjust the offsets for the list item marker. - int offsetAdjustment = offsetAdjustmentForListItem(coreObject); - if (offsetAdjustment) { - if (offset < offsetAdjustment) - return FALSE; - - offset = atkOffsetToWebCoreOffset(text, offset); - } - - PlainTextRange textRange(offset, 0); - VisiblePositionRange range = coreObject->visiblePositionRangeForRange(textRange); - if (range.isNull()) - return FALSE; - - coreObject->setSelectedVisiblePositionRange(range); - return TRUE; + // Internally, setting the caret offset is equivalent to set a zero-length + // selection, so delegate in that implementation and void duplicated code. + return webkitAccessibleTextSetSelection(text, 0, offset, offset); } #if ATK_CHECK_VERSION(2, 10, 0) |