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

Side by Side Diff: Source/core/rendering/RenderBlockLineLayout.cpp

Issue 23112019: If an element has unicode-bidi: plaintext and no strong directional characters. By default it shoul… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Proposed patch v3 Created 7 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved.
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 381
382 if (!next) 382 if (!next)
383 break; 383 break;
384 384
385 current = next; 385 current = next;
386 } 386 }
387 387
388 return current; 388 return current;
389 } 389 }
390 390
391 static void determinePlaintextDirectionality(TextDirection& dir, RenderObject* r oot, RenderObject* current = 0, unsigned pos = 0) 391 static TextDirection determinePlaintextDirectionality(RenderObject* root, Render Object* current = 0, unsigned pos = 0)
392 { 392 {
393 InlineIterator iter(root, firstRenderObjectForDirectionalityDetermination(ro ot, current), pos); 393 InlineIterator iter(root, firstRenderObjectForDirectionalityDetermination(ro ot, current), pos);
394 InlineBidiResolver observer; 394 InlineBidiResolver observer;
395 observer.setPositionIgnoringNestedIsolates(iter); 395 observer.setPositionIgnoringNestedIsolates(iter);
396 observer.setStatus(BidiStatus(root->style()->direction(), isOverride(root->s tyle()->unicodeBidi()))); 396 observer.setStatus(BidiStatus(root->style()->direction(), isOverride(root->s tyle()->unicodeBidi())));
397 while (!iter.atEnd()) { 397 while (!iter.atEnd()) {
398 if (observer.inIsolate()) { 398 if (observer.inIsolate()) {
399 iter.increment(&observer); 399 iter.increment(&observer);
400 continue; 400 continue;
401 } 401 }
402 if (iter.atParagraphSeparator()) 402 if (iter.atParagraphSeparator())
403 return; 403 break;
404 if (UChar current = iter.current()) { 404 if (UChar current = iter.current()) {
405 Direction charDirection = direction(current); 405 Direction charDirection = direction(current);
406 if (charDirection == LeftToRight) { 406 if (charDirection == LeftToRight)
407 dir = LTR; 407 return LTR;
408 return; 408 if (charDirection == RightToLeft || charDirection == RightToLeftArab ic)
409 } 409 return RTL;
410 if (charDirection == RightToLeft || charDirection == RightToLeftArab ic) {
411 dir = RTL;
412 return;
413 }
414 } 410 }
415 iter.increment(&observer); 411 iter.increment(&observer);
416 } 412 }
413 return LTR;
417 } 414 }
418 415
419 static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator& lBreak) 416 static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator& lBreak)
420 { 417 {
421 // Check to see if our last midpoint is a start point beyond the line break. If so, 418 // Check to see if our last midpoint is a start point beyond the line break. If so,
422 // shave it off the list, and shave off a trailing space if the previous end point doesn't 419 // shave it off the list, and shave off a trailing space if the previous end point doesn't
423 // preserve whitespace. 420 // preserve whitespace.
424 if (lBreak.m_obj && lineMidpointState.numMidpoints && !(lineMidpointState.nu mMidpoints % 2)) { 421 if (lBreak.m_obj && lineMidpointState.numMidpoints && !(lineMidpointState.nu mMidpoints % 2)) {
425 InlineIterator* midpoints = lineMidpointState.midpoints.data(); 422 InlineIterator* midpoints = lineMidpointState.midpoints.data();
426 InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2] ; 423 InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2] ;
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 // FIXME: Because enterIsolate is not passed a RenderObject, we have to crawl up the 1316 // FIXME: Because enterIsolate is not passed a RenderObject, we have to crawl up the
1320 // tree to see which parent inline is the isolate. We could change enter Isolate 1317 // tree to see which parent inline is the isolate. We could change enter Isolate
1321 // to take a RenderObject and do this logic there, but that would be a l ayering 1318 // to take a RenderObject and do this logic there, but that would be a l ayering
1322 // violation for BidiResolver (which knows nothing about RenderObject). 1319 // violation for BidiResolver (which knows nothing about RenderObject).
1323 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj , currentRoot)); 1320 RenderInline* isolatedInline = toRenderInline(containingIsolate(startObj , currentRoot));
1324 1321
1325 InlineBidiResolver isolatedResolver; 1322 InlineBidiResolver isolatedResolver;
1326 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi(); 1323 EUnicodeBidi unicodeBidi = isolatedInline->style()->unicodeBidi();
1327 TextDirection direction = isolatedInline->style()->direction(); 1324 TextDirection direction = isolatedInline->style()->direction();
1328 if (unicodeBidi == Plaintext) 1325 if (unicodeBidi == Plaintext)
1329 determinePlaintextDirectionality(direction, isolatedInline, startObj ); 1326 direction = determinePlaintextDirectionality(isolatedInline, startOb j);
1330 else { 1327 else {
1331 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride); 1328 ASSERT(unicodeBidi == Isolate || unicodeBidi == IsolateOverride);
1332 direction = isolatedInline->style()->direction(); 1329 direction = isolatedInline->style()->direction();
1333 } 1330 }
1334 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni codeBidi))); 1331 isolatedResolver.setStatus(statusWithDirection(direction, isOverride(uni codeBidi)));
1335 1332
1336 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb j); 1333 setupResolverToResumeInIsolate(isolatedResolver, isolatedInline, startOb j);
1337 1334
1338 // The starting position is the beginning of the first run within the is olate that was identified 1335 // The starting position is the beginning of the first run within the is olate that was identified
1339 // during the earlier call to createBidiRunsForLine. This can be but is not necessarily the 1336 // during the earlier call to createBidiRunsForLine. This can be but is not necessarily the
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 ASSERT(end != resolver.position()); 1842 ASSERT(end != resolver.position());
1846 1843
1847 // This is a short-cut for empty lines. 1844 // This is a short-cut for empty lines.
1848 if (layoutState.lineInfo().isEmpty()) { 1845 if (layoutState.lineInfo().isEmpty()) {
1849 if (lastRootBox()) 1846 if (lastRootBox())
1850 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s tatus()); 1847 lastRootBox()->setLineBreakInfo(end.m_obj, end.m_pos, resolver.s tatus());
1851 } else { 1848 } else {
1852 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride); 1849 VisualDirectionOverride override = (styleToUse->rtlOrdering() == Vis ualOrder ? (styleToUse->direction() == LTR ? VisualLeftToRightOverride : VisualR ightToLeftOverride) : NoVisualOverride);
1853 1850
1854 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && ! resolver.context()->parent()) { 1851 if (isNewUBAParagraph && styleToUse->unicodeBidi() == Plaintext && ! resolver.context()->parent()) {
1855 TextDirection direction = styleToUse->direction(); 1852 TextDirection direction = determinePlaintextDirectionality(resol ver.position().root(), resolver.position().object(), resolver.position().offset( ));
1856 determinePlaintextDirectionality(direction, resolver.position(). root(), resolver.position().object(), resolver.position().offset());
1857 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse-> unicodeBidi()))); 1853 resolver.setStatus(BidiStatus(direction, isOverride(styleToUse-> unicodeBidi())));
1858 } 1854 }
1859 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine. 1855 // FIXME: This ownership is reversed. We should own the BidiRunList and pass it to createBidiRunsForLine.
1860 BidiRunList<BidiRun>& bidiRuns = resolver.runs(); 1856 BidiRunList<BidiRun>& bidiRuns = resolver.runs();
1861 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la youtState.lineInfo().previousLineBrokeCleanly()); 1857 constructBidiRunsForLine(this, resolver, bidiRuns, end, override, la youtState.lineInfo().previousLineBrokeCleanly());
1862 ASSERT(resolver.position() == end); 1858 ASSERT(resolver.position() == end);
1863 1859
1864 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0; 1860 BidiRun* trailingSpaceRun = !layoutState.lineInfo().previousLineBrok eCleanly() ? handleTrailingSpaces(bidiRuns, resolver.context()) : 0;
1865 1861
1866 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) { 1862 if (bidiRuns.runCount() && lineBreaker.lineWasHyphenated()) {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr eak()); 2329 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr eak());
2334 2330
2335 if (last) { 2331 if (last) {
2336 setLogicalHeight(last->lineBottomWithLeading()); 2332 setLogicalHeight(last->lineBottomWithLeading());
2337 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l ineBreakPos()); 2333 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l ineBreakPos());
2338 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); 2334 resolver.setPosition(iter, numberOfIsolateAncestors(iter));
2339 resolver.setStatus(last->lineBreakBidiStatus()); 2335 resolver.setStatus(last->lineBreakBidiStatus());
2340 } else { 2336 } else {
2341 TextDirection direction = style()->direction(); 2337 TextDirection direction = style()->direction();
2342 if (style()->unicodeBidi() == Plaintext) 2338 if (style()->unicodeBidi() == Plaintext)
2343 determinePlaintextDirectionality(direction, this); 2339 direction = determinePlaintextDirectionality(this);
2344 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); 2340 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ())));
2345 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, &resolver), 0); 2341 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, &resolver), 0);
2346 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); 2342 resolver.setPosition(iter, numberOfIsolateAncestors(iter));
2347 } 2343 }
2348 return curr; 2344 return curr;
2349 } 2345 }
2350 2346
2351 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus) 2347 void RenderBlock::determineEndPosition(LineLayoutState& layoutState, RootInlineB ox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus)
2352 { 2348 {
2353 ASSERT(!layoutState.endLine()); 2349 ASSERT(!layoutState.endLine());
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3529 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); 3525 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache);
3530 3526
3531 setLineGridBox(lineGridBox); 3527 setLineGridBox(lineGridBox);
3532 3528
3533 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying 3529 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying
3534 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping 3530 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
3535 // to this grid. 3531 // to this grid.
3536 } 3532 }
3537 3533
3538 } 3534 }
OLDNEW
« Source/core/html/HTMLElement.cpp ('K') | « Source/core/html/HTMLElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698