Set FullRelayoutNeeded after GetNaturalSize/GetHeightForWidth to avoid the backup... 55/264455/8
authorShrouq Sabah <s.sabah@samsung.com>
Mon, 20 Sep 2021 11:17:14 +0000 (14:17 +0300)
committerssabah <s.sabah@samsung.com>
Tue, 7 Dec 2021 07:40:26 +0000 (09:40 +0200)
This solved some issues happen after calling GetNaturalSize/GetHeightForWidth or after initialization when set WIDTH_RESIZE_POLICY to ResizePolicy::USE_NATURAL_SIZE

1) Fixing the issue where characters were being drawn at the same location whenever GetNaturalSize was called.
https://review.tizen.org/gerrit/c/platform/core/uifw/dali-toolkit/+/253286
2) Side effect on Scrolling, LineWrap and Invalid position of cursor in TextEditor after calling GetNaturalSize or GetHeightForWidth.
https://review.tizen.org/gerrit/c/platform/core/uifw/dali-toolkit/+/255379
3) Crash issue when set WIDTH_RESIZE_POLICY to ResizePolicy::USE_NATURAL_SIZE in TextEditor then insert/remove characters from 2nd line in it after initialization
4) Crash issue when set WIDTH_RESIZE_POLICY to ResizePolicy::USE_NATURAL_SIZE in TextEditor and select_text at initialization then cut it after initialization
5) Crash issue when set WIDTH_RESIZE_POLICY to ResizePolicy::USE_NATURAL_SIZE in TextEditor then double enter in it after initialization
6) Incorrect NaturalSize after the second call for GetNaturalSize. This issue in TextLabel when call GetNaturalSize, then set MULTI_LINE, then re-call GetNaturalSize with Text has break-line

Change-Id: Ieea984f41a218c62e016baa60156b51e985f2fc0

automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-relayouter.cpp
dali-toolkit/internal/text/text-controller-relayouter.h
dali-toolkit/internal/text/text-controller.cpp

index 02dff2e..c32c391 100644 (file)
@@ -4492,7 +4492,7 @@ int utcDaliTextEditorSelectionClearedSignal(void)
   application.Render();
 
   // Move to second line of the text & Select some text in the right of the current cursor position
-  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); 
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
 
   // remove selection
@@ -4720,4 +4720,212 @@ int utcDaliTextEditorSelectionChangedSignal(void)
   DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
 
   END_TEST;
+}
+
+
+int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
+{
+
+  //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
+  //DaliException on vector: "Iterator not inside vector"
+
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK( editor );
+
+  application.GetScene().Add( editor );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  //Set multilines text
+  editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  //Set ResizePolicy to NaturalSize
+  editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Create a tap event to touch the text editor.
+  TestGenerateTap( application, 5.0f, 5.0f );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Set currsor and add character (in first line)
+  editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
+  application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  //Check the changed text and cursor position
+  DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hellod \n World", TEST_LOCATION );
+  DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 6, TEST_LOCATION );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
+
+int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
+{
+
+  //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
+  //DaliException on vector: "Iterator not inside vector"
+
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK( editor );
+
+  application.GetScene().Add( editor );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  //Set multilines text
+  editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  //Set ResizePolicy to NaturalSize
+  editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
+
+  // Set currsor
+  editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
+  application.SendNotification();
+  application.Render();
+
+  // Set focus and remove character
+  editor.SetKeyInputFocus();
+  application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  //Check the changed text and cursor position
+  DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hell \n World", TEST_LOCATION );
+  DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
+
+int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
+{
+
+  //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
+  //DaliException on vector: "Iterator not inside vector"
+
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK( editor );
+
+  application.GetScene().Add( editor );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  //Set multilines text
+  editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  //Set ResizePolicy to NaturalSize
+  editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
+
+  //Select text at initialization (before the first render)
+  DevelTextEditor::SelectText( editor ,3, 5 );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  //Cut text
+  application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+  application.ProcessEvent( GenerateKey( "x", "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  //Check the changed text and cursor position
+  DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hel \n World", TEST_LOCATION );
+  DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 3, TEST_LOCATION );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
+
+
+int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
+{
+
+  //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
+  //DaliException on vector: "Iterator not inside vector"
+
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK( editor );
+
+  application.GetScene().Add( editor );
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+  //Set multilines text
+  editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
+  editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+  editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+  //Set ResizePolicy to NaturalSize
+  editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
+
+  // Set currsor
+  editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
+  application.SendNotification();
+  application.Render();
+
+  // Set focus and double enter (new line)
+  editor.SetKeyInputFocus();
+  application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+  application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  //Check the changed text and cursor position
+  DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION );
+  DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 7, TEST_LOCATION );
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
 }
\ No newline at end of file
index 35ad959..f287daf 100644 (file)
 #include <dali-toolkit/internal/text/text-controller-impl.h>
 
 // EXTERNAL INCLUDES
-#include <cmath>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/actors/layer.h>
-#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <cmath>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/text/character-set-conversion.h>
@@ -54,10 +54,8 @@ const std::string EMPTY_STRING("");
 
 namespace Dali::Toolkit::Text
 {
-
 namespace
 {
-
 void SetDefaultInputStyle(InputStyle& inputStyle, const FontDefaults* const fontDefaults, const Vector4& textColor)
 {
   // Sets the default text's color.
@@ -342,7 +340,7 @@ void ChangeTextControllerState(Controller::Impl& impl, EventData::State newState
         decorator->StopCursorBlink();
         decorator->SetHandleActive(GRAB_HANDLE, false);
         if(eventData->mDecorator->IsHandleActive(LEFT_SELECTION_HANDLE) ||
-            decorator->IsHandleActive(RIGHT_SELECTION_HANDLE))
+           decorator->IsHandleActive(RIGHT_SELECTION_HANDLE))
         {
           decorator->SetHandleActive(LEFT_SELECTION_HANDLE, false);
           decorator->SetHandleActive(RIGHT_SELECTION_HANDLE, false);
@@ -692,7 +690,6 @@ bool Controller::Impl::SetDefaultLineSpacing(float lineSpacing)
   if(std::fabs(lineSpacing - mLayoutEngine.GetDefaultLineSpacing()) > Math::MACHINE_EPSILON_1000)
   {
     mLayoutEngine.SetDefaultLineSpacing(lineSpacing);
-    mRecalculateNaturalSize = true;
 
     RelayoutForNewLineSize();
     return true;
@@ -705,7 +702,6 @@ bool Controller::Impl::SetDefaultLineSize(float lineSize)
   if(std::fabs(lineSize - mLayoutEngine.GetDefaultLineSize()) > Math::MACHINE_EPSILON_1000)
   {
     mLayoutEngine.SetDefaultLineSize(lineSize);
-    mRecalculateNaturalSize = true;
 
     RelayoutForNewLineSize();
     return true;
@@ -1470,8 +1466,13 @@ void Controller::Impl::RelayoutForNewLineSize()
   mTextUpdateInfo.mNumberOfCharactersToAdd    = mModel->mLogicalModel->mText.Count();
   mOperationsPending                          = static_cast<OperationsMask>(mOperationsPending | LAYOUT);
 
+  mTextUpdateInfo.mFullRelayoutNeeded = true;
+
+  // Need to recalculate natural size
+  mRecalculateNaturalSize = true;
+
   //remove selection
-  if(mEventData && mEventData->mState == EventData::SELECTING)
+  if((mEventData != nullptr) && (mEventData->mState == EventData::SELECTING))
   {
     ChangeState(EventData::EDITING);
   }
@@ -1493,7 +1494,7 @@ void Controller::Impl::ProcessInputStyleChangedSignals()
       // Emit the input style changed signal for each mask
       std::for_each(mEventData->mInputStyleChangedQueue.begin(),
                     mEventData->mInputStyleChangedQueue.end(),
-                    [&](const auto mask) { mEditableControlInterface->InputStyleChanged(mask); } );
+                    [&](const auto mask) { mEditableControlInterface->InputStyleChanged(mask); });
     }
 
     mEventData->mInputStyleChangedQueue.Clear();
@@ -1724,7 +1725,7 @@ void Controller::Impl::SetVerticalAlignment(VerticalAlignment::Type alignment)
   {
     // Set the alignment.
     mModel->mVerticalAlignment = alignment;
-    mOperationsPending = static_cast<OperationsMask>(mOperationsPending | ALIGN);
+    mOperationsPending         = static_cast<OperationsMask>(mOperationsPending | ALIGN);
     RequestRelayout();
   }
 }
@@ -1804,7 +1805,6 @@ void Controller::Impl::ClearStyleData()
   mModel->mLogicalModel->ClearFontDescriptionRuns();
 }
 
-
 void Controller::Impl::ResetScrollPosition()
 {
   if(mEventData)
index ce40c60..34e7053 100644 (file)
@@ -49,7 +49,7 @@ namespace Toolkit
 {
 namespace Text
 {
-Size Controller::Relayouter::CalculateLayoutSizeOnRequiredControllerSize(Controller& controller, const Size& requestedControllerSize, const OperationsMask& requestedOperationsMask, bool restoreLinesAndGlyphPositions)
+Size Controller::Relayouter::CalculateLayoutSizeOnRequiredControllerSize(Controller& controller, const Size& requestedControllerSize, const OperationsMask& requestedOperationsMask)
 {
   DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->CalculateLayoutSizeOnRequiredControllerSize\n");
   Size calculatedLayoutSize;
@@ -58,17 +58,6 @@ Size Controller::Relayouter::CalculateLayoutSizeOnRequiredControllerSize(Control
   ModelPtr&         model       = impl.mModel;
   VisualModelPtr&   visualModel = model->mVisualModel;
 
-  // Store the pending operations mask so that it can be restored later on with no modifications made on it
-  // while getting the natural size were reflected on the original mask.
-  OperationsMask operationsPendingBackUp = static_cast<OperationsMask>(impl.mOperationsPending);
-
-  // This is a hotfix for side effect on Scrolling, LineWrap and Invalid position of cursor in TextEditor after calling CalculateLayoutSizeOnRequiredControllerSize.
-  // The number of lines and glyph-positions inside visualModel have been changed by calling DoRelayout with requestedControllerSize.
-  // Store the mLines and mGlyphPositions from visualModel so that they can be restored later on with no modifications made on them.
-  //TODO: Refactor "DoRelayout" and extract common code of size calculation without modifying attributes of mVisualModel, and then blah, blah, etc.
-  Vector<LineRun> linesBackup          = visualModel->mLines;
-  Vector<Vector2> glyphPositionsBackup = visualModel->mGlyphPositions;
-
   // Operations that can be done only once until the text changes.
   const OperationsMask onlyOnceOperations = static_cast<OperationsMask>(CONVERT_TO_UTF32 |
                                                                         GET_SCRIPTS |
@@ -89,39 +78,59 @@ Size Controller::Relayouter::CalculateLayoutSizeOnRequiredControllerSize(Control
   textUpdateInfo.mParagraphCharacterIndex     = 0u;
   textUpdateInfo.mRequestedNumberOfCharacters = model->mLogicalModel->mText.Count();
 
-  // Make sure the model is up-to-date before layouting
-  impl.UpdateModel(onlyOnceOperations);
+  // This is to keep Index to the first character to be updated.
+  // Then restore it after calling Clear method.
+  auto updateInfoCharIndexBackup = textUpdateInfo.mCharacterIndex;
 
   // Get a reference to the pending operations member
   OperationsMask& operationsPending = impl.mOperationsPending;
 
   // Layout the text for the new width.
-  operationsPending = static_cast<OperationsMask>(operationsPending | requestedOperationsMask);
+  // Apply the pending operations, requested operations and the only once operations.
+  // Then remove onlyOnceOperations
+  operationsPending = static_cast<OperationsMask>(operationsPending | requestedOperationsMask | onlyOnceOperations);
+
+  // Make sure the model is up-to-date before layouting
+  impl.UpdateModel(static_cast<OperationsMask>(operationsPending & ~UPDATE_LAYOUT_SIZE));
 
   // Store the actual control's size to restore later.
   const Size actualControlSize = visualModel->mControlSize;
 
   DoRelayout(impl,
              requestedControllerSize,
-             static_cast<OperationsMask>(onlyOnceOperations |
-                                         requestedOperationsMask),
+             static_cast<OperationsMask>(operationsPending & ~UPDATE_LAYOUT_SIZE),
              calculatedLayoutSize);
 
   // Clear the update info. This info will be set the next time the text is updated.
   textUpdateInfo.Clear();
-  textUpdateInfo.mClearAll = true;
+
+  //TODO: Refactor "DoRelayout" and extract common code of size calculation without modifying attributes of mVisualModel,
+  //TODO: then calculate GlyphPositions. Lines, Size, Layout for Natural-Size
+  //TODO: and utilize the values in OperationsPending and TextUpdateInfo without changing the original one.
+  //TODO: Also it will improve performance because there is no need todo FullRelyout on the next need for layouting.
+
+  // FullRelayoutNeeded should be true because DoRelayout is MAX_FLOAT, MAX_FLOAT.
+  // By this no need to take backup and restore it.
+  textUpdateInfo.mFullRelayoutNeeded = true;
+
+  // Restore mCharacterIndex. Because "Clear" set it to the maximum integer.
+  // The "CalculateTextUpdateIndices" does not work proprely because the mCharacterIndex will be greater than mPreviousNumberOfCharacters.
+  // Which apply an assumption to update only the last  paragraph. That could cause many of out of index crashes.
+  textUpdateInfo.mCharacterIndex = updateInfoCharIndexBackup;
+
+  // Do not do again the only once operations.
+  operationsPending = static_cast<OperationsMask>(operationsPending & ~onlyOnceOperations);
+
+  // Do the size related operations again.
+
+  const OperationsMask sizeOperations = static_cast<OperationsMask>(LAYOUT |
+                                                                    ALIGN |
+                                                                    REORDER);
+
+  operationsPending = static_cast<OperationsMask>(operationsPending | sizeOperations);
 
   // Restore the actual control's size.
   visualModel->mControlSize = actualControlSize;
-  // Restore the previously backed-up pending operations' mask without the only once operations.
-  impl.mOperationsPending = static_cast<OperationsMask>(operationsPendingBackUp & ~onlyOnceOperations);
-
-  // Restore the previously backed-up mLines and mGlyphPositions from visualModel.
-  if(restoreLinesAndGlyphPositions)
-  {
-    visualModel->mLines          = linesBackup;
-    visualModel->mGlyphPositions = glyphPositionsBackup;
-  }
 
   return calculatedLayoutSize;
 }
@@ -146,7 +155,7 @@ Vector3 Controller::Relayouter::GetNaturalSize(Controller& controller)
     OperationsMask requestedOperationsMask  = static_cast<OperationsMask>(LAYOUT | REORDER);
     Size           sizeMaxWidthAndMaxHeight = Size(MAX_FLOAT, MAX_FLOAT);
 
-    naturalSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeMaxWidthAndMaxHeight, requestedOperationsMask, true);
+    naturalSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeMaxWidthAndMaxHeight, requestedOperationsMask);
 
     // Stores the natural size to avoid recalculate it again
     // unless the text/style changes.
@@ -295,15 +304,7 @@ float Controller::Relayouter::GetHeightForWidth(Controller& controller, float wi
     OperationsMask requestedOperationsMask        = static_cast<OperationsMask>(LAYOUT);
     Size           sizeRequestedWidthAndMaxHeight = Size(width, MAX_FLOAT);
 
-    // Skip restore, because if GetHeightForWidth called before rendering and layouting then visualModel->mControlSize will be zero which will make LineCount zero.
-    // The implementation of Get LineCount property depends on calling GetHeightForWidth then read mLines.Count() from visualModel direct.
-    // If the LineCount property is requested before rendering and layouting then the value will be zero, which is incorrect.
-    // So we will not restore the previously backed-up mLines and mGlyphPositions from visualModel in such case.
-    // Another case to skip restore is when the requested width equals the Control's width which means the caller need to update the old values.
-    // For example, when the text is changed.
-    bool restoreLinesAndGlyphPositions = (visualModel->mControlSize.width > 0 && visualModel->mControlSize.height > 0) && (visualModel->mControlSize.width != width);
-
-    layoutSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeRequestedWidthAndMaxHeight, requestedOperationsMask, restoreLinesAndGlyphPositions);
+    layoutSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeRequestedWidthAndMaxHeight, requestedOperationsMask);
 
     DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height);
   }
index decca97..b605545 100644 (file)
@@ -110,12 +110,10 @@ struct Controller::Relayouter
   * @param[in] controller The controller to calcualte size on it.
   * @param[in] requestedControllerSize The requested size of controller to calcualte layout size on it.
   * @param[in] requestedOperationsMask The requested operations-mask to calcualte layout size according to it.
-  * @param[in] restoreLinesAndGlyphPositions whether to restore lines and glyph-positions to status before requesting calculation on size.
   *
   * @return The calculated layout-size.
   */
-  static Size CalculateLayoutSizeOnRequiredControllerSize(Controller& controller, const Size& requestedControllerSize, const OperationsMask& requestedOperationsMask, bool restoreLinesAndGlyphPositions);
-
+  static Size CalculateLayoutSizeOnRequiredControllerSize(Controller& controller, const Size& requestedControllerSize, const OperationsMask& requestedOperationsMask);
 };
 
 } // namespace Text
index 757d54a..19f2131 100644 (file)
@@ -116,7 +116,6 @@ void UpdateCursorPosition(Dali::Toolkit::Text::EventData* eventData)
 
 namespace Dali::Toolkit::Text
 {
-
 void Controller::EnableTextInput(DecoratorPtr decorator, InputMethodContext& inputMethodContext)
 {
   if(!decorator)