Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "core/paint/ObjectPainter.h" | 5 #include "core/paint/ObjectPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBlock.h" | 7 #include "core/layout/LayoutBlock.h" |
| 8 #include "core/layout/LayoutInline.h" | 8 #include "core/layout/LayoutInline.h" |
| 9 #include "core/layout/LayoutObject.h" | 9 #include "core/layout/LayoutObject.h" |
| 10 #include "core/layout/LayoutTheme.h" | 10 #include "core/layout/LayoutTheme.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 } | 181 } |
| 182 | 182 |
| 183 if (useTransparencyLayer) | 183 if (useTransparencyLayer) |
| 184 graphicsContext.endLayer(); | 184 graphicsContext.endLayer(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace | 187 } // namespace |
| 188 | 188 |
| 189 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 189 void ObjectPainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
| 190 { | 190 { |
| 191 ASSERT(paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhase SelfOutline); | 191 ASSERT(shouldPaintSelfOutline(paintInfo.phase)); |
| 192 | 192 |
| 193 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); | 193 const ComputedStyle& styleToUse = m_layoutObject.styleRef(); |
| 194 if (!styleToUse.hasOutline() || styleToUse.visibility() != VISIBLE) | 194 if (!styleToUse.hasOutline() || styleToUse.visibility() != VISIBLE) |
| 195 return; | 195 return; |
| 196 | 196 |
| 197 // Only paint the focus ring by hand if the theme isn't able to draw the foc us ring. | 197 // Only paint the focus ring by hand if the theme isn't able to draw the foc us ring. |
| 198 if (styleToUse.outlineStyleIsAuto() && !LayoutTheme::theme().shouldDrawDefau ltFocusRing(m_layoutObject)) | 198 if (styleToUse.outlineStyleIsAuto() && !LayoutTheme::theme().shouldDrawDefau ltFocusRing(m_layoutObject)) |
| 199 return; | 199 return; |
| 200 | 200 |
| 201 Vector<LayoutRect> outlineRects; | 201 Vector<LayoutRect> outlineRects; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 | 234 |
| 235 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) { | 235 if (unitedOutlineRect == pixelSnappedOutlineRects[0]) { |
| 236 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse, co lor); | 236 paintSingleRectangleOutline(paintInfo, unitedOutlineRect, styleToUse, co lor); |
| 237 return; | 237 return; |
| 238 } | 238 } |
| 239 paintComplexOutline(paintInfo.context, pixelSnappedOutlineRects, styleToUse, color); | 239 paintComplexOutline(paintInfo.context, pixelSnappedOutlineRects, styleToUse, color); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void ObjectPainter::paintInlineChildrenOutlines(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset) | 242 void ObjectPainter::paintInlineChildrenOutlines(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset) |
| 243 { | 243 { |
| 244 ASSERT(paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhase DescendantOutlines); | 244 ASSERT(shouldPaintDescendantOutlines(paintInfo.phase)); |
| 245 | 245 |
| 246 PaintInfo childPaintInfo(paintInfo); | 246 PaintInfo paintInfoForDescendants = paintInfo.forDescendants(); |
| 247 childPaintInfo.phase = paintInfo.phase == PaintPhaseDescendantOutlines ? Pai ntPhaseOutline : paintInfo.phase; | |
| 248 | |
| 249 for (LayoutObject* child = m_layoutObject.slowFirstChild(); child; child = c hild->nextSibling()) { | 247 for (LayoutObject* child = m_layoutObject.slowFirstChild(); child; child = c hild->nextSibling()) { |
| 250 if (child->isLayoutInline() && !toLayoutInline(child)->hasSelfPaintingLa yer()) | 248 if (child->isLayoutInline() && !toLayoutInline(child)->hasSelfPaintingLa yer()) |
| 251 child->paint(childPaintInfo, paintOffset); | 249 child->paint(paintInfoForDescendants, paintOffset); |
| 252 } | 250 } |
| 253 } | 251 } |
| 254 | 252 |
| 255 void ObjectPainter::addPDFURLRectIfNeeded(const PaintInfo& paintInfo, const Layo utPoint& paintOffset) | 253 void ObjectPainter::addPDFURLRectIfNeeded(const PaintInfo& paintInfo, const Layo utPoint& paintOffset) |
| 256 { | 254 { |
| 257 ASSERT(paintInfo.isPrinting()); | 255 ASSERT(paintInfo.isPrinting()); |
| 258 if (m_layoutObject.isElementContinuation() || !m_layoutObject.node() || !m_l ayoutObject.node()->isLink() || m_layoutObject.styleRef().visibility() != VISIBL E) | 256 if (m_layoutObject.isElementContinuation() || !m_layoutObject.node() || !m_l ayoutObject.node()->isLink() || m_layoutObject.styleRef().visibility() != VISIBL E) |
| 259 return; | 257 return; |
| 260 | 258 |
| 261 KURL url = toElement(m_layoutObject.node())->hrefURL(); | 259 KURL url = toElement(m_layoutObject.node())->hrefURL(); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 529 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); | 527 quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0)); |
| 530 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); | 528 quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0)); |
| 531 break; | 529 break; |
| 532 } | 530 } |
| 533 | 531 |
| 534 graphicsContext.fillPolygon(4, quad, color, antialias); | 532 graphicsContext.fillPolygon(4, quad, color, antialias); |
| 535 } | 533 } |
| 536 | 534 |
| 537 void ObjectPainter::paintAsPseudoStackingContext(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset) | 535 void ObjectPainter::paintAsPseudoStackingContext(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset) |
| 538 { | 536 { |
| 539 bool preservePhase = paintInfo.phase == PaintPhaseSelection || paintInfo.pha se == PaintPhaseTextClip; | 537 if (paintInfo.phase == PaintPhaseSelection || paintInfo.phase == PaintPhaseT extClip) { |
|
pdr.
2016/01/14 19:51:50
Can you add a comment here about why we preserve t
Xianzhu
2016/01/15 01:05:33
Done.
| |
| 540 if (!preservePhase && paintInfo.phase != PaintPhaseForeground) | 538 m_layoutObject.paint(paintInfo, paintOffset); |
| 539 return; | |
| 540 } | |
| 541 | |
| 542 if (paintInfo.phase != PaintPhaseForeground) | |
| 541 return; | 543 return; |
| 542 | 544 |
| 543 PaintInfo info(paintInfo); | 545 PaintInfo info(paintInfo); |
| 544 info.phase = preservePhase ? paintInfo.phase : PaintPhaseSelfBlockBackground ; | 546 info.phase = PaintPhaseBlockBackground; |
| 545 m_layoutObject.paint(info, paintOffset); | 547 m_layoutObject.paint(info, paintOffset); |
| 546 if (!preservePhase) { | 548 info.phase = PaintPhaseFloat; |
| 547 info.phase = PaintPhaseDescendantBlockBackgrounds; | 549 m_layoutObject.paint(info, paintOffset); |
| 548 m_layoutObject.paint(info, paintOffset); | 550 info.phase = PaintPhaseForeground; |
| 549 info.phase = PaintPhaseFloat; | 551 m_layoutObject.paint(info, paintOffset); |
| 550 m_layoutObject.paint(info, paintOffset); | 552 info.phase = PaintPhaseOutline; |
| 551 info.phase = PaintPhaseForeground; | 553 m_layoutObject.paint(info, paintOffset); |
| 552 m_layoutObject.paint(info, paintOffset); | |
| 553 info.phase = PaintPhaseOutline; | |
| 554 m_layoutObject.paint(info, paintOffset); | |
| 555 } | |
| 556 } | 554 } |
| 557 | 555 |
| 558 } // namespace blink | 556 } // namespace blink |
| OLD | NEW |