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

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

Issue 669803002: Optimize for horizontal writing mode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: w compile fix Created 6 years, 2 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) 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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 if (block->hasOverflowClip()) { 1331 if (block->hasOverflowClip()) {
1332 block->layer()->scrollableArea()->updateAfterLayout(); 1332 block->layer()->scrollableArea()->updateAfterLayout();
1333 } 1333 }
1334 } 1334 }
1335 } 1335 }
1336 } 1336 }
1337 1337
1338 void RenderBlock::updateScrollInfoAfterLayout() 1338 void RenderBlock::updateScrollInfoAfterLayout()
1339 { 1339 {
1340 if (hasOverflowClip()) { 1340 if (hasOverflowClip()) {
1341 if (style()->isFlippedBlocksWritingMode()) { 1341 if (style()->slowIsFlippedBlocksWritingMode()) {
1342 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937 1342 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937
1343 // Workaround for now. We cannot delay the scroll info for overflow 1343 // Workaround for now. We cannot delay the scroll info for overflow
1344 // for items with opposite writing directions, as the contents needs 1344 // for items with opposite writing directions, as the contents needs
1345 // to overflow in that direction 1345 // to overflow in that direction
1346 layer()->scrollableArea()->updateAfterLayout(); 1346 layer()->scrollableArea()->updateAfterLayout();
1347 return; 1347 return;
1348 } 1348 }
1349 1349
1350 if (gDelayUpdateScrollInfo) 1350 if (gDelayUpdateScrollInfo)
1351 gDelayedUpdateScrollInfoSet->add(this); 1351 gDelayedUpdateScrollInfoSet->add(this);
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 2454
2455 return false; 2455 return false;
2456 } 2456 }
2457 2457
2458 class ColumnRectIterator { 2458 class ColumnRectIterator {
2459 WTF_MAKE_NONCOPYABLE(ColumnRectIterator); 2459 WTF_MAKE_NONCOPYABLE(ColumnRectIterator);
2460 public: 2460 public:
2461 ColumnRectIterator(const RenderBlock& block) 2461 ColumnRectIterator(const RenderBlock& block)
2462 : m_block(block) 2462 : m_block(block)
2463 , m_colInfo(block.columnInfo()) 2463 , m_colInfo(block.columnInfo())
2464 , m_direction(m_block.style()->isFlippedBlocksWritingMode() ? 1 : -1) 2464 , m_direction(m_block.style()->slowIsFlippedBlocksWritingMode() ? 1 : -1 )
2465 , m_isHorizontal(block.isHorizontalWritingMode()) 2465 , m_isHorizontal(block.isHorizontalWritingMode())
2466 , m_logicalLeft(block.logicalLeftOffsetForContent()) 2466 , m_logicalLeft(block.logicalLeftOffsetForContent())
2467 { 2467 {
2468 int colCount = m_colInfo->columnCount(); 2468 int colCount = m_colInfo->columnCount();
2469 m_colIndex = colCount - 1; 2469 m_colIndex = colCount - 1;
2470 m_currLogicalTopOffset = colCount * m_colInfo->columnHeight() * m_direct ion; 2470 m_currLogicalTopOffset = colCount * m_colInfo->columnHeight() * m_direct ion;
2471 update(); 2471 update();
2472 } 2472 }
2473 2473
2474 void advance() 2474 void advance()
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2631 } 2631 }
2632 2632
2633 PositionWithAffinity RenderBlock::positionForPointWithInlineChildren(const Layou tPoint& pointInLogicalContents) 2633 PositionWithAffinity RenderBlock::positionForPointWithInlineChildren(const Layou tPoint& pointInLogicalContents)
2634 { 2634 {
2635 ASSERT(childrenInline()); 2635 ASSERT(childrenInline());
2636 2636
2637 if (!firstRootBox()) 2637 if (!firstRootBox())
2638 return createPositionWithAffinity(0, DOWNSTREAM); 2638 return createPositionWithAffinity(0, DOWNSTREAM);
2639 2639
2640 bool linesAreFlipped = style()->isFlippedLinesWritingMode(); 2640 bool linesAreFlipped = style()->isFlippedLinesWritingMode();
2641 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); 2641 bool blocksAreFlipped = style()->slowIsFlippedBlocksWritingMode();
2642 2642
2643 // look for the closest line box in the root box which is at the passed-in y coordinate 2643 // look for the closest line box in the root box which is at the passed-in y coordinate
2644 InlineBox* closestBox = 0; 2644 InlineBox* closestBox = 0;
2645 RootInlineBox* firstRootBoxWithChildren = 0; 2645 RootInlineBox* firstRootBoxWithChildren = 0;
2646 RootInlineBox* lastRootBoxWithChildren = 0; 2646 RootInlineBox* lastRootBoxWithChildren = 0;
2647 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox()) { 2647 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox()) {
2648 if (!root->firstLeafChild()) 2648 if (!root->firstLeafChild())
2649 continue; 2649 continue;
2650 if (!firstRootBoxWithChildren) 2650 if (!firstRootBoxWithChildren)
2651 firstRootBoxWithChildren = root; 2651 firstRootBoxWithChildren = root;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2749 if (!isHorizontalWritingMode()) 2749 if (!isHorizontalWritingMode())
2750 pointInLogicalContents = pointInLogicalContents.transposedPoint(); 2750 pointInLogicalContents = pointInLogicalContents.transposedPoint();
2751 2751
2752 if (childrenInline()) 2752 if (childrenInline())
2753 return positionForPointWithInlineChildren(pointInLogicalContents); 2753 return positionForPointWithInlineChildren(pointInLogicalContents);
2754 2754
2755 RenderBox* lastCandidateBox = lastChildBox(); 2755 RenderBox* lastCandidateBox = lastChildBox();
2756 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) 2756 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox))
2757 lastCandidateBox = lastCandidateBox->previousSiblingBox(); 2757 lastCandidateBox = lastCandidateBox->previousSiblingBox();
2758 2758
2759 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); 2759 bool blocksAreFlipped = style()->slowIsFlippedBlocksWritingMode();
2760 if (lastCandidateBox) { 2760 if (lastCandidateBox) {
2761 if (pointInLogicalContents.y() > logicalTopForChild(lastCandidateBox) 2761 if (pointInLogicalContents.y() > logicalTopForChild(lastCandidateBox)
2762 || (!blocksAreFlipped && pointInLogicalContents.y() == logicalTopFor Child(lastCandidateBox))) 2762 || (!blocksAreFlipped && pointInLogicalContents.y() == logicalTopFor Child(lastCandidateBox)))
2763 return positionForPointRespectingEditingBoundaries(this, lastCandida teBox, pointInContents); 2763 return positionForPointRespectingEditingBoundaries(this, lastCandida teBox, pointInContents);
2764 2764
2765 for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBo x->nextSiblingBox()) { 2765 for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBo x->nextSiblingBox()) {
2766 if (!isChildHitTestCandidate(childBox)) 2766 if (!isChildHitTestCandidate(childBox))
2767 continue; 2767 continue;
2768 LayoutUnit childLogicalBottom = logicalTopForChild(childBox) + logic alHeightForChild(childBox); 2768 LayoutUnit childLogicalBottom = logicalTopForChild(childBox) + logic alHeightForChild(childBox);
2769 // We hit child if our click is above the bottom of its padding box (like IE6/7 and FF3). 2769 // We hit child if our click is above the bottom of its padding box (like IE6/7 and FF3).
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
2962 } 2962 }
2963 } else { 2963 } else {
2964 if (point.x() < colRect.x()) 2964 if (point.x() < colRect.x())
2965 point.setX(colRect.x()); 2965 point.setX(colRect.x());
2966 else if (point.x() >= colRect.maxX()) 2966 else if (point.x() >= colRect.maxX())
2967 point.setX(colRect.maxX() - 1); 2967 point.setX(colRect.maxX() - 1);
2968 } 2968 }
2969 2969
2970 // We're inside the column. Translate the x and y into our colu mn coordinate space. 2970 // We're inside the column. Translate the x and y into our colu mn coordinate space.
2971 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) 2971 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis)
2972 point.move(columnPoint.x() - colRect.x(), (!style()->isFlipp edBlocksWritingMode() ? logicalOffset : -logicalOffset)); 2972 point.move(columnPoint.x() - colRect.x(), (!style()->slowIsF lippedBlocksWritingMode() ? logicalOffset : -logicalOffset));
2973 else 2973 else
2974 point.move((!style()->isFlippedBlocksWritingMode() ? logical Offset : -logicalOffset) - colRect.x() + borderLeft() + paddingLeft(), 0); 2974 point.move((!style()->slowIsFlippedBlocksWritingMode() ? log icalOffset : -logicalOffset) - colRect.x() + borderLeft() + paddingLeft(), 0);
2975 return; 2975 return;
2976 } 2976 }
2977 2977
2978 // Move to the next position. 2978 // Move to the next position.
2979 logicalOffset += colInfo->progressionAxis() == ColumnInfo::InlineAxi s ? colRect.height() : colRect.width(); 2979 logicalOffset += colInfo->progressionAxis() == ColumnInfo::InlineAxi s ? colRect.height() : colRect.width();
2980 } else { 2980 } else {
2981 LayoutRect gapAndColumnRect(colRect.x(), colRect.y() - halfColGap, c olRect.width(), colRect.height() + colGap); 2981 LayoutRect gapAndColumnRect(colRect.x(), colRect.y() - halfColGap, c olRect.width(), colRect.height() + colGap);
2982 if (point.y() >= gapAndColumnRect.y() && point.y() < gapAndColumnRec t.maxY()) { 2982 if (point.y() >= gapAndColumnRect.y() && point.y() < gapAndColumnRec t.maxY()) {
2983 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) { 2983 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) {
2984 // FIXME: The clamping that follows is not completely right for right-to-left 2984 // FIXME: The clamping that follows is not completely right for right-to-left
2985 // content. 2985 // content.
2986 // Clamp everything above the column to its top left. 2986 // Clamp everything above the column to its top left.
2987 if (point.x() < gapAndColumnRect.x()) 2987 if (point.x() < gapAndColumnRect.x())
2988 point = gapAndColumnRect.location(); 2988 point = gapAndColumnRect.location();
2989 // Clamp everything below the column to the next column's to p left. If there is 2989 // Clamp everything below the column to the next column's to p left. If there is
2990 // no next column, this still maps to just after this column . 2990 // no next column, this still maps to just after this column .
2991 else if (point.x() >= gapAndColumnRect.maxX()) { 2991 else if (point.x() >= gapAndColumnRect.maxX()) {
2992 point = gapAndColumnRect.location(); 2992 point = gapAndColumnRect.location();
2993 point.move(gapAndColumnRect.width(), 0); 2993 point.move(gapAndColumnRect.width(), 0);
2994 } 2994 }
2995 } else { 2995 } else {
2996 if (point.y() < colRect.y()) 2996 if (point.y() < colRect.y())
2997 point.setY(colRect.y()); 2997 point.setY(colRect.y());
2998 else if (point.y() >= colRect.maxY()) 2998 else if (point.y() >= colRect.maxY())
2999 point.setY(colRect.maxY() - 1); 2999 point.setY(colRect.maxY() - 1);
3000 } 3000 }
3001 3001
3002 // We're inside the column. Translate the x and y into our colu mn coordinate space. 3002 // We're inside the column. Translate the x and y into our colu mn coordinate space.
3003 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) 3003 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis)
3004 point.move((!style()->isFlippedBlocksWritingMode() ? logical Offset : -logicalOffset), columnPoint.y() - colRect.y()); 3004 point.move((!style()->slowIsFlippedBlocksWritingMode() ? log icalOffset : -logicalOffset), columnPoint.y() - colRect.y());
3005 else 3005 else
3006 point.move(0, (!style()->isFlippedBlocksWritingMode() ? logi calOffset : -logicalOffset) - colRect.y() + borderTop() + paddingTop()); 3006 point.move(0, (!style()->slowIsFlippedBlocksWritingMode() ? logicalOffset : -logicalOffset) - colRect.y() + borderTop() + paddingTop());
3007 return; 3007 return;
3008 } 3008 }
3009 3009
3010 // Move to the next position. 3010 // Move to the next position.
3011 logicalOffset += colInfo->progressionAxis() == ColumnInfo::InlineAxi s ? colRect.width() : colRect.height(); 3011 logicalOffset += colInfo->progressionAxis() == ColumnInfo::InlineAxi s ? colRect.width() : colRect.height();
3012 } 3012 }
3013 } 3013 }
3014 } 3014 }
3015 3015
3016 void RenderBlock::adjustRectForColumns(LayoutRect& r) const 3016 void RenderBlock::adjustRectForColumns(LayoutRect& r) const
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 result.unite(columnRectAt(colInfo, startColumn)); 3068 result.unite(columnRectAt(colInfo, startColumn));
3069 result.unite(columnRectAt(colInfo, endColumn)); 3069 result.unite(columnRectAt(colInfo, endColumn));
3070 } 3070 }
3071 3071
3072 r = result; 3072 r = result;
3073 } 3073 }
3074 3074
3075 LayoutPoint RenderBlock::flipForWritingModeIncludingColumns(const LayoutPoint& p oint) const 3075 LayoutPoint RenderBlock::flipForWritingModeIncludingColumns(const LayoutPoint& p oint) const
3076 { 3076 {
3077 ASSERT(hasColumns()); 3077 ASSERT(hasColumns());
3078 if (!hasColumns() || !style()->isFlippedBlocksWritingMode()) 3078 if (!hasColumns() || !style()->slowIsFlippedBlocksWritingMode())
3079 return point; 3079 return point;
3080 ColumnInfo* colInfo = columnInfo(); 3080 ColumnInfo* colInfo = columnInfo();
3081 LayoutUnit columnLogicalHeight = colInfo->columnHeight(); 3081 LayoutUnit columnLogicalHeight = colInfo->columnHeight();
3082 LayoutUnit expandedLogicalHeight = borderBefore() + paddingBefore() + column Count(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollba rLogicalHeight(); 3082 LayoutUnit expandedLogicalHeight = borderBefore() + paddingBefore() + column Count(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollba rLogicalHeight();
3083 if (isHorizontalWritingMode()) 3083 if (isHorizontalWritingMode())
3084 return LayoutPoint(point.x(), expandedLogicalHeight - point.y()); 3084 return LayoutPoint(point.x(), expandedLogicalHeight - point.y());
3085 return LayoutPoint(expandedLogicalHeight - point.x(), point.y()); 3085 return LayoutPoint(expandedLogicalHeight - point.x(), point.y());
3086 } 3086 }
3087 3087
3088 void RenderBlock::adjustStartEdgeForWritingModeIncludingColumns(LayoutRect& rect ) const 3088 void RenderBlock::adjustStartEdgeForWritingModeIncludingColumns(LayoutRect& rect ) const
3089 { 3089 {
3090 ASSERT(hasColumns()); 3090 ASSERT(hasColumns());
3091 if (!hasColumns() || !style()->isFlippedBlocksWritingMode()) 3091 if (!hasColumns() || !style()->slowIsFlippedBlocksWritingMode())
3092 return; 3092 return;
3093 3093
3094 ColumnInfo* colInfo = columnInfo(); 3094 ColumnInfo* colInfo = columnInfo();
3095 LayoutUnit columnLogicalHeight = colInfo->columnHeight(); 3095 LayoutUnit columnLogicalHeight = colInfo->columnHeight();
3096 LayoutUnit expandedLogicalHeight = borderBefore() + paddingBefore() + column Count(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollba rLogicalHeight(); 3096 LayoutUnit expandedLogicalHeight = borderBefore() + paddingBefore() + column Count(colInfo) * columnLogicalHeight + borderAfter() + paddingAfter() + scrollba rLogicalHeight();
3097 3097
3098 if (isHorizontalWritingMode()) 3098 if (isHorizontalWritingMode())
3099 rect.setY(expandedLogicalHeight - rect.maxY()); 3099 rect.setY(expandedLogicalHeight - rect.maxY());
3100 else 3100 else
3101 rect.setX(expandedLogicalHeight - rect.maxX()); 3101 rect.setX(expandedLogicalHeight - rect.maxX());
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
4112 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 4112 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
4113 { 4113 {
4114 showRenderObject(); 4114 showRenderObject();
4115 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 4115 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
4116 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 4116 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
4117 } 4117 }
4118 4118
4119 #endif 4119 #endif
4120 4120
4121 } // namespace blink 4121 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698