| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/ng/ng_layout_inline_items_builder.h" | 5 #include "core/layout/ng/ng_layout_inline_items_builder.h" |
| 6 #include "core/layout/LayoutInline.h" | 6 #include "core/layout/LayoutInline.h" |
| 7 #include "core/layout/ng/ng_inline_node.h" | 7 #include "core/layout/ng/ng_inline_node.h" |
| 8 #include "core/style/ComputedStyle.h" | 8 #include "core/style/ComputedStyle.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 builder.ExitBlock(); | 180 builder.ExitBlock(); |
| 181 | 181 |
| 182 EXPECT_EQ("", builder.ToString()); | 182 EXPECT_EQ("", builder.ToString()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 TEST_F(NGLayoutInlineItemsBuilderTest, BidiBlockOverride) { | 185 TEST_F(NGLayoutInlineItemsBuilderTest, BidiBlockOverride) { |
| 186 Vector<NGLayoutInlineItem> items; | 186 Vector<NGLayoutInlineItem> items; |
| 187 NGLayoutInlineItemsBuilder builder(&items); | 187 NGLayoutInlineItemsBuilder builder(&items); |
| 188 RefPtr<ComputedStyle> block_style(ComputedStyle::create()); | 188 RefPtr<ComputedStyle> block_style(ComputedStyle::create()); |
| 189 block_style->setUnicodeBidi(Override); | 189 block_style->setUnicodeBidi(Override); |
| 190 block_style->setDirection(RTL); | 190 block_style->setDirection(TextDirection::Rtl); |
| 191 builder.EnterBlock(block_style.get()); | 191 builder.EnterBlock(block_style.get()); |
| 192 builder.Append("Hello", style_.get()); | 192 builder.Append("Hello", style_.get()); |
| 193 builder.ExitBlock(); | 193 builder.ExitBlock(); |
| 194 | 194 |
| 195 // Expected control characters as defined in: | 195 // Expected control characters as defined in: |
| 196 // https://drafts.csswg.org/css-writing-modes-3/#bidi-control-codes-injection-
table | 196 // https://drafts.csswg.org/css-writing-modes-3/#bidi-control-codes-injection-
table |
| 197 EXPECT_EQ(String(u"\u202E" | 197 EXPECT_EQ(String(u"\u202E" |
| 198 u"Hello" | 198 u"Hello" |
| 199 u"\u202C"), | 199 u"\u202C"), |
| 200 builder.ToString()); | 200 builder.ToString()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 static std::unique_ptr<LayoutInline> createLayoutInline( | 203 static std::unique_ptr<LayoutInline> createLayoutInline( |
| 204 void (*initialize_style)(ComputedStyle*)) { | 204 void (*initialize_style)(ComputedStyle*)) { |
| 205 RefPtr<ComputedStyle> style(ComputedStyle::create()); | 205 RefPtr<ComputedStyle> style(ComputedStyle::create()); |
| 206 initialize_style(style.get()); | 206 initialize_style(style.get()); |
| 207 std::unique_ptr<LayoutInline> node = WTF::makeUnique<LayoutInline>(nullptr); | 207 std::unique_ptr<LayoutInline> node = WTF::makeUnique<LayoutInline>(nullptr); |
| 208 node->setStyleInternal(std::move(style)); | 208 node->setStyleInternal(std::move(style)); |
| 209 return node; | 209 return node; |
| 210 } | 210 } |
| 211 | 211 |
| 212 TEST_F(NGLayoutInlineItemsBuilderTest, BidiIsolate) { | 212 TEST_F(NGLayoutInlineItemsBuilderTest, BidiIsolate) { |
| 213 Vector<NGLayoutInlineItem> items; | 213 Vector<NGLayoutInlineItem> items; |
| 214 NGLayoutInlineItemsBuilder builder(&items); | 214 NGLayoutInlineItemsBuilder builder(&items); |
| 215 builder.Append("Hello ", style_.get()); | 215 builder.Append("Hello ", style_.get()); |
| 216 std::unique_ptr<LayoutInline> isolateRTL( | 216 std::unique_ptr<LayoutInline> isolateRTL( |
| 217 createLayoutInline([](ComputedStyle* style) { | 217 createLayoutInline([](ComputedStyle* style) { |
| 218 style->setUnicodeBidi(Isolate); | 218 style->setUnicodeBidi(Isolate); |
| 219 style->setDirection(RTL); | 219 style->setDirection(TextDirection::Rtl); |
| 220 })); | 220 })); |
| 221 builder.EnterInline(isolateRTL.get()); | 221 builder.EnterInline(isolateRTL.get()); |
| 222 builder.Append(u"\u05E2\u05D1\u05E8\u05D9\u05EA", style_.get()); | 222 builder.Append(u"\u05E2\u05D1\u05E8\u05D9\u05EA", style_.get()); |
| 223 builder.ExitInline(isolateRTL.get()); | 223 builder.ExitInline(isolateRTL.get()); |
| 224 builder.Append(" World", style_.get()); | 224 builder.Append(" World", style_.get()); |
| 225 | 225 |
| 226 // Expected control characters as defined in: | 226 // Expected control characters as defined in: |
| 227 // https://drafts.csswg.org/css-writing-modes-3/#bidi-control-codes-injection-
table | 227 // https://drafts.csswg.org/css-writing-modes-3/#bidi-control-codes-injection-
table |
| 228 EXPECT_EQ(String(u"Hello " | 228 EXPECT_EQ(String(u"Hello " |
| 229 u"\u2067" | 229 u"\u2067" |
| 230 u"\u05E2\u05D1\u05E8\u05D9\u05EA" | 230 u"\u05E2\u05D1\u05E8\u05D9\u05EA" |
| 231 u"\u2069" | 231 u"\u2069" |
| 232 u" World"), | 232 u" World"), |
| 233 builder.ToString()); | 233 builder.ToString()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 TEST_F(NGLayoutInlineItemsBuilderTest, BidiIsolateOverride) { | 236 TEST_F(NGLayoutInlineItemsBuilderTest, BidiIsolateOverride) { |
| 237 Vector<NGLayoutInlineItem> items; | 237 Vector<NGLayoutInlineItem> items; |
| 238 NGLayoutInlineItemsBuilder builder(&items); | 238 NGLayoutInlineItemsBuilder builder(&items); |
| 239 builder.Append("Hello ", style_.get()); | 239 builder.Append("Hello ", style_.get()); |
| 240 std::unique_ptr<LayoutInline> isolateOverrideRTL( | 240 std::unique_ptr<LayoutInline> isolateOverrideRTL( |
| 241 createLayoutInline([](ComputedStyle* style) { | 241 createLayoutInline([](ComputedStyle* style) { |
| 242 style->setUnicodeBidi(IsolateOverride); | 242 style->setUnicodeBidi(IsolateOverride); |
| 243 style->setDirection(RTL); | 243 style->setDirection(TextDirection::Rtl); |
| 244 })); | 244 })); |
| 245 builder.EnterInline(isolateOverrideRTL.get()); | 245 builder.EnterInline(isolateOverrideRTL.get()); |
| 246 builder.Append(u"\u05E2\u05D1\u05E8\u05D9\u05EA", style_.get()); | 246 builder.Append(u"\u05E2\u05D1\u05E8\u05D9\u05EA", style_.get()); |
| 247 builder.ExitInline(isolateOverrideRTL.get()); | 247 builder.ExitInline(isolateOverrideRTL.get()); |
| 248 builder.Append(" World", style_.get()); | 248 builder.Append(" World", style_.get()); |
| 249 | 249 |
| 250 // Expected control characters as defined in: | 250 // Expected control characters as defined in: |
| 251 // https://drafts.csswg.org/css-writing-modes-3/#bidi-control-codes-injection-
table | 251 // https://drafts.csswg.org/css-writing-modes-3/#bidi-control-codes-injection-
table |
| 252 EXPECT_EQ(String(u"Hello " | 252 EXPECT_EQ(String(u"Hello " |
| 253 u"\u2068\u202E" | 253 u"\u2068\u202E" |
| 254 u"\u05E2\u05D1\u05E8\u05D9\u05EA" | 254 u"\u05E2\u05D1\u05E8\u05D9\u05EA" |
| 255 u"\u202C\u2069" | 255 u"\u202C\u2069" |
| 256 u" World"), | 256 u" World"), |
| 257 builder.ToString()); | 257 builder.ToString()); |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace | 260 } // namespace |
| 261 | 261 |
| 262 } // namespace blink | 262 } // namespace blink |
| OLD | NEW |