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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 1407633003: [css-grid] Implementation of Baseline Self-Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied suggested changes. Created 4 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 2471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 int count = 0; 2482 int count = 0;
2483 for (const RootInlineBox* box = firstRootBox(); box; 2483 for (const RootInlineBox* box = firstRootBox(); box;
2484 box = box->nextRootBox()) { 2484 box = box->nextRootBox()) {
2485 count++; 2485 count++;
2486 if (box == stopRootInlineBox) 2486 if (box == stopRootInlineBox)
2487 break; 2487 break;
2488 } 2488 }
2489 return count; 2489 return count;
2490 } 2490 }
2491 2491
2492 bool LayoutBlockFlow::isDescentBaseline() const {
2493 if (isOrthogonalWritingModeRoot())
2494 return !styleRef().isHorizontalWritingMode();
kojii 2016/11/16 17:18:06 Just curious, since I don't understand, why do we
jfernandez 2016/11/16 18:50:07 In the general case, we don't compute baselines fo
kojii 2016/11/18 04:14:53 Oh I think I understand this. I think the missing
2495 return parent() ? parent()->styleRef().isFlippedLinesWritingMode()
2496 : styleRef().isFlippedLinesWritingMode();
2497 }
2498
2492 int LayoutBlockFlow::firstLineBoxBaseline() const { 2499 int LayoutBlockFlow::firstLineBoxBaseline() const {
2493 if (isWritingModeRoot() && !isRubyRun()) 2500 if (isWritingModeRoot() && !isRubyRun() && !isGridItem())
2494 return -1; 2501 return -1;
2495 if (!childrenInline()) 2502 if (!childrenInline())
2496 return LayoutBlock::firstLineBoxBaseline(); 2503 return LayoutBlock::firstLineBoxBaseline();
2497 if (firstLineBox()) { 2504 if (firstLineBox()) {
2498 const SimpleFontData* fontData = style(true)->font().primaryFont(); 2505 const SimpleFontData* fontData = style(true)->font().primaryFont();
2499 DCHECK(fontData); 2506 DCHECK(fontData);
2500 if (!fontData) 2507 if (!fontData)
2501 return -1; 2508 return -1;
2502 return (firstLineBox()->logicalTop() + 2509 return (firstLineBox()->logicalTop() +
2503 fontData->getFontMetrics().ascent(firstRootBox()->baselineType())) 2510 (!isDescentBaseline()
2511 ? fontData->getFontMetrics().ascent(
2512 firstRootBox()->baselineType())
2513 : fontData->getFontMetrics().descent(
2514 firstRootBox()->baselineType())))
2504 .toInt(); 2515 .toInt();
2505 } 2516 }
2506 return -1; 2517 return -1;
2507 } 2518 }
2508 2519
2509 int LayoutBlockFlow::inlineBlockBaseline( 2520 int LayoutBlockFlow::inlineBlockBaseline(
2510 LineDirectionMode lineDirection) const { 2521 LineDirectionMode lineDirection) const {
2511 // CSS2.1 states that the baseline of an 'inline-block' is: 2522 // CSS2.1 states that the baseline of an 'inline-block' is:
2512 // the baseline of the last line box in the normal flow, unless it has 2523 // the baseline of the last line box in the normal flow, unless it has
2513 // either no in-flow line boxes or if its 'overflow' property has a computed 2524 // either no in-flow line boxes or if its 'overflow' property has a computed
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
4544 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); 4555 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState);
4545 } 4556 }
4546 4557
4547 void LayoutBlockFlow::invalidateDisplayItemClients( 4558 void LayoutBlockFlow::invalidateDisplayItemClients(
4548 PaintInvalidationReason invalidationReason) const { 4559 PaintInvalidationReason invalidationReason) const {
4549 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( 4560 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients(
4550 invalidationReason); 4561 invalidationReason);
4551 } 4562 }
4552 4563
4553 } // namespace blink 4564 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698