Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5380)

Unified Diff: Source/core/rendering/InlineIterator.h

Issue 119853004: Blink Unicode Bidi implementation does not support L1 rule. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/rendering/RenderBlockLineLayout.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/InlineIterator.h
diff --git a/Source/core/rendering/InlineIterator.h b/Source/core/rendering/InlineIterator.h
index 3e7a69e74605034ade5ee763c5ab86086f8bafd4..27ab95818ad420a201581553ab08366846862308 100644
--- a/Source/core/rendering/InlineIterator.h
+++ b/Source/core/rendering/InlineIterator.h
@@ -451,6 +451,67 @@ inline bool InlineBidiResolver::isEndOfLine(const InlineIterator& end)
return inEndOfLine;
}
+static inline bool isCollapsibleSpace(UChar character, RenderText* renderer)
+{
+ if (character == ' ' || character == '\t' || character == softHyphen)
+ return true;
+ if (character == '\n')
+ return !renderer->style()->preserveNewline();
+ return false;
+}
+
+template <typename CharacterType>
+static inline int findFirstTrailingSpace(RenderText* lastText, const CharacterType* characters, int start, int stop)
+{
+ int firstSpace = stop;
+ while (firstSpace > start) {
+ UChar current = characters[firstSpace - 1];
+ if (!isCollapsibleSpace(current, lastText))
+ break;
+ firstSpace--;
+ }
+
+ return firstSpace;
+}
+
+template <>
+inline int InlineBidiResolver::findFirstTrailingSpaceAtRun(BidiRun* run)
+{
+ ASSERT(run);
+ RenderObject* lastObject = run->m_object;
+ if (!lastObject->isText())
+ return run->m_stop;
+
+ RenderText* lastText = toRenderText(lastObject);
+ int firstSpace;
+ if (lastText->is8Bit())
+ firstSpace = findFirstTrailingSpace(lastText, lastText->characters8(), run->start(), run->stop());
+ else
+ firstSpace = findFirstTrailingSpace(lastText, lastText->characters16(), run->start(), run->stop());
+ return firstSpace;
+}
+
+template <>
+inline BidiRun* InlineBidiResolver::addTrailingRun(int start, int stop, BidiRun* run, BidiContext* context, TextDirection direction)
+{
+ BidiRun* newTrailingRun = new BidiRun(start, stop, run->m_object, context, WTF::Unicode::OtherNeutral);
+ if (direction == LTR)
+ m_runs.addRun(newTrailingRun);
+ else
+ m_runs.prependRun(newTrailingRun);
+
+ return newTrailingRun;
+}
+
+template <>
+inline bool InlineBidiResolver::needsToApplyL1Rule()
+{
+ if (!m_runs.logicallyLastRun()->m_object->style()->breakOnlyAfterWhiteSpace()
+ || !m_runs.logicallyLastRun()->m_object->style()->autoWrap())
+ return false;
+ return true;
+}
+
static inline bool isIsolatedInline(RenderObject* object)
{
ASSERT(object);
« no previous file with comments | « no previous file | Source/core/rendering/RenderBlockLineLayout.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698