[AT-SPI][Text] Remove libunibreak dependency on accessible 06/279706/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 16 Aug 2022 12:02:31 +0000 (21:02 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Wed, 17 Aug 2022 09:20:50 +0000 (09:20 +0000)
libunibreak in AT-SPI only used some special case.
I think we don't make it as Accessible's own API.

Change-Id: Id7661320ba6d8a23ae61775642b275ef1e3a2666
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/devel-api/atspi-interfaces/accessible.h
dali/devel-api/text-abstraction/segmentation.cpp
dali/devel-api/text-abstraction/segmentation.h
dali/internal/accessibility/bridge/accessible.cpp
dali/internal/accessibility/bridge/dummy/dummy-atspi.cpp
dali/internal/text/text-abstraction/segmentation-impl.cpp
dali/internal/text/text-abstraction/segmentation-impl.h

index 84fe37c..edac6d9 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_ADAPTOR_ATSPI_ACCESSIBLE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,8 +26,8 @@
 #include <vector>
 
 // INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/accessibility.h>
 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/adaptor-framework/accessibility.h>
 
 namespace Dali::Accessibility
 {
@@ -39,32 +39,6 @@ class DALI_ADAPTOR_API Accessible
 public:
   virtual ~Accessible() noexcept;
 
-  using utf8_t = unsigned char;
-
-  /**
-   * @brief Calculates and finds word boundaries in given utf8 text.
-   *
-   * @param[in] string The source text to find
-   * @param[in] length The length of text to find
-   * @param[in] language The language to use
-   * @param[out] breaks The word boundaries in given text
-   *
-   * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length.
-   */
-  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.
-   *
-   * @param[in] string The source text to find
-   * @param[in] length The length of text to find
-   * @param[in] language The language to use
-   * @param[out] breaks The line boundaries in given text
-   *
-   * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length.
-   */
-  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.
    *
index 5466fae..fa5a01b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,6 +61,24 @@ void Segmentation::GetWordBreakPositions(const Character* const text,
                                                  breakInfo);
 }
 
+void Segmentation::GetLineBreakPositionsUtf8(const uint8_t* const text,
+                                             Length               numberOfCharacters,
+                                             LineBreakInfo*       breakInfo)
+{
+  GetImplementation(*this).GetLineBreakPositionsUtf8(text,
+                                                     numberOfCharacters,
+                                                     breakInfo);
+}
+
+void Segmentation::GetWordBreakPositionsUtf8(const uint8_t* const text,
+                                             Length               numberOfCharacters,
+                                             WordBreakInfo*       breakInfo)
+{
+  GetImplementation(*this).GetWordBreakPositionsUtf8(text,
+                                                     numberOfCharacters,
+                                                     breakInfo);
+}
+
 } // namespace TextAbstraction
 
 } // namespace Dali
index a183ada..42df64f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_PLATFORM_TEXT_ABSTRACTION_SEGMENTATION_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -119,6 +119,53 @@ public:
   void GetWordBreakPositions(const Character* const text,
                              Length                 numberOfCharacters,
                              WordBreakInfo*         breakInfo);
+
+  /**
+   * @brief Retrieves the line break info from utf8.
+   *
+   * @pre @p breakInfo must have enough space allocated for @p numberOfCharacters.
+   *
+   * Possible values for LineBreakInfo are:
+   *
+   *  - 0 is a LINE_MUST_BREAK.  Text must be broken into a new line.
+   *  - 1 is a LINE_ALLOW_BREAK. Is possible to break the text into a new line.
+   *  - 2 is a LINE_NO_BREAK.    Text can't be broken into a new line.
+   *
+     @verbatim
+     i.e. Hello big\nworld produces:
+          2222212220 22220
+     @endverbatim
+   *
+   * @param[in] text Pointer to the first character of the text coded in UTF8.
+   * @param[in] numberOfCharacters The number of characters.
+   * @param[out] breakInfo The line break info.
+   */
+  void GetLineBreakPositionsUtf8(const uint8_t* const text,
+                                 Length               numberOfCharacters,
+                                 LineBreakInfo*       breakInfo);
+
+  /**
+   * @brief Retrieves the word break info from utf8.
+   *
+   * @pre @p breakInfo must have enough space allocated for @p numberOfCharacters.
+   *
+   * Possible values for WordBreakInfo are:
+   *
+   * - 0 is a WORD_BREAK.    Text can be broken into a new word.
+   * - 1 is a WORD_NO_BREAK. Text can't be broken into a new word.
+   *
+     @verbatim
+     i.e. Hello big\nworld produces:
+          1111001100 11110
+     @endverbatim
+   *
+   * @param[in] text Pointer to the first character of the text coded in UTF8.
+   * @param[in] numberOfCharacters The number of characters.
+   * @param[out] breakInfo The word break info.
+   */
+  void GetWordBreakPositionsUtf8(const uint8_t* const text,
+                                 Length               numberOfCharacters,
+                                 WordBreakInfo*       breakInfo);
 };
 
 } // namespace TextAbstraction
index 403bcc4..f97479a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@
 // CLASS HEADER
 
 //INTERNAL INCLUDES
-#include <dali/devel-api/atspi-interfaces/accessible.h>
 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/atspi-interfaces/accessible.h>
 #include <dali/devel-api/atspi-interfaces/socket.h>
 #include <dali/internal/accessibility/bridge/accessibility-common.h>
 #include <third-party/libunibreak/linebreak.h>
@@ -221,13 +221,3 @@ void Accessible::NotifyAccessibilityStateChange(Dali::Accessibility::States stat
     }
   }
 }
-
-void Accessible::FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks)
-{
-  set_wordbreaks_utf8(string, length, language, breaks);
-}
-
-void Accessible::FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks)
-{
-  set_linebreaks_utf8(string, length, language, breaks);
-}
index 5e8e49e..713dd3c 100644 (file)
@@ -15,8 +15,8 @@
  *
  */
 
-#include <dali/devel-api/adaptor-framework/accessibility.h>
 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/adaptor-framework/accessibility.h>
 #include <dali/devel-api/atspi-interfaces/accessible.h>
 #include <dali/devel-api/atspi-interfaces/component.h>
 #include <dali/internal/accessibility/bridge/dummy/dummy-atspi.h>
@@ -141,14 +141,6 @@ void Accessibility::Accessible::EmitSocketAvailable()
 {
 }
 
-void Accessibility::Accessible::FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks)
-{
-}
-
-void Accessibility::Accessible::FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks)
-{
-}
-
 void Accessibility::Accessible::NotifyAccessibilityStateChange(Accessibility::States states, bool isRecursive)
 {
 }
index a677176..774138d 100644 (file)
@@ -31,19 +31,33 @@ namespace Internal
 {
 struct Segmentation::Plugin
 {
-  void GetLineBreakPositions(const Character* const text,
-                             Length                 numberOfCharacters,
-                             LineBreakInfo*         breakInfo)
+  void GetLineBreakPositionsUtf32(const Character* const text,
+                                  Length                 numberOfCharacters,
+                                  LineBreakInfo*         breakInfo)
   {
     set_linebreaks_utf32(text, numberOfCharacters, NULL, breakInfo);
   }
 
-  void GetWordBreakPositions(const Character* const text,
-                             Length                 numberOfCharacters,
-                             WordBreakInfo*         breakInfo)
+  void GetWordBreakPositionsUtf32(const Character* const text,
+                                  Length                 numberOfCharacters,
+                                  WordBreakInfo*         breakInfo)
   {
     set_wordbreaks_utf32(text, numberOfCharacters, NULL, breakInfo);
   }
+
+  void GetLineBreakPositionsUtf8(const uint8_t* const text,
+                                 Length               numberOfCharacters,
+                                 LineBreakInfo*       breakInfo)
+  {
+    set_linebreaks_utf8(text, numberOfCharacters, NULL, breakInfo);
+  }
+
+  void GetWordBreakPositionsUtf8(const uint8_t* const text,
+                                 Length               numberOfCharacters,
+                                 WordBreakInfo*       breakInfo)
+  {
+    set_wordbreaks_utf8(text, numberOfCharacters, NULL, breakInfo);
+  }
 };
 
 Segmentation::Segmentation()
@@ -87,7 +101,7 @@ void Segmentation::GetLineBreakPositions(const Character* const text,
 {
   CreatePlugin();
 
-  mPlugin->GetLineBreakPositions(text, numberOfCharacters, breakInfo);
+  mPlugin->GetLineBreakPositionsUtf32(text, numberOfCharacters, breakInfo);
 }
 
 void Segmentation::GetWordBreakPositions(const Character* const text,
@@ -96,7 +110,25 @@ void Segmentation::GetWordBreakPositions(const Character* const text,
 {
   CreatePlugin();
 
-  mPlugin->GetWordBreakPositions(text, numberOfCharacters, breakInfo);
+  mPlugin->GetWordBreakPositionsUtf32(text, numberOfCharacters, breakInfo);
+}
+
+void Segmentation::GetLineBreakPositionsUtf8(const uint8_t* const text,
+                                             Length               numberOfCharacters,
+                                             LineBreakInfo*       breakInfo)
+{
+  CreatePlugin();
+
+  mPlugin->GetLineBreakPositionsUtf8(text, numberOfCharacters, breakInfo);
+}
+
+void Segmentation::GetWordBreakPositionsUtf8(const uint8_t* const text,
+                                             Length               numberOfCharacters,
+                                             WordBreakInfo*       breakInfo)
+{
+  CreatePlugin();
+
+  mPlugin->GetWordBreakPositionsUtf8(text, numberOfCharacters, breakInfo);
 }
 
 void Segmentation::CreatePlugin()
index 170b7b7..f0d0d8c 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_TEXT_ABSTRACTION_SEGMENTATION_IMPL_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -66,6 +66,20 @@ public:
                              Length                 numberOfCharacters,
                              WordBreakInfo*         breakInfo);
 
+  /**
+   * @copydoc Dali::Segmentation::GetLineBreakPositionsUtf8()
+   */
+  void GetLineBreakPositionsUtf8(const uint8_t* const text,
+                                 Length               numberOfCharacters,
+                                 LineBreakInfo*       breakInfo);
+
+  /**
+   * @copydoc Dali::Segmentation::GetWordBreakPositionsUtf8()
+   */
+  void GetWordBreakPositionsUtf8(const uint8_t* const text,
+                                 Length               numberOfCharacters,
+                                 WordBreakInfo*       breakInfo);
+
 private:
   /**
    * Helper for lazy initialization.