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

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

Issue 688223002: Get rid of isWritingModeRoot. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: merge to ToT 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
« no previous file with comments | « no previous file | sky/engine/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 RenderBox* positionedObject; 1076 RenderBox* positionedObject;
1077 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); 1077 TrackedRendererListHashSet::iterator end = positionedDescendants->end();
1078 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) { 1078 for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin( ); it != end; ++it) {
1079 positionedObject = *it; 1079 positionedObject = *it;
1080 addOverflowFromChild(positionedObject, LayoutSize(positionedObject->x(), positionedObject->y())); 1080 addOverflowFromChild(positionedObject, LayoutSize(positionedObject->x(), positionedObject->y()));
1081 } 1081 }
1082 } 1082 }
1083 1083
1084 bool RenderBlock::createsBlockFormattingContext() const 1084 bool RenderBlock::createsBlockFormattingContext() const
1085 { 1085 {
1086 return isInlineBlock() || isFloatingOrOutOfFlowPositioned() || hasOverflowCl ip() || isFlexItemIncludingDeprecated() 1086 return isInlineBlock() || isFloatingOrOutOfFlowPositioned() || hasOverflowCl ip() || isFlexItemIncludingDeprecated() || isDocumentElement();
1087 || isWritingModeRoot() || isDocumentElement();
1088 } 1087 }
1089 1088
1090 void RenderBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, R enderBox* child) 1089 void RenderBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, R enderBox* child)
1091 { 1090 {
1092 // FIXME: Technically percentage height objects only need a relayout if thei r percentage isn't going to be turned into 1091 // FIXME: Technically percentage height objects only need a relayout if thei r percentage isn't going to be turned into
1093 // an auto value. Add a method to determine this, so that we can avoid the r elayout. 1092 // an auto value. Add a method to determine this, so that we can avoid the r elayout.
1094 if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView( ))) 1093 if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView( )))
1095 child->setChildNeedsLayout(MarkOnlyThis); 1094 child->setChildNeedsLayout(MarkOnlyThis);
1096 1095
1097 // If relayoutChildren is set and the child has percentage padding or an emb edded content box, we also need to invalidate the childs pref widths. 1096 // If relayoutChildren is set and the child has percentage padding or an emb edded content box, we also need to invalidate the childs pref widths.
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 return selectionState() != SelectionNone && isSelectionRoot(); 1534 return selectionState() != SelectionNone && isSelectionRoot();
1536 } 1535 }
1537 1536
1538 bool RenderBlock::isSelectionRoot() const 1537 bool RenderBlock::isSelectionRoot() const
1539 { 1538 {
1540 ASSERT(node() || isAnonymous()); 1539 ASSERT(node() || isAnonymous());
1541 1540
1542 if (isDocumentElement() || hasOverflowClip() 1541 if (isDocumentElement() || hasOverflowClip()
1543 || isPositioned() || isFloating() 1542 || isPositioned() || isFloating()
1544 || isInlineBlock() 1543 || isInlineBlock()
1545 || hasTransform() || hasMask() || isWritingModeRoot() 1544 || hasTransform() || hasMask()
1546 || isFlexItemIncludingDeprecated()) 1545 || isFlexItemIncludingDeprecated())
1547 return true; 1546 return true;
1548 1547
1549 if (view() && view()->selectionStart()) { 1548 if (view() && view()->selectionStart()) {
1550 Node* startElement = view()->selectionStart()->node(); 1549 Node* startElement = view()->selectionStart()->node();
1551 if (startElement && startElement->rootEditableElement() == node()) 1550 if (startElement && startElement->rootEditableElement() == node())
1552 return true; 1551 return true;
1553 } 1552 }
1554 1553
1555 return false; 1554 return false;
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 // the base class. If we're being queried as though we're the root line 2563 // the base class. If we're being queried as though we're the root line
2565 // box, then the fact that we're an inline-block is irrelevant, and we behav e 2564 // box, then the fact that we're an inline-block is irrelevant, and we behav e
2566 // just like a block. 2565 // just like a block.
2567 if (isInline() && linePositionMode == PositionOnContainingLine) { 2566 if (isInline() && linePositionMode == PositionOnContainingLine) {
2568 // CSS2.1 states that the baseline of an inline block is the baseline of the last line box in 2567 // CSS2.1 states that the baseline of an inline block is the baseline of the last line box in
2569 // the normal flow. We make an exception for marquees, since their base lines are meaningless 2568 // the normal flow. We make an exception for marquees, since their base lines are meaningless
2570 // (the content inside them moves). This matches WinIE as well, which j ust bottom-aligns them. 2569 // (the content inside them moves). This matches WinIE as well, which j ust bottom-aligns them.
2571 // We also give up on finding a baseline if we have a vertical scrollbar , or if we are scrolled 2570 // We also give up on finding a baseline if we have a vertical scrollbar , or if we are scrolled
2572 // vertically (e.g., an overflow:hidden block that has had scrollTop mov ed). 2571 // vertically (e.g., an overflow:hidden block that has had scrollTop mov ed).
2573 bool ignoreBaseline = (layer() && layer()->scrollableArea() && ((directi on == HorizontalLine ? (layer()->scrollableArea()->verticalScrollbar() || layer( )->scrollableArea()->scrollYOffset()) 2572 bool ignoreBaseline = (layer() && layer()->scrollableArea() && ((directi on == HorizontalLine ? (layer()->scrollableArea()->verticalScrollbar() || layer( )->scrollableArea()->scrollYOffset())
2574 : (layer()->scrollableArea()->horizontalScrollbar() || layer()->scro llableArea()->scrollXOffset())))) || isWritingModeRoot(); 2573 : (layer()->scrollableArea()->horizontalScrollbar() || layer()->scro llableArea()->scrollXOffset()))));
2575 2574
2576 int baselinePos = ignoreBaseline ? -1 : inlineBlockBaseline(direction); 2575 int baselinePos = ignoreBaseline ? -1 : inlineBlockBaseline(direction);
2577 2576
2578 if (baselinePos != -1) 2577 if (baselinePos != -1)
2579 return beforeMarginInLineDirection(direction) + baselinePos; 2578 return beforeMarginInLineDirection(direction) + baselinePos;
2580 2579
2581 return RenderBox::baselinePosition(baselineType, firstLine, direction, l inePositionMode); 2580 return RenderBox::baselinePosition(baselineType, firstLine, direction, l inePositionMode);
2582 } 2581 }
2583 2582
2584 // If we're not replaced, we'll only get called with PositionOfInteriorLineB oxes. 2583 // If we're not replaced, we'll only get called with PositionOfInteriorLineB oxes.
2585 // Note that inline-block counts as replaced here. 2584 // Note that inline-block counts as replaced here.
2586 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); 2585 ASSERT(linePositionMode == PositionOfInteriorLineBoxes);
2587 2586
2588 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); 2587 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics();
2589 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2; 2588 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2;
2590 } 2589 }
2591 2590
2592 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, Layou tUnit replacedHeight) const 2591 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, Layou tUnit replacedHeight) const
2593 { 2592 {
2594 if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock)) 2593 if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock))
2595 return 0; 2594 return 0;
2596 2595
2597 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, Horizont alLine, PositionOfInteriorLineBoxes)); 2596 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, Horizont alLine, PositionOfInteriorLineBoxes));
2598 } 2597 }
2599 2598
2600 int RenderBlock::firstLineBoxBaseline() const 2599 int RenderBlock::firstLineBoxBaseline() const
2601 { 2600 {
2602 if (isWritingModeRoot())
2603 return -1;
2604
2605 if (childrenInline()) { 2601 if (childrenInline()) {
2606 if (firstLineBox()) 2602 if (firstLineBox())
2607 return firstLineBox()->logicalTop() + style(true)->fontMetrics().asc ent(firstRootBox()->baselineType()); 2603 return firstLineBox()->logicalTop() + style(true)->fontMetrics().asc ent(firstRootBox()->baselineType());
2608 else 2604 else
2609 return -1; 2605 return -1;
2610 } 2606 }
2611 else { 2607 else {
2612 for (RenderBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBo x()) { 2608 for (RenderBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBo x()) {
2613 if (!curr->isFloatingOrOutOfFlowPositioned()) { 2609 if (!curr->isFloatingOrOutOfFlowPositioned()) {
2614 int result = curr->firstLineBoxBaseline(); 2610 int result = curr->firstLineBoxBaseline();
(...skipping 11 matching lines...) Expand all
2626 if (!style()->isOverflowVisible()) { 2622 if (!style()->isOverflowVisible()) {
2627 // We are not calling RenderBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us. 2623 // We are not calling RenderBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us.
2628 return direction == HorizontalLine ? height() + m_marginBox.bottom() : w idth() + m_marginBox.left(); 2624 return direction == HorizontalLine ? height() + m_marginBox.bottom() : w idth() + m_marginBox.left();
2629 } 2625 }
2630 2626
2631 return lastLineBoxBaseline(direction); 2627 return lastLineBoxBaseline(direction);
2632 } 2628 }
2633 2629
2634 int RenderBlock::lastLineBoxBaseline(LineDirectionMode lineDirection) const 2630 int RenderBlock::lastLineBoxBaseline(LineDirectionMode lineDirection) const
2635 { 2631 {
2636 if (isWritingModeRoot())
2637 return -1;
2638
2639 if (childrenInline()) { 2632 if (childrenInline()) {
2640 if (!firstLineBox() && hasLineIfEmpty()) { 2633 if (!firstLineBox() && hasLineIfEmpty()) {
2641 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); 2634 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics();
2642 return fontMetrics.ascent() 2635 return fontMetrics.ascent()
2643 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2 2636 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2
2644 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight()); 2637 + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight());
2645 } 2638 }
2646 if (lastLineBox()) 2639 if (lastLineBox())
2647 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin eBox())->fontMetrics().ascent(lastRootBox()->baselineType()); 2640 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin eBox())->fontMetrics().ascent(lastRootBox()->baselineType());
2648 return -1; 2641 return -1;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2927 } 2920 }
2928 } 2921 }
2929 2922
2930 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par ent) const 2923 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par ent) const
2931 { 2924 {
2932 return createAnonymousWithParentRendererAndDisplay(parent, style()->display( )); 2925 return createAnonymousWithParentRendererAndDisplay(parent, style()->display( ));
2933 } 2926 }
2934 2927
2935 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co nst 2928 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co nst
2936 { 2929 {
2937 // If the child has the same directionality as we do, then we can just retur n its 2930 // FIXME(sky): Remove
2938 // collapsed margin. 2931 return child->collapsedMarginBefore();
2939 if (!child->isWritingModeRoot())
2940 return child->collapsedMarginBefore();
2941 return child->collapsedMarginAfter();
2942 } 2932 }
2943 2933
2944 LayoutUnit RenderBlock::collapsedMarginAfterForChild(const RenderBox* child) co nst 2934 LayoutUnit RenderBlock::collapsedMarginAfterForChild(const RenderBox* child) co nst
2945 { 2935 {
2946 // If the child has the same directionality as we do, then we can just retur n its 2936 // FIXME(sky): Remove
2947 // collapsed margin. 2937 return child->collapsedMarginAfter();
2948 if (!child->isWritingModeRoot())
2949 return child->collapsedMarginAfter();
2950 return child->collapsedMarginBefore();
2951 } 2938 }
2952 2939
2953 bool RenderBlock::hasMarginBeforeQuirk(const RenderBox* child) const 2940 bool RenderBlock::hasMarginBeforeQuirk(const RenderBox* child) const
2954 { 2941 {
2955 // If the child has the same directionality as we do, then we can just retur n its 2942 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginBeforeQuirk() : child->style()->hasMarginBeforeQuirk();
2956 // margin quirk.
2957 if (!child->isWritingModeRoot())
2958 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginBeforeQui rk() : child->style()->hasMarginBeforeQuirk();
2959
2960 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginAfterQuirk() : child->style()->hasMarginAfterQuirk();
2961 } 2943 }
2962 2944
2963 bool RenderBlock::hasMarginAfterQuirk(const RenderBox* child) const 2945 bool RenderBlock::hasMarginAfterQuirk(const RenderBox* child) const
2964 { 2946 {
2965 // If the child has the same directionality as we do, then we can just retur n its 2947 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginAfterQuirk() : child->style()->hasMarginAfterQuirk();
2966 // margin quirk.
2967 if (!child->isWritingModeRoot())
2968 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginAfterQuir k() : child->style()->hasMarginAfterQuirk();
2969
2970 return child->isRenderBlock() ? toRenderBlock(child)->hasMarginBeforeQuirk() : child->style()->hasMarginBeforeQuirk();
2971 } 2948 }
2972 2949
2973 const char* RenderBlock::renderName() const 2950 const char* RenderBlock::renderName() const
2974 { 2951 {
2975 if (isFloating()) 2952 if (isFloating())
2976 return "RenderBlock (floating)"; 2953 return "RenderBlock (floating)";
2977 if (isOutOfFlowPositioned()) 2954 if (isOutOfFlowPositioned())
2978 return "RenderBlock (positioned)"; 2955 return "RenderBlock (positioned)";
2979 if (isAnonymousBlock()) 2956 if (isAnonymousBlock())
2980 return "RenderBlock (anonymous)"; 2957 return "RenderBlock (anonymous)";
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3111 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 3088 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
3112 { 3089 {
3113 showRenderObject(); 3090 showRenderObject();
3114 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 3091 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
3115 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 3092 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
3116 } 3093 }
3117 3094
3118 #endif 3095 #endif
3119 3096
3120 } // namespace blink 3097 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/engine/core/rendering/RenderBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698