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

Side by Side Diff: sky/engine/core/rendering/RenderFlexibleBox.cpp

Issue 689743002: First past at removing writing mode. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 bool RenderFlexibleBox::isHorizontalFlow() const 321 bool RenderFlexibleBox::isHorizontalFlow() const
322 { 322 {
323 if (isHorizontalWritingMode()) 323 if (isHorizontalWritingMode())
324 return !isColumnFlow(); 324 return !isColumnFlow();
325 return isColumnFlow(); 325 return isColumnFlow();
326 } 326 }
327 327
328 bool RenderFlexibleBox::isLeftToRightFlow() const 328 bool RenderFlexibleBox::isLeftToRightFlow() const
329 { 329 {
330 if (isColumnFlow()) 330 if (isColumnFlow())
331 return style()->writingMode() == TopToBottomWritingMode || style()->writ ingMode() == LeftToRightWritingMode; 331 return true;
332 return style()->isLeftToRightDirection() ^ (style()->flexDirection() == Flow RowReverse); 332 return style()->isLeftToRightDirection() ^ (style()->flexDirection() == Flow RowReverse);
333 } 333 }
334 334
335 bool RenderFlexibleBox::isMultiline() const 335 bool RenderFlexibleBox::isMultiline() const
336 { 336 {
337 return style()->flexWrap() != FlexNoWrap; 337 return style()->flexWrap() != FlexNoWrap;
338 } 338 }
339 339
340 Length RenderFlexibleBox::flexBasisForChild(RenderBox* child) const 340 Length RenderFlexibleBox::flexBasisForChild(RenderBox* child) const
341 { 341 {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 // We don't have to check for "auto" here - computeContentLogicalHeight will just return -1 for that case anyway. 417 // We don't have to check for "auto" here - computeContentLogicalHeight will just return -1 for that case anyway.
418 if (size.isIntrinsic()) 418 if (size.isIntrinsic())
419 child->layoutIfNeeded(); 419 child->layoutIfNeeded();
420 return child->computeContentLogicalHeight(size, child->logicalHeight() - child->borderAndPaddingLogicalHeight()) + child->scrollbarLogicalHeight(); 420 return child->computeContentLogicalHeight(size, child->logicalHeight() - child->borderAndPaddingLogicalHeight()) + child->scrollbarLogicalHeight();
421 } 421 }
422 return child->computeLogicalWidthUsing(sizeType, size, contentLogicalWidth() , this) - child->borderAndPaddingLogicalWidth(); 422 return child->computeLogicalWidthUsing(sizeType, size, contentLogicalWidth() , this) - child->borderAndPaddingLogicalWidth();
423 } 423 }
424 424
425 WritingMode RenderFlexibleBox::transformedWritingMode() const 425 WritingMode RenderFlexibleBox::transformedWritingMode() const
426 { 426 {
427 WritingMode mode = style()->writingMode(); 427 // FIXME(sky): Remove
428 if (!isColumnFlow())
429 return mode;
430
431 switch (mode) {
432 case TopToBottomWritingMode:
433 case BottomToTopWritingMode:
434 return style()->isLeftToRightDirection() ? LeftToRightWritingMode : Righ tToLeftWritingMode;
435 case LeftToRightWritingMode:
436 case RightToLeftWritingMode:
437 return style()->isLeftToRightDirection() ? TopToBottomWritingMode : Bott omToTopWritingMode;
438 }
439 ASSERT_NOT_REACHED();
440 return TopToBottomWritingMode; 428 return TopToBottomWritingMode;
441 } 429 }
442 430
443 LayoutUnit RenderFlexibleBox::flowAwareBorderStart() const 431 LayoutUnit RenderFlexibleBox::flowAwareBorderStart() const
444 { 432 {
445 if (isHorizontalFlow()) 433 if (isHorizontalFlow())
446 return isLeftToRightFlow() ? borderLeft() : borderRight(); 434 return isLeftToRightFlow() ? borderLeft() : borderRight();
447 return isLeftToRightFlow() ? borderTop() : borderBottom(); 435 return isLeftToRightFlow() ? borderTop() : borderBottom();
448 } 436 }
449 437
450 LayoutUnit RenderFlexibleBox::flowAwareBorderEnd() const 438 LayoutUnit RenderFlexibleBox::flowAwareBorderEnd() const
451 { 439 {
452 if (isHorizontalFlow()) 440 if (isHorizontalFlow())
453 return isLeftToRightFlow() ? borderRight() : borderLeft(); 441 return isLeftToRightFlow() ? borderRight() : borderLeft();
454 return isLeftToRightFlow() ? borderBottom() : borderTop(); 442 return isLeftToRightFlow() ? borderBottom() : borderTop();
455 } 443 }
456 444
457 LayoutUnit RenderFlexibleBox::flowAwareBorderBefore() const 445 LayoutUnit RenderFlexibleBox::flowAwareBorderBefore() const
458 { 446 {
459 switch (transformedWritingMode()) { 447 // FIXME(sky): Remove
460 case TopToBottomWritingMode:
461 return borderTop();
462 case BottomToTopWritingMode:
463 return borderBottom();
464 case LeftToRightWritingMode:
465 return borderLeft();
466 case RightToLeftWritingMode:
467 return borderRight();
468 }
469 ASSERT_NOT_REACHED();
470 return borderTop(); 448 return borderTop();
471 } 449 }
472 450
473 LayoutUnit RenderFlexibleBox::flowAwareBorderAfter() const 451 LayoutUnit RenderFlexibleBox::flowAwareBorderAfter() const
474 { 452 {
475 switch (transformedWritingMode()) { 453 // FIXME(sky): Remove
476 case TopToBottomWritingMode:
477 return borderBottom();
478 case BottomToTopWritingMode:
479 return borderTop();
480 case LeftToRightWritingMode:
481 return borderRight();
482 case RightToLeftWritingMode:
483 return borderLeft();
484 }
485 ASSERT_NOT_REACHED();
486 return borderTop(); 454 return borderTop();
487 } 455 }
488 456
489 LayoutUnit RenderFlexibleBox::flowAwarePaddingStart() const 457 LayoutUnit RenderFlexibleBox::flowAwarePaddingStart() const
490 { 458 {
491 if (isHorizontalFlow()) 459 if (isHorizontalFlow())
492 return isLeftToRightFlow() ? paddingLeft() : paddingRight(); 460 return isLeftToRightFlow() ? paddingLeft() : paddingRight();
493 return isLeftToRightFlow() ? paddingTop() : paddingBottom(); 461 return isLeftToRightFlow() ? paddingTop() : paddingBottom();
494 } 462 }
495 463
496 LayoutUnit RenderFlexibleBox::flowAwarePaddingEnd() const 464 LayoutUnit RenderFlexibleBox::flowAwarePaddingEnd() const
497 { 465 {
498 if (isHorizontalFlow()) 466 if (isHorizontalFlow())
499 return isLeftToRightFlow() ? paddingRight() : paddingLeft(); 467 return isLeftToRightFlow() ? paddingRight() : paddingLeft();
500 return isLeftToRightFlow() ? paddingBottom() : paddingTop(); 468 return isLeftToRightFlow() ? paddingBottom() : paddingTop();
501 } 469 }
502 470
503 LayoutUnit RenderFlexibleBox::flowAwarePaddingBefore() const 471 LayoutUnit RenderFlexibleBox::flowAwarePaddingBefore() const
504 { 472 {
505 switch (transformedWritingMode()) { 473 // FIXME(sky): Remove
506 case TopToBottomWritingMode:
507 return paddingTop();
508 case BottomToTopWritingMode:
509 return paddingBottom();
510 case LeftToRightWritingMode:
511 return paddingLeft();
512 case RightToLeftWritingMode:
513 return paddingRight();
514 }
515 ASSERT_NOT_REACHED();
516 return paddingTop(); 474 return paddingTop();
517 } 475 }
518 476
519 LayoutUnit RenderFlexibleBox::flowAwarePaddingAfter() const 477 LayoutUnit RenderFlexibleBox::flowAwarePaddingAfter() const
520 { 478 {
521 switch (transformedWritingMode()) { 479 // FIXME(sky): Remove
522 case TopToBottomWritingMode:
523 return paddingBottom();
524 case BottomToTopWritingMode:
525 return paddingTop();
526 case LeftToRightWritingMode:
527 return paddingRight();
528 case RightToLeftWritingMode:
529 return paddingLeft();
530 }
531 ASSERT_NOT_REACHED();
532 return paddingTop(); 480 return paddingTop();
533 } 481 }
534 482
535 LayoutUnit RenderFlexibleBox::flowAwareMarginStartForChild(RenderBox* child) con st 483 LayoutUnit RenderFlexibleBox::flowAwareMarginStartForChild(RenderBox* child) con st
536 { 484 {
537 if (isHorizontalFlow()) 485 if (isHorizontalFlow())
538 return isLeftToRightFlow() ? child->marginLeft() : child->marginRight(); 486 return isLeftToRightFlow() ? child->marginLeft() : child->marginRight();
539 return isLeftToRightFlow() ? child->marginTop() : child->marginBottom(); 487 return isLeftToRightFlow() ? child->marginTop() : child->marginBottom();
540 } 488 }
541 489
542 LayoutUnit RenderFlexibleBox::flowAwareMarginEndForChild(RenderBox* child) const 490 LayoutUnit RenderFlexibleBox::flowAwareMarginEndForChild(RenderBox* child) const
543 { 491 {
544 if (isHorizontalFlow()) 492 if (isHorizontalFlow())
545 return isLeftToRightFlow() ? child->marginRight() : child->marginLeft(); 493 return isLeftToRightFlow() ? child->marginRight() : child->marginLeft();
546 return isLeftToRightFlow() ? child->marginBottom() : child->marginTop(); 494 return isLeftToRightFlow() ? child->marginBottom() : child->marginTop();
547 } 495 }
548 496
549 LayoutUnit RenderFlexibleBox::flowAwareMarginBeforeForChild(RenderBox* child) co nst 497 LayoutUnit RenderFlexibleBox::flowAwareMarginBeforeForChild(RenderBox* child) co nst
550 { 498 {
551 switch (transformedWritingMode()) { 499 // FIXME(sky): Remove
552 case TopToBottomWritingMode:
553 return child->marginTop();
554 case BottomToTopWritingMode:
555 return child->marginBottom();
556 case LeftToRightWritingMode:
557 return child->marginLeft();
558 case RightToLeftWritingMode:
559 return child->marginRight();
560 }
561 ASSERT_NOT_REACHED();
562 return marginTop(); 500 return marginTop();
563 } 501 }
564 502
565 LayoutUnit RenderFlexibleBox::crossAxisMarginExtentForChild(RenderBox* child) co nst 503 LayoutUnit RenderFlexibleBox::crossAxisMarginExtentForChild(RenderBox* child) co nst
566 { 504 {
567 return isHorizontalFlow() ? child->marginHeight() : child->marginWidth(); 505 return isHorizontalFlow() ? child->marginHeight() : child->marginWidth();
568 } 506 }
569 507
570 LayoutUnit RenderFlexibleBox::crossAxisScrollbarExtent() const 508 LayoutUnit RenderFlexibleBox::crossAxisScrollbarExtent() const
571 { 509 {
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 ASSERT(child); 1335 ASSERT(child);
1398 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1336 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1399 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1337 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1400 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1338 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1401 adjustAlignmentForChild(child, newOffset - originalOffset); 1339 adjustAlignmentForChild(child, newOffset - originalOffset);
1402 } 1340 }
1403 } 1341 }
1404 } 1342 }
1405 1343
1406 } 1344 }
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBox.cpp ('k') | sky/engine/core/rendering/shapes/ShapeOutsideInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698