From bca8807cab8f86a80f680a394e81d03cdff5f5f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Artur=20=C5=9Awigo=C5=84?= Date: Fri, 3 Dec 2021 18:39:33 +0100 Subject: [PATCH] [AT-SPI] Clean up AT-SPI interfaces This patch adds a `const` qualifier to most getter methods across all AT-SPI interfaces, with the exception of those that return an `Accessible*`, since these objects are by nature mutable (i.e. exposed on DBus for external manipulation, and DBus does not have const objects), and there is always a possibility to return to `this` with the `const` cast away, e.g. GetParent()->GetChildAtIndex(i). There are also some other minor changes like a `noexcept` qualifier for `~Accessible`, the `EditableText` interface now implying `Text`, and a data-driven `GetRoleName` in `Accessible`. Change-Id: I2ab0bb451f188fe0bd6dbd47c4aa0bad56624b42 --- .../adaptor-framework/accessibility-bridge.h | 12 +- dali/devel-api/adaptor-framework/accessibility.cpp | 664 +++++---------------- .../devel-api/adaptor-framework/proxy-accessible.h | 29 +- dali/devel-api/atspi-interfaces/accessible.h | 37 +- dali/devel-api/atspi-interfaces/action.h | 12 +- dali/devel-api/atspi-interfaces/application.h | 4 +- dali/devel-api/atspi-interfaces/collection.h | 1 - dali/devel-api/atspi-interfaces/component.h | 12 +- dali/devel-api/atspi-interfaces/editable-text.h | 11 +- dali/devel-api/atspi-interfaces/hyperlink.h | 10 +- dali/devel-api/atspi-interfaces/hypertext.h | 6 +- dali/devel-api/atspi-interfaces/selection.h | 4 +- dali/devel-api/atspi-interfaces/text.h | 16 +- dali/devel-api/atspi-interfaces/value.h | 8 +- dali/internal/accessibility/bridge/accessible.cpp | 30 +- dali/internal/accessibility/bridge/bridge-base.h | 30 +- dali/internal/accessibility/bridge/component.cpp | 4 +- dali/internal/accessibility/bridge/dummy-atspi.cpp | 12 +- 18 files changed, 271 insertions(+), 631 deletions(-) diff --git a/dali/devel-api/adaptor-framework/accessibility-bridge.h b/dali/devel-api/adaptor-framework/accessibility-bridge.h index 1ef28d0..05c4f65 100644 --- a/dali/devel-api/adaptor-framework/accessibility-bridge.h +++ b/dali/devel-api/adaptor-framework/accessibility-bridge.h @@ -396,11 +396,11 @@ struct DALI_ADAPTOR_API Bridge protected: struct Data { - std::unordered_set mKnownObjects; - std::string mBusName; - Bridge* mBridge = nullptr; - Actor mHighlightActor; - Actor mCurrentlyHighlightedActor; + std::unordered_set mKnownObjects; + std::string mBusName; + Bridge* mBridge = nullptr; + Actor mHighlightActor; + Actor mCurrentlyHighlightedActor; }; std::shared_ptr mData; friend class Accessible; @@ -425,7 +425,7 @@ protected: * * @param[in] object The accessible object **/ - void RegisterOnBridge(Accessible* object); + void RegisterOnBridge(const Accessible* object); /** * @brief Tells bridge, that given object is considered root (doesn't have any parents). diff --git a/dali/devel-api/adaptor-framework/accessibility.cpp b/dali/devel-api/adaptor-framework/accessibility.cpp index fcf60cd..7caed8e 100644 --- a/dali/devel-api/adaptor-framework/accessibility.cpp +++ b/dali/devel-api/adaptor-framework/accessibility.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include // INTERNAL INCLUDES #include @@ -42,510 +44,145 @@ const std::string& Dali::Accessibility::Address::GetBus() const return mBus.empty() && Bridge::GetCurrentBridge() ? Bridge::GetCurrentBridge()->GetBusName() : mBus; } -std::string EmptyAccessibleWithAddress::GetRoleName() -{ - return ""; -} - -std::string Accessible::GetLocalizedRoleName() +std::string Accessible::GetLocalizedRoleName() const { return GetRoleName(); } -std::string Accessible::GetRoleName() +std::string Accessible::GetRoleName() const { - switch(GetRole()) + static const std::unordered_map roleMap{ + {Role::INVALID, "invalid"}, + {Role::ACCELERATOR_LABEL, "accelerator label"}, + {Role::ALERT, "alert"}, + {Role::ANIMATION, "animation"}, + {Role::ARROW, "arrow"}, + {Role::CALENDAR, "calendar"}, + {Role::CANVAS, "canvas"}, + {Role::CHECK_BOX, "check box"}, + {Role::CHECK_MENU_ITEM, "check menu item"}, + {Role::COLOR_CHOOSER, "color chooser"}, + {Role::COLUMN_HEADER, "column header"}, + {Role::COMBO_BOX, "combo box"}, + {Role::DATE_EDITOR, "date editor"}, + {Role::DESKTOP_ICON, "desktop icon"}, + {Role::DESKTOP_FRAME, "desktop frame"}, + {Role::DIAL, "dial"}, + {Role::DIALOG, "dialog"}, + {Role::DIRECTORY_PANE, "directory pane"}, + {Role::DRAWING_AREA, "drawing area"}, + {Role::FILE_CHOOSER, "file chooser"}, + {Role::FILLER, "filler"}, + {Role::FOCUS_TRAVERSABLE, "focus traversable"}, + {Role::FONT_CHOOSER, "font chooser"}, + {Role::FRAME, "frame"}, + {Role::GLASS_PANE, "glass pane"}, + {Role::HTML_CONTAINER, "html container"}, + {Role::ICON, "icon"}, + {Role::IMAGE, "image"}, + {Role::INTERNAL_FRAME, "internal frame"}, + {Role::LABEL, "label"}, + {Role::LAYERED_PANE, "layered pane"}, + {Role::LIST, "list"}, + {Role::LIST_ITEM, "list item"}, + {Role::MENU, "menu"}, + {Role::MENU_BAR, "menu bar"}, + {Role::MENU_ITEM, "menu item"}, + {Role::OPTION_PANE, "option pane"}, + {Role::PAGE_TAB, "page tab"}, + {Role::PAGE_TAB_LIST, "page tab list"}, + {Role::PANEL, "panel"}, + {Role::PASSWORD_TEXT, "password text"}, + {Role::POPUP_MENU, "popup menu"}, + {Role::PROGRESS_BAR, "progress bar"}, + {Role::PUSH_BUTTON, "push button"}, + {Role::RADIO_BUTTON, "radio button"}, + {Role::RADIO_MENU_ITEM, "radio menu item"}, + {Role::ROOT_PANE, "root pane"}, + {Role::ROW_HEADER, "row header"}, + {Role::SCROLL_BAR, "scroll bar"}, + {Role::SCROLL_PANE, "scroll pane"}, + {Role::SEPARATOR, "separator"}, + {Role::SLIDER, "slider"}, + {Role::SPIN_BUTTON, "spin button"}, + {Role::SPLIT_PANE, "split pane"}, + {Role::STATUS_BAR, "status bar"}, + {Role::TABLE, "table"}, + {Role::TABLE_CELL, "table cell"}, + {Role::TABLE_COLUMN_HEADER, "table column header"}, + {Role::TABLE_ROW_HEADER, "table row header"}, + {Role::TEAROFF_MENU_ITEM, "tearoff menu item"}, + {Role::TERMINAL, "terminal"}, + {Role::TEXT, "text"}, + {Role::TOGGLE_BUTTON, "toggle button"}, + {Role::TOOL_BAR, "tool bar"}, + {Role::TOOL_TIP, "tool tip"}, + {Role::TREE, "tree"}, + {Role::TREE_TABLE, "tree table"}, + {Role::UNKNOWN, "unknown"}, + {Role::VIEWPORT, "viewport"}, + {Role::WINDOW, "window"}, + {Role::EXTENDED, "extended"}, + {Role::HEADER, "header"}, + {Role::FOOTER, "footer"}, + {Role::PARAGRAPH, "paragraph"}, + {Role::RULER, "ruler"}, + {Role::APPLICATION, "application"}, + {Role::AUTOCOMPLETE, "autocomplete"}, + {Role::EDITBAR, "edit bar"}, + {Role::EMBEDDED, "embedded"}, + {Role::ENTRY, "entry"}, + {Role::CHART, "chart"}, + {Role::CAPTION, "caution"}, + {Role::DOCUMENT_FRAME, "document frame"}, + {Role::HEADING, "heading"}, + {Role::PAGE, "page"}, + {Role::SECTION, "section"}, + {Role::REDUNDANT_OBJECT, "redundant object"}, + {Role::FORM, "form"}, + {Role::LINK, "link"}, + {Role::INPUT_METHOD_WINDOW, "input method window"}, + {Role::TABLE_ROW, "table row"}, + {Role::TREE_ITEM, "tree item"}, + {Role::DOCUMENT_SPREADSHEET, "document spreadsheet"}, + {Role::DOCUMENT_PRESENTATION, "document presentation"}, + {Role::DOCUMENT_TEXT, "document text"}, + {Role::DOCUMENT_WEB, "document web"}, + {Role::DOCUMENT_EMAIL, "document email"}, + {Role::COMMENT, "comment"}, + {Role::LIST_BOX, "list box"}, + {Role::GROUPING, "grouping"}, + {Role::IMAGE_MAP, "image map"}, + {Role::NOTIFICATION, "notification"}, + {Role::INFO_BAR, "info bar"}, + {Role::LEVEL_BAR, "level bar"}, + {Role::TITLE_BAR, "title bar"}, + {Role::BLOCK_QUOTE, "block quote"}, + {Role::AUDIO, "audio"}, + {Role::VIDEO, "video"}, + {Role::DEFINITION, "definition"}, + {Role::ARTICLE, "article"}, + {Role::LANDMARK, "landmark"}, + {Role::LOG, "log"}, + {Role::MARQUEE, "marquee"}, + {Role::MATH, "math"}, + {Role::RATING, "rating"}, + {Role::TIMER, "timer"}, + {Role::STATIC, "static"}, + {Role::MATH_FRACTION, "math fraction"}, + {Role::MATH_ROOT, "math root"}, + {Role::SUBSCRIPT, "subscript"}, + {Role::SUPERSCRIPT, "superscript"}, + }; + + auto it = roleMap.find(GetRole()); + + if(it == roleMap.end()) { - case Role::INVALID: - { - return "invalid"; - } - case Role::ACCELERATOR_LABEL: - { - return "accelerator label"; - } - case Role::ALERT: - { - return "alert"; - } - case Role::ANIMATION: - { - return "animation"; - } - case Role::ARROW: - { - return "arrow"; - } - case Role::CALENDAR: - { - return "calendar"; - } - case Role::CANVAS: - { - return "canvas"; - } - case Role::CHECK_BOX: - { - return "check box"; - } - case Role::CHECK_MENU_ITEM: - { - return "check menu item"; - } - case Role::COLOR_CHOOSER: - { - return "color chooser"; - } - case Role::COLUMN_HEADER: - { - return "column header"; - } - case Role::COMBO_BOX: - { - return "combo box"; - } - case Role::DATE_EDITOR: - { - return "date editor"; - } - case Role::DESKTOP_ICON: - { - return "desktop icon"; - } - case Role::DESKTOP_FRAME: - { - return "desktop frame"; - } - case Role::DIAL: - { - return "dial"; - } - case Role::DIALOG: - { - return "dialog"; - } - case Role::DIRECTORY_PANE: - { - return "directory pane"; - } - case Role::DRAWING_AREA: - { - return "drawing area"; - } - case Role::FILE_CHOOSER: - { - return "file chooser"; - } - case Role::FILLER: - { - return "filler"; - } - case Role::FOCUS_TRAVERSABLE: - { - return "focus traversable"; - } - case Role::FONT_CHOOSER: - { - return "font chooser"; - } - case Role::FRAME: - { - return "frame"; - } - case Role::GLASS_PANE: - { - return "glass pane"; - } - case Role::HTML_CONTAINER: - { - return "html container"; - } - case Role::ICON: - { - return "icon"; - } - case Role::IMAGE: - { - return "image"; - } - case Role::INTERNAL_FRAME: - { - return "internal frame"; - } - case Role::LABEL: - { - return "label"; - } - case Role::LAYERED_PANE: - { - return "layered pane"; - } - case Role::LIST: - { - return "list"; - } - case Role::LIST_ITEM: - { - return "list item"; - } - case Role::MENU: - { - return "menu"; - } - case Role::MENU_BAR: - { - return "menu bar"; - } - case Role::MENU_ITEM: - { - return "menu item"; - } - case Role::OPTION_PANE: - { - return "option pane"; - } - case Role::PAGE_TAB: - { - return "page tab"; - } - case Role::PAGE_TAB_LIST: - { - return "page tab list"; - } - case Role::PANEL: - { - return "panel"; - } - case Role::PASSWORD_TEXT: - { - return "password text"; - } - case Role::POPUP_MENU: - { - return "popup menu"; - } - case Role::PROGRESS_BAR: - { - return "progress bar"; - } - case Role::PUSH_BUTTON: - { - return "push button"; - } - case Role::RADIO_BUTTON: - { - return "radio button"; - } - case Role::RADIO_MENU_ITEM: - { - return "radio menu item"; - } - case Role::ROOT_PANE: - { - return "root pane"; - } - case Role::ROW_HEADER: - { - return "row header"; - } - case Role::SCROLL_BAR: - { - return "scroll bar"; - } - case Role::SCROLL_PANE: - { - return "scroll pane"; - } - case Role::SEPARATOR: - { - return "separator"; - } - case Role::SLIDER: - { - return "slider"; - } - case Role::SPIN_BUTTON: - { - return "spin button"; - } - case Role::SPLIT_PANE: - { - return "split pane"; - } - case Role::STATUS_BAR: - { - return "status bar"; - } - case Role::TABLE: - { - return "table"; - } - case Role::TABLE_CELL: - { - return "table cell"; - } - case Role::TABLE_COLUMN_HEADER: - { - return "table column header"; - } - case Role::TABLE_ROW_HEADER: - { - return "table row header"; - } - case Role::TEAROFF_MENU_ITEM: - { - return "tearoff menu item"; - } - case Role::TERMINAL: - { - return "terminal"; - } - case Role::TEXT: - { - return "text"; - } - case Role::TOGGLE_BUTTON: - { - return "toggle button"; - } - case Role::TOOL_BAR: - { - return "tool bar"; - } - case Role::TOOL_TIP: - { - return "tool tip"; - } - case Role::TREE: - { - return "tree"; - } - case Role::TREE_TABLE: - { - return "tree table"; - } - case Role::UNKNOWN: - { - return "unknown"; - } - case Role::VIEWPORT: - { - return "viewport"; - } - case Role::WINDOW: - { - return "window"; - } - case Role::EXTENDED: - { - return "extended"; - } - case Role::HEADER: - { - return "header"; - } - case Role::FOOTER: - { - return "footer"; - } - case Role::PARAGRAPH: - { - return "paragraph"; - } - case Role::RULER: - { - return "ruler"; - } - case Role::APPLICATION: - { - return "application"; - } - case Role::AUTOCOMPLETE: - { - return "autocomplete"; - } - case Role::EDITBAR: - { - return "edit bar"; - } - case Role::EMBEDDED: - { - return "embedded"; - } - case Role::ENTRY: - { - return "entry"; - } - case Role::CHART: - { - return "chart"; - } - case Role::CAPTION: - { - return "caution"; - } - case Role::DOCUMENT_FRAME: - { - return "document frame"; - } - case Role::HEADING: - { - return "heading"; - } - case Role::PAGE: - { - return "page"; - } - case Role::SECTION: - { - return "section"; - } - case Role::REDUNDANT_OBJECT: - { - return "redundant object"; - } - case Role::FORM: - { - return "form"; - } - case Role::LINK: - { - return "link"; - } - case Role::INPUT_METHOD_WINDOW: - { - return "input method window"; - } - case Role::TABLE_ROW: - { - return "table row"; - } - case Role::TREE_ITEM: - { - return "tree item"; - } - case Role::DOCUMENT_SPREADSHEET: - { - return "document spreadsheet"; - } - case Role::DOCUMENT_PRESENTATION: - { - return "document presentation"; - } - case Role::DOCUMENT_TEXT: - { - return "document text"; - } - case Role::DOCUMENT_WEB: - { - return "document web"; - } - case Role::DOCUMENT_EMAIL: - { - return "document email"; - } - case Role::COMMENT: - { - return "comment"; - } - case Role::LIST_BOX: - { - return "list box"; - } - case Role::GROUPING: - { - return "grouping"; - } - case Role::IMAGE_MAP: - { - return "image map"; - } - case Role::NOTIFICATION: - { - return "notification"; - } - case Role::INFO_BAR: - { - return "info bar"; - } - case Role::LEVEL_BAR: - { - return "level bar"; - } - case Role::TITLE_BAR: - { - return "title bar"; - } - case Role::BLOCK_QUOTE: - { - return "block quote"; - } - case Role::AUDIO: - { - return "audio"; - } - case Role::VIDEO: - { - return "video"; - } - case Role::DEFINITION: - { - return "definition"; - } - case Role::ARTICLE: - { - return "article"; - } - case Role::LANDMARK: - { - return "landmark"; - } - case Role::LOG: - { - return "log"; - } - case Role::MARQUEE: - { - return "marquee"; - } - case Role::MATH: - { - return "math"; - } - case Role::RATING: - { - return "rating"; - } - case Role::TIMER: - { - return "timer"; - } - case Role::STATIC: - { - return "static"; - } - case Role::MATH_FRACTION: - { - return "math fraction"; - } - case Role::MATH_ROOT: - { - return "math root"; - } - case Role::SUBSCRIPT: - { - return "subscript"; - } - case Role::SUPERSCRIPT: - { - return "superscript"; - } - case Role::MAX_COUNT: - { - break; - } + return {}; } - return ""; + + return std::string{it->second}; } Dali::Actor Accessible::GetCurrentlyHighlightedActor() @@ -601,7 +238,7 @@ protected: Dali::WeakHandle mSelf; bool mRoot = false; - Dali::Actor Self() + Dali::Actor Self() const { auto handle = mSelf.GetHandle(); @@ -619,7 +256,7 @@ public: { } - Dali::Rect<> GetExtents(Dali::Accessibility::CoordinateType type) override + Dali::Rect<> GetExtents(Dali::Accessibility::CoordinateType type) const override { Dali::Actor actor = Self(); Vector2 screenPosition = actor.GetProperty(Actor::Property::SCREEN_POSITION).Get(); @@ -634,23 +271,23 @@ public: } else // Dali::Accessibility::CoordinateType::SCREEN { - auto window = Dali::DevelWindow::Get(actor); + auto window = Dali::DevelWindow::Get(actor); auto windowPosition = window.GetPosition(); return {position.x + windowPosition.GetX(), position.y + windowPosition.GetY(), size.x, size.y}; } } - Dali::Accessibility::ComponentLayer GetLayer() override + Dali::Accessibility::ComponentLayer GetLayer() const override { return Dali::Accessibility::ComponentLayer::WINDOW; } - int16_t GetMdiZOrder() override + int16_t GetMdiZOrder() const override { return 0; } - double GetAlpha() override + double GetAlpha() const override { return 0; } @@ -670,17 +307,17 @@ public: return false; } - bool IsScrollable() override + bool IsScrollable() const override { return false; } - std::string GetName() override + std::string GetName() const override { return Self().GetProperty(Dali::Actor::Property::NAME); } - std::string GetDescription() override + std::string GetDescription() const override { return ""; } @@ -695,7 +332,7 @@ public: return Get(Self().GetParent()); } - size_t GetChildCount() override + size_t GetChildCount() const override { return static_cast(Self().GetChildCount()); } @@ -728,7 +365,7 @@ public: throw std::domain_error{"actor is not a child of it's parent"}; } - Role GetRole() override + Role GetRole() const override { return mRoot ? Role::WINDOW : Role::REDUNDANT_OBJECT; } @@ -738,8 +375,8 @@ public: States state; if(mRoot) { - auto window = Dali::DevelWindow::Get(Self()); - auto visible = window.IsVisible(); + auto window = Dali::DevelWindow::Get(Self()); + auto visible = window.IsVisible(); state[State::ENABLED] = true; state[State::SENSITIVE] = true; state[State::SHOWING] = visible; @@ -748,19 +385,18 @@ public: } else { - auto parentState = GetParent()->GetStates(); + auto parentState = GetParent()->GetStates(); state[State::SHOWING] = parentState[State::SHOWING]; state[State::VISIBLE] = parentState[State::VISIBLE]; } return state; } - Attributes GetAttributes() override + Attributes GetAttributes() const override { Dali::TypeInfo type; Self().GetTypeInfo(type); - return - { + return { {"class", type.GetName()}, }; } diff --git a/dali/devel-api/adaptor-framework/proxy-accessible.h b/dali/devel-api/adaptor-framework/proxy-accessible.h index c931039..e60c7e1 100644 --- a/dali/devel-api/adaptor-framework/proxy-accessible.h +++ b/dali/devel-api/adaptor-framework/proxy-accessible.h @@ -30,16 +30,16 @@ namespace Dali::Accessibility /** * @brief The minimalistic, always empty Accessible object with settable address. * - * For those situations, where you want to return address in different bridge - * (embedding for example), but the object itself ain't planned to be used otherwise. - * This object has null parent, no children, empty name and so on + * To be used as a proxy object, in those situations where you want to return an address in + * a different bridge (embedding for example), but the object itself isn't planned to be used + * otherwise. This object has no parent, no children, an empty name and so on. */ -class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible +class DALI_ADAPTOR_API ProxyAccessible : public virtual Accessible { public: - EmptyAccessibleWithAddress() = default; + ProxyAccessible() = default; - EmptyAccessibleWithAddress(Address address) + ProxyAccessible(Address address) : mAddress(std::move(address)) { } @@ -49,12 +49,12 @@ public: this->mAddress = std::move(address); } - std::string GetName() override + std::string GetName() const override { return ""; } - std::string GetDescription() override + std::string GetDescription() const override { return ""; } @@ -64,7 +64,7 @@ public: return nullptr; } - size_t GetChildCount() override + size_t GetChildCount() const override { return 0; } @@ -84,24 +84,27 @@ public: return static_cast(-1); } - Role GetRole() override + Role GetRole() const override { return {}; } - std::string GetRoleName() override; + std::string GetRoleName() const override + { + return {}; + } States GetStates() override { return {}; } - Attributes GetAttributes() override + Attributes GetAttributes() const override { return {}; } - Address GetAddress() override + Address GetAddress() const override { return mAddress; } diff --git a/dali/devel-api/atspi-interfaces/accessible.h b/dali/devel-api/atspi-interfaces/accessible.h index da7786e..91dc7ab 100644 --- a/dali/devel-api/atspi-interfaces/accessible.h +++ b/dali/devel-api/atspi-interfaces/accessible.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -36,7 +37,7 @@ namespace Dali::Accessibility class DALI_ADAPTOR_API Accessible { public: - virtual ~Accessible(); + virtual ~Accessible() noexcept; using utf8_t = unsigned char; @@ -50,7 +51,7 @@ public: * * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length. */ - void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks); + static void FindWordSeparationsUtf8(const utf8_t* string, std::size_t length, const char* language, char* breaks); /** * @brief Calculates and finds line boundaries in given utf8 text. @@ -62,7 +63,7 @@ public: * * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length. */ - void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks); + static void FindLineSeparationsUtf8(const utf8_t* string, std::size_t length, const char* language, char* breaks); /** * @brief Helper function for emiting active-descendant-changed event. @@ -176,14 +177,14 @@ public: * * @return The string with name */ - virtual std::string GetName() = 0; + virtual std::string GetName() const = 0; /** * @brief Gets accessibility description. * * @return The string with description */ - virtual std::string GetDescription() = 0; + virtual std::string GetDescription() const = 0; /** * @brief Gets parent. @@ -197,7 +198,7 @@ public: * * @return The number of children */ - virtual size_t GetChildCount() = 0; + virtual std::size_t GetChildCount() const = 0; /** * @brief Gets collection with all children. @@ -211,14 +212,14 @@ public: * * @return The child object */ - virtual Accessible* GetChildAtIndex(size_t index) = 0; + virtual Accessible* GetChildAtIndex(std::size_t index) = 0; /** * @brief Gets index that current object has in its parent's children collection. * * @return The index of the current object */ - virtual size_t GetIndexInParent() = 0; + virtual std::size_t GetIndexInParent() = 0; /** * @brief Gets accessibility role. @@ -227,7 +228,7 @@ public: * * @see Dali::Accessibility::Role */ - virtual Role GetRole() = 0; + virtual Role GetRole() const = 0; /** * @brief Gets name of accessibility role. @@ -237,7 +238,7 @@ public: * @see Dali::Accessibility::Role * @see Accessibility::Accessible::GetRole */ - virtual std::string GetRoleName(); + virtual std::string GetRoleName() const; /** * @brief Gets localized name of accessibility role. @@ -251,7 +252,7 @@ public: * * @note translation is not supported in this version */ - virtual std::string GetLocalizedRoleName(); + virtual std::string GetLocalizedRoleName() const; /** * @brief Gets accessibility states. @@ -270,14 +271,14 @@ public: * * @return The map of attributes and their values */ - virtual Attributes GetAttributes() = 0; + virtual Attributes GetAttributes() const = 0; /** * @brief Checks if this is proxy. * * @return True if this is proxy */ - virtual bool IsProxy(); + virtual bool IsProxy() const; /** * @brief Gets unique address on accessibility bus. @@ -286,7 +287,7 @@ public: * * @see Dali::Accessibility::Address */ - virtual Address GetAddress(); + virtual Address GetAddress() const; /** * @brief Deputes an object to perform provided gesture. @@ -329,7 +330,7 @@ public: * * @return The collection of strings with implemented interfaces */ - std::vector GetInterfaces(); + std::vector GetInterfaces() const; /** * @brief Checks if object is on root level. @@ -347,7 +348,7 @@ protected: Accessible(Accessible&&) = delete; Accessible& operator=(const Accessible&) = delete; Accessible& operator=(Accessible&&) = delete; - std::shared_ptr GetBridgeData(); + std::shared_ptr GetBridgeData() const; public: /** @@ -406,8 +407,8 @@ public: private: friend class Bridge; - std::weak_ptr mBridgeData; - bool mIsOnRootLevel = false; + mutable std::weak_ptr mBridgeData; + bool mIsOnRootLevel = false; }; // Accessible class diff --git a/dali/devel-api/atspi-interfaces/action.h b/dali/devel-api/atspi-interfaces/action.h index 0276378..b3d9717 100644 --- a/dali/devel-api/atspi-interfaces/action.h +++ b/dali/devel-api/atspi-interfaces/action.h @@ -38,7 +38,7 @@ public: * * @return The string with name of action */ - virtual std::string GetActionName(size_t index) = 0; + virtual std::string GetActionName(std::size_t index) const = 0; /** * @brief Gets translated name of action with given index. @@ -49,7 +49,7 @@ public: * * @note The translation is not supported in this version */ - virtual std::string GetLocalizedActionName(size_t index) = 0; + virtual std::string GetLocalizedActionName(std::size_t index) const = 0; /** * @brief Gets description of action with given index. @@ -58,7 +58,7 @@ public: * * @return The string with description of action */ - virtual std::string GetActionDescription(size_t index) = 0; + virtual std::string GetActionDescription(std::size_t index) const = 0; /** * @brief Gets key code binded to action with given index. @@ -67,14 +67,14 @@ public: * * @return The string with key name */ - virtual std::string GetActionKeyBinding(size_t index) = 0; + virtual std::string GetActionKeyBinding(std::size_t index) const = 0; /** * @brief Gets number of provided actions. * * @return The number of actions */ - virtual size_t GetActionCount() = 0; + virtual std::size_t GetActionCount() const = 0; /** * @brief Performs an action with given index. @@ -83,7 +83,7 @@ public: * * @return true on success, false otherwise */ - virtual bool DoAction(size_t index) = 0; + virtual bool DoAction(std::size_t index) = 0; /** * @brief Performs an action with given name. diff --git a/dali/devel-api/atspi-interfaces/application.h b/dali/devel-api/atspi-interfaces/application.h index c4eb62a..5e37f6b 100644 --- a/dali/devel-api/atspi-interfaces/application.h +++ b/dali/devel-api/atspi-interfaces/application.h @@ -40,14 +40,14 @@ public: * * @return String with name */ - virtual std::string GetToolkitName() = 0; + virtual std::string GetToolkitName() const = 0; /** * @brief Gets version of graphic user interface framework used by an application. * * @return String with version */ - virtual std::string GetVersion() = 0; + virtual std::string GetVersion() const = 0; }; } // namespace Dali::Accessibility diff --git a/dali/devel-api/atspi-interfaces/collection.h b/dali/devel-api/atspi-interfaces/collection.h index 173c929..6452854 100644 --- a/dali/devel-api/atspi-interfaces/collection.h +++ b/dali/devel-api/atspi-interfaces/collection.h @@ -30,7 +30,6 @@ namespace Dali::Accessibility */ class DALI_ADAPTOR_API Collection : public virtual Accessible { -public: }; } // namespace Dali::Accessibility diff --git a/dali/devel-api/atspi-interfaces/component.h b/dali/devel-api/atspi-interfaces/component.h index b32fe02..5a0fa73 100644 --- a/dali/devel-api/atspi-interfaces/component.h +++ b/dali/devel-api/atspi-interfaces/component.h @@ -42,7 +42,7 @@ public: * * @see Dali::Rect */ - virtual Rect<> GetExtents(CoordinateType type) = 0; + virtual Rect<> GetExtents(CoordinateType type) const = 0; /** * @brief Gets layer current object is localized on. @@ -51,7 +51,7 @@ public: * * @see Dali::Accessibility::ComponentLayer */ - virtual ComponentLayer GetLayer() = 0; + virtual ComponentLayer GetLayer() const = 0; /** * @brief Gets value of z-order. @@ -61,7 +61,7 @@ public: * which in short means that many stacked windows can be displayed within a single application. * In such model, the concept of z-order of UI element became important to deal with element overlapping. */ - virtual int16_t GetMdiZOrder() = 0; + virtual int16_t GetMdiZOrder() const = 0; /** * @brief Sets current object as "focused". @@ -75,7 +75,7 @@ public: * * @return The alpha channel value in range [0.0, 1.0] */ - virtual double GetAlpha() = 0; + virtual double GetAlpha() const = 0; /** * @brief Sets current object as "highlighted". @@ -105,7 +105,7 @@ public: * * @see Dali:Accessibility::State */ - virtual bool IsScrollable(); + virtual bool IsScrollable() const; /** * @brief Gets Accessible object containing given point. @@ -130,7 +130,7 @@ public: * @remarks This method is `Contains` in DBus method. * @see Dali::Accessibility::Point */ - virtual bool IsAccessibleContainingPoint(Point point, CoordinateType type); + virtual bool IsAccessibleContainingPoint(Point point, CoordinateType type) const; }; } // namespace Dali::Accessibility diff --git a/dali/devel-api/atspi-interfaces/editable-text.h b/dali/devel-api/atspi-interfaces/editable-text.h index b710958..66c822e 100644 --- a/dali/devel-api/atspi-interfaces/editable-text.h +++ b/dali/devel-api/atspi-interfaces/editable-text.h @@ -22,6 +22,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali::Accessibility { @@ -32,7 +33,7 @@ namespace Dali::Accessibility * * @see Dali::Accessibility::EditableText */ -class DALI_ADAPTOR_API EditableText : public virtual Accessible +class DALI_ADAPTOR_API EditableText : public virtual Accessible, public virtual Text { public: /** @@ -43,7 +44,7 @@ public: * * @return true on success, false otherwise */ - virtual bool CopyText(size_t startPosition, size_t endPosition) = 0; + virtual bool CopyText(std::size_t startPosition, std::size_t endPosition) = 0; /** * @brief Cuts text in range to system clipboard. @@ -53,7 +54,7 @@ public: * * @return true on success, false otherwise */ - virtual bool CutText(size_t startPosition, size_t endPosition) = 0; + virtual bool CutText(std::size_t startPosition, std::size_t endPosition) = 0; /** * @brief Deletes text in range. @@ -63,7 +64,7 @@ public: * * @return true on success, false otherwise */ - virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0; + virtual bool DeleteText(std::size_t startPosition, std::size_t endPosition) = 0; /** * @brief Inserts text at startPosition. @@ -73,7 +74,7 @@ public: * * @return true on success, false otherwise */ - virtual bool InsertText(size_t startPosition, std::string text) = 0; + virtual bool InsertText(std::size_t startPosition, std::string text) = 0; /** * @brief Replaces text with content. diff --git a/dali/devel-api/atspi-interfaces/hyperlink.h b/dali/devel-api/atspi-interfaces/hyperlink.h index dc24615..5f7c8f5 100644 --- a/dali/devel-api/atspi-interfaces/hyperlink.h +++ b/dali/devel-api/atspi-interfaces/hyperlink.h @@ -37,21 +37,21 @@ public: * * @return The 0-based index of hyperlink's last character + 1, in its originating hypertext. */ - virtual int32_t GetEndIndex() const = 0; + virtual std::int32_t GetEndIndex() const = 0; /** * @brief Gets the index of character in originating hypertext at which this hyperlink starts. * * @return The 0-based index of hyperlink's first character, in its originating hypertext. */ - virtual int32_t GetStartIndex() const = 0; + virtual std::int32_t GetStartIndex() const = 0; /** * @brief Gets the total number of anchors which this hyperlink has. Though, typical hyperlinks will have only one anchor. * * @return The number of anchors. */ - virtual int32_t GetAnchorCount() const = 0; + virtual std::int32_t GetAnchorCount() const = 0; /** * @brief Gets the object associated with a particular hyperlink's anchor. @@ -60,7 +60,7 @@ public: * * @return The handle to accessible object. */ - virtual Accessible* GetAnchorAccessible(int32_t anchorIndex) const = 0; + virtual Accessible* GetAnchorAccessible(std::int32_t anchorIndex) const = 0; /** * @brief Gets the URI associated with a particular hyperlink's anchor. @@ -69,7 +69,7 @@ public: * * @return The string containing URI. */ - virtual std::string GetAnchorUri(int32_t anchorIndex) const = 0; + virtual std::string GetAnchorUri(std::int32_t anchorIndex) const = 0; /** * @brief Tells whether this hyperlink object is still valid with respect to its originating hypertext object. diff --git a/dali/devel-api/atspi-interfaces/hypertext.h b/dali/devel-api/atspi-interfaces/hypertext.h index cc96bbb..e9b4deb 100644 --- a/dali/devel-api/atspi-interfaces/hypertext.h +++ b/dali/devel-api/atspi-interfaces/hypertext.h @@ -39,7 +39,7 @@ public: * * @return Handle to hyperlink object at a specified index in hyperlink collection of hypertext. */ - virtual Hyperlink* GetLink(int32_t linkIndex) const = 0; + virtual Hyperlink* GetLink(std::int32_t linkIndex) const = 0; /** * @brief Gets the index in hyperlink collection occupied by hyperlink which spans over a specified character offset in this hypertext. @@ -48,14 +48,14 @@ public: * * @return The value of 0-based index in hyperlink collection (-1 if there is no hyperlink at the specified character offset). */ - virtual int32_t GetLinkIndex(int32_t characterOffset) const = 0; + virtual std::int32_t GetLinkIndex(std::int32_t characterOffset) const = 0; /** * @brief Gets number of hyperlinks stored in this hypertext. * * @return The number of hyperlinks (zero if none or -1 if the number cannot be determined) */ - virtual int32_t GetLinkCount() const = 0; + virtual std::int32_t GetLinkCount() const = 0; }; } // namespace Dali::Accessibility diff --git a/dali/devel-api/atspi-interfaces/selection.h b/dali/devel-api/atspi-interfaces/selection.h index fb6bdf9..2aadd67 100644 --- a/dali/devel-api/atspi-interfaces/selection.h +++ b/dali/devel-api/atspi-interfaces/selection.h @@ -33,7 +33,7 @@ public: * * @return The number of selected children (zero if none) */ - virtual int GetSelectedChildrenCount() = 0; + virtual int GetSelectedChildrenCount() const = 0; /** * @brief Gets a specific selected child. @@ -77,7 +77,7 @@ public: * * @return true if given child is selected, false otherwise */ - virtual bool IsChildSelected(int childIndex) = 0; + virtual bool IsChildSelected(int childIndex) const = 0; /** * @brief Selects all children. diff --git a/dali/devel-api/atspi-interfaces/text.h b/dali/devel-api/atspi-interfaces/text.h index 53158ba..bd2981c 100644 --- a/dali/devel-api/atspi-interfaces/text.h +++ b/dali/devel-api/atspi-interfaces/text.h @@ -42,7 +42,7 @@ public: * * @return The substring of stored text */ - virtual std::string GetText(size_t startOffset, size_t endOffset) = 0; + virtual std::string GetText(std::size_t startOffset, std::size_t endOffset) const = 0; /** * @brief Gets number of all stored characters. @@ -50,7 +50,7 @@ public: * @return The number of characters * @remarks This method is `CharacterCount` in DBus method. */ - virtual size_t GetCharacterCount() = 0; + virtual std::size_t GetCharacterCount() const = 0; /** * @brief Gets the cursor offset. @@ -58,7 +58,7 @@ public: * @return Value of cursor offset * @remarks This method is `CaretOffset` in DBus method. */ - virtual size_t GetCursorOffset() = 0; + virtual std::size_t GetCursorOffset() const = 0; /** * @brief Sets the cursor offset. @@ -68,7 +68,7 @@ public: * @return True if successful * @remarks This method is `SetCaretOffset` in DBus method. */ - virtual bool SetCursorOffset(size_t offset) = 0; + virtual bool SetCursorOffset(std::size_t offset) = 0; /** * @brief Gets substring of stored text truncated in concrete gradation. @@ -80,7 +80,7 @@ public: * * @see Dali::Accessibility::Range */ - virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0; + virtual Range GetTextAtOffset(std::size_t offset, TextBoundary boundary) const = 0; /** * @brief Gets selected text. @@ -93,7 +93,7 @@ public: * @remarks This method is `GetSelection` in DBus method. * @see Dali::Accessibility::Range */ - virtual Range GetRangeOfSelection(size_t selectionIndex) = 0; + virtual Range GetRangeOfSelection(std::size_t selectionIndex) const = 0; /** * @brief Removes the whole selection. @@ -103,7 +103,7 @@ public: * * @return bool on success, false otherwise */ - virtual bool RemoveSelection(size_t selectionIndex) = 0; + virtual bool RemoveSelection(std::size_t selectionIndex) = 0; /** * @brief Sets selected text. @@ -117,7 +117,7 @@ public: * @return true on success, false otherwise * @remarks This method is `SetSelection` in DBus method. */ - virtual bool SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) = 0; + virtual bool SetRangeOfSelection(std::size_t selectionIndex, std::size_t startOffset, std::size_t endOffset) = 0; }; } // namespace Dali::Accessibility diff --git a/dali/devel-api/atspi-interfaces/value.h b/dali/devel-api/atspi-interfaces/value.h index 69bba32..350e2be 100644 --- a/dali/devel-api/atspi-interfaces/value.h +++ b/dali/devel-api/atspi-interfaces/value.h @@ -33,21 +33,21 @@ public: * * @return The minimum value */ - virtual double GetMinimum() = 0; + virtual double GetMinimum() const = 0; /** * @brief Gets the current value. * * @return The current value */ - virtual double GetCurrent() = 0; + virtual double GetCurrent() const = 0; /** * @brief Gets the highest possible value. * * @return The highest value. */ - virtual double GetMaximum() = 0; + virtual double GetMaximum() const = 0; /** * @brief Sets the current value. @@ -63,7 +63,7 @@ public: * * @return The lowest increment */ - virtual double GetMinimumIncrement() = 0; + virtual double GetMinimumIncrement() const = 0; }; } // namespace Dali::Accessibility diff --git a/dali/internal/accessibility/bridge/accessible.cpp b/dali/internal/accessibility/bridge/accessible.cpp index 2921e60..08c57d3 100644 --- a/dali/internal/accessibility/bridge/accessible.cpp +++ b/dali/internal/accessibility/bridge/accessible.cpp @@ -36,46 +36,46 @@ using namespace Dali::Accessibility; -std::vector Accessible::GetInterfaces() +std::vector Accessible::GetInterfaces() const { std::vector tmp; tmp.push_back(AtspiDbusInterfaceAccessible); - if(dynamic_cast(this)) + if(dynamic_cast(this)) { tmp.push_back(AtspiDbusInterfaceCollection); } - if(dynamic_cast(this)) + if(dynamic_cast(this)) { tmp.push_back(AtspiDbusInterfaceText); } - if(dynamic_cast(this)) + if(dynamic_cast(this)) { tmp.push_back(AtspiDbusInterfaceEditableText); } - if(dynamic_cast(this)) + if(dynamic_cast(this)) { tmp.push_back(AtspiDbusInterfaceValue); } - if(dynamic_cast(this)) + if(dynamic_cast(this)) { tmp.push_back(AtspiDbusInterfaceComponent); } - if(auto action = dynamic_cast(this)) + if(auto action = dynamic_cast(this)) { if(action->GetActionCount() > 0) { tmp.push_back(AtspiDbusInterfaceAction); } } - if(dynamic_cast(this)) + if(dynamic_cast(this)) { tmp.push_back(AtspiDbusInterfaceSelection); } - if(dynamic_cast(this)) + if(dynamic_cast(this)) { tmp.push_back(AtspiDbusInterfaceHypertext); } - if(dynamic_cast(this)) + if(dynamic_cast(this)) { tmp.push_back(AtspiDbusInterfaceHyperlink); } @@ -86,7 +86,7 @@ Accessible::Accessible() { } -Accessible::~Accessible() +Accessible::~Accessible() noexcept { auto handle = mBridgeData.lock(); if(handle) @@ -205,7 +205,7 @@ std::vector Accessible::GetChildren() return tmp; } -std::shared_ptr Accessible::GetBridgeData() +std::shared_ptr Accessible::GetBridgeData() const { auto handle = mBridgeData.lock(); if(!handle) @@ -216,7 +216,7 @@ std::shared_ptr Accessible::GetBridgeData() return handle; } -Address Accessible::GetAddress() +Address Accessible::GetAddress() const { auto handle = mBridgeData.lock(); if(!handle) @@ -232,7 +232,7 @@ Address Accessible::GetAddress() return {handle ? handle->mBusName : "", tmp.str()}; } -void Bridge::RegisterOnBridge(Accessible* object) +void Bridge::RegisterOnBridge(const Accessible* object) { assert(!object->mBridgeData.lock() || object->mBridgeData.lock() == mData); if(!object->mBridgeData.lock()) @@ -243,7 +243,7 @@ void Bridge::RegisterOnBridge(Accessible* object) } } -bool Accessible::IsProxy() +bool Accessible::IsProxy() const { return false; } diff --git a/dali/internal/accessibility/bridge/bridge-base.h b/dali/internal/accessibility/bridge/bridge-base.h index 77cd826..30917e2 100644 --- a/dali/internal/accessibility/bridge/bridge-base.h +++ b/dali/internal/accessibility/bridge/bridge-base.h @@ -33,22 +33,22 @@ #include /** - * @brief The AppAccessible class is to define Accessibility Application. + * @brief The ApplicationAccessible class is to define Accessibility Application. */ -class AppAccessible : public virtual Dali::Accessibility::Accessible, public virtual Dali::Accessibility::Collection, public virtual Dali::Accessibility::Application +class ApplicationAccessible : public virtual Dali::Accessibility::Accessible, public virtual Dali::Accessibility::Collection, public virtual Dali::Accessibility::Application { public: - Dali::Accessibility::EmptyAccessibleWithAddress mParent; - std::vector mChildren; - std::vector mWindows; - std::string mName; + Dali::Accessibility::ProxyAccessible mParent; + std::vector mChildren; + std::vector mWindows; + std::string mName; - std::string GetName() override + std::string GetName() const override { return mName; } - std::string GetDescription() override + std::string GetDescription() const override { return ""; } @@ -58,7 +58,7 @@ public: return &mParent; } - size_t GetChildCount() override + size_t GetChildCount() const override { return mChildren.size(); } @@ -78,7 +78,7 @@ public: throw std::domain_error{"can't call GetIndexInParent on application object"}; } - Dali::Accessibility::Role GetRole() override + Dali::Accessibility::Role GetRole() const override { return Dali::Accessibility::Role::APPLICATION; } @@ -88,7 +88,7 @@ public: return {}; } - Dali::Accessibility::Attributes GetAttributes() override + Dali::Accessibility::Attributes GetAttributes() const override { return {}; } @@ -137,17 +137,17 @@ public: return Dali::Actor{}; } - Dali::Accessibility::Address GetAddress() override + Dali::Accessibility::Address GetAddress() const override { return {"", "root"}; } - std::string GetToolkitName() override + std::string GetToolkitName() const override { return {"dali"}; } - std::string GetVersion() override + std::string GetVersion() const override { return std::to_string(Dali::ADAPTOR_MAJOR_VERSION) + "." + std::to_string(Dali::ADAPTOR_MINOR_VERSION); } @@ -443,7 +443,7 @@ public: } protected: - mutable AppAccessible mApplication; + mutable ApplicationAccessible mApplication; std::vector mDefaultLabels; bool mIsScreenReaderSuppressed = false; diff --git a/dali/internal/accessibility/bridge/component.cpp b/dali/internal/accessibility/bridge/component.cpp index 7992df5..1a4c9c9 100644 --- a/dali/internal/accessibility/bridge/component.cpp +++ b/dali/internal/accessibility/bridge/component.cpp @@ -26,7 +26,7 @@ using namespace Dali::Accessibility; -bool Component::IsAccessibleContainingPoint(Point point, Dali::Accessibility::CoordinateType type) +bool Component::IsAccessibleContainingPoint(Point point, Dali::Accessibility::CoordinateType type) const { auto extents = GetExtents(type); return point.x >= extents.x && point.y >= extents.y && point.x <= extents.x + extents.width && point.y <= extents.y + extents.height; @@ -46,7 +46,7 @@ Accessible* Component::GetAccessibleAtPoint(Point point, Dali::Accessibility::Co return nullptr; } -bool Component::IsScrollable() +bool Component::IsScrollable() const { return false; } diff --git a/dali/internal/accessibility/bridge/dummy-atspi.cpp b/dali/internal/accessibility/bridge/dummy-atspi.cpp index 4fd124b..a4d1cff 100644 --- a/dali/internal/accessibility/bridge/dummy-atspi.cpp +++ b/dali/internal/accessibility/bridge/dummy-atspi.cpp @@ -27,7 +27,7 @@ Accessibility::Accessible::Accessible() { } -Accessibility::Accessible::~Accessible() +Accessibility::Accessible::~Accessible() noexcept { } @@ -36,27 +36,27 @@ std::vector Accessibility::Accessible::GetChildren() return {}; } -Accessibility::Address Accessibility::Accessible::GetAddress() +Accessibility::Address Accessibility::Accessible::GetAddress() const { return {}; } -std::shared_ptr Accessibility::Accessible::GetBridgeData() +std::shared_ptr Accessibility::Accessible::GetBridgeData() const { return {}; } -bool Accessibility::Accessible::IsProxy() +bool Accessibility::Accessible::IsProxy() const { return false; } -bool Accessibility::Component::IsScrollable() +bool Accessibility::Component::IsScrollable() const { return false; } -bool Accessibility::Component::IsAccessibleContainingPoint(Point point, CoordinateType type) +bool Accessibility::Component::IsAccessibleContainingPoint(Point point, CoordinateType type) const { return false; } -- 2.7.4