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

Side by Side Diff: Source/core/paint/BlockPainter.cpp

Issue 669803002: Optimize for horizontal writing mode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moved logic to RenderBlock as suggested by pdr 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/BlockPainter.h" 6 #include "core/paint/BlockPainter.h"
7 7
8 #include "core/editing/Caret.h" 8 #include "core/editing/Caret.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (!child->hasSelfPaintingLayer() && !child->isFloating()) 102 if (!child->hasSelfPaintingLayer() && !child->isFloating())
103 paintAsInlineBlock(child, paintInfo, childPoint); 103 paintAsInlineBlock(child, paintInfo, childPoint);
104 } 104 }
105 105
106 void BlockPainter::paintInlineBox(InlineBox& inlineBox, PaintInfo& paintInfo, co nst LayoutPoint& paintOffset) 106 void BlockPainter::paintInlineBox(InlineBox& inlineBox, PaintInfo& paintInfo, co nst LayoutPoint& paintOffset)
107 { 107 {
108 if (!paintInfo.shouldPaintWithinRoot(&inlineBox.renderer()) || (paintInfo.ph ase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)) 108 if (!paintInfo.shouldPaintWithinRoot(&inlineBox.renderer()) || (paintInfo.ph ase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
109 return; 109 return;
110 110
111 LayoutPoint childPoint = paintOffset; 111 LayoutPoint childPoint = paintOffset;
112 if (inlineBox.parent()->renderer().style()->isFlippedBlocksWritingMode()) // Faster than calling containingBlock(). 112 const RenderObject& renderer = inlineBox.parent()->renderer();
113 if (!UNLIKELY(renderer.document().containsAnyVerticalWritingModes())
114 && renderer.style()->slowIsFlippedBlocksWritingMode()) { // Faster than calling containingBlock().
pdr. 2014/10/21 23:35:34 I think this comment belongs with the parent() cal
113 childPoint = inlineBox.renderer().containingBlock()->flipForWritingModeF orChild(&toRenderBox(inlineBox.renderer()), childPoint); 115 childPoint = inlineBox.renderer().containingBlock()->flipForWritingModeF orChild(&toRenderBox(inlineBox.renderer()), childPoint);
116 }
114 117
115 paintAsInlineBlock(&inlineBox.renderer(), paintInfo, childPoint); 118 paintAsInlineBlock(&inlineBox.renderer(), paintInfo, childPoint);
116 } 119 }
117 120
118 void BlockPainter::paintAsInlineBlock(RenderObject* renderer, PaintInfo& paintIn fo, const LayoutPoint& childPoint) 121 void BlockPainter::paintAsInlineBlock(RenderObject* renderer, PaintInfo& paintIn fo, const LayoutPoint& childPoint)
119 { 122 {
120 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase Selection) 123 if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhase Selection)
121 return; 124 return;
122 125
123 // Paint all phases atomically, as though the element established its own 126 // Paint all phases atomically, as though the element established its own
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 LayoutUnit ruleRight = m_renderBlock.isHorizontalWritingMode() ? ruleLeft + ruleThickness : ruleLeft + m_renderBlock.contentWidth(); 327 LayoutUnit ruleRight = m_renderBlock.isHorizontalWritingMode() ? ruleLeft + ruleThickness : ruleLeft + m_renderBlock.contentWidth();
325 LayoutUnit ruleTop = m_renderBlock.isHorizontalWritingMode() ? p aintOffset.y() + m_renderBlock.borderTop() + m_renderBlock.paddingTop() : paintO ffset.y() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd; 328 LayoutUnit ruleTop = m_renderBlock.isHorizontalWritingMode() ? p aintOffset.y() + m_renderBlock.borderTop() + m_renderBlock.paddingTop() : paintO ffset.y() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd;
326 LayoutUnit ruleBottom = m_renderBlock.isHorizontalWritingMode() ? ruleTop + m_renderBlock.contentHeight() : ruleTop + ruleThickness; 329 LayoutUnit ruleBottom = m_renderBlock.isHorizontalWritingMode() ? ruleTop + m_renderBlock.contentHeight() : ruleTop + ruleThickness;
327 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule Left, ruleTop, ruleRight, ruleBottom); 330 IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(rule Left, ruleTop, ruleRight, ruleBottom);
328 ObjectPainter::drawLineForBoxSide(paintInfo.context, pixelSnappe dRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnapp edRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); 331 ObjectPainter::drawLineForBoxSide(paintInfo.context, pixelSnappe dRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnapp edRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias);
329 } 332 }
330 333
331 ruleLogicalLeft = currLogicalLeftOffset; 334 ruleLogicalLeft = currLogicalLeftOffset;
332 } 335 }
333 } else { 336 } else {
334 bool topToBottom = !m_renderBlock.style()->isFlippedBlocksWritingMode(); 337 bool topToBottom = !m_renderBlock.style()->slowIsFlippedBlocksWritingMod e();
335 LayoutUnit ruleLeft = m_renderBlock.isHorizontalWritingMode() 338 LayoutUnit ruleLeft = m_renderBlock.isHorizontalWritingMode()
336 ? m_renderBlock.borderLeft() + m_renderBlock.paddingLeft() 339 ? m_renderBlock.borderLeft() + m_renderBlock.paddingLeft()
337 : colGap / 2 - colGap - ruleThickness / 2 + m_renderBlock.borderBefo re() + m_renderBlock.paddingBefore(); 340 : colGap / 2 - colGap - ruleThickness / 2 + m_renderBlock.borderBefo re() + m_renderBlock.paddingBefore();
338 LayoutUnit ruleWidth = m_renderBlock.isHorizontalWritingMode() ? m_rende rBlock.contentWidth() : ruleThickness; 341 LayoutUnit ruleWidth = m_renderBlock.isHorizontalWritingMode() ? m_rende rBlock.contentWidth() : ruleThickness;
339 LayoutUnit ruleTop = m_renderBlock.isHorizontalWritingMode() 342 LayoutUnit ruleTop = m_renderBlock.isHorizontalWritingMode()
340 ? colGap / 2 - colGap - ruleThickness / 2 + m_renderBlock.borderBefo re() + m_renderBlock.paddingBefore() 343 ? colGap / 2 - colGap - ruleThickness / 2 + m_renderBlock.borderBefo re() + m_renderBlock.paddingBefore()
341 : m_renderBlock.borderStart() + m_renderBlock.paddingStart(); 344 : m_renderBlock.borderStart() + m_renderBlock.paddingStart();
342 LayoutUnit ruleHeight = m_renderBlock.isHorizontalWritingMode() ? ruleTh ickness : m_renderBlock.contentHeight(); 345 LayoutUnit ruleHeight = m_renderBlock.isHorizontalWritingMode() ? ruleTh ickness : m_renderBlock.contentHeight();
343 LayoutRect ruleRect(ruleLeft, ruleTop, ruleWidth, ruleHeight); 346 LayoutRect ruleRect(ruleLeft, ruleTop, ruleWidth, ruleHeight);
344 347
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 414
412 // Adjust our x and y when painting. 415 // Adjust our x and y when painting.
413 LayoutPoint adjustedPaintOffset = paintOffset + offset; 416 LayoutPoint adjustedPaintOffset = paintOffset + offset;
414 if (paintingFloats) 417 if (paintingFloats)
415 m_renderBlock.paintFloats(info, adjustedPaintOffset, paintInfo.p hase == PaintPhaseSelection || paintInfo.phase == PaintPhaseTextClip); 418 m_renderBlock.paintFloats(info, adjustedPaintOffset, paintInfo.p hase == PaintPhaseSelection || paintInfo.phase == PaintPhaseTextClip);
416 else 419 else
417 paintContents(info, adjustedPaintOffset); 420 paintContents(info, adjustedPaintOffset);
418 } 421 }
419 422
420 LayoutUnit blockDelta = (m_renderBlock.isHorizontalWritingMode() ? colRe ct.height() : colRect.width()); 423 LayoutUnit blockDelta = (m_renderBlock.isHorizontalWritingMode() ? colRe ct.height() : colRect.width());
421 if (m_renderBlock.style()->isFlippedBlocksWritingMode()) 424 if (m_renderBlock.style()->slowIsFlippedBlocksWritingMode())
422 currLogicalTopOffset += blockDelta; 425 currLogicalTopOffset += blockDelta;
423 else 426 else
424 currLogicalTopOffset -= blockDelta; 427 currLogicalTopOffset -= blockDelta;
425 } 428 }
426 } 429 }
427 430
428 void BlockPainter::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintO ffset) 431 void BlockPainter::paintContents(PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
429 { 432 {
430 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC. 433 // Avoid painting descendants of the root element when stylesheets haven't l oaded. This eliminates FOUC.
431 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document 434 // It's ok not to draw, because later on, when all the stylesheets do load, styleResolverChanged() on the Document
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 RenderBlock* block = flow->containingBlock(); 515 RenderBlock* block = flow->containingBlock();
513 for ( ; block && block != &m_renderBlock; block = block->containingBlock ()) 516 for ( ; block && block != &m_renderBlock; block = block->containingBlock ())
514 accumulatedPaintOffset.moveBy(block->location()); 517 accumulatedPaintOffset.moveBy(block->location());
515 ASSERT(block); 518 ASSERT(block);
516 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset); 519 InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset);
517 } 520 }
518 } 521 }
519 522
520 523
521 } // namespace blink 524 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698