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

Side by Side Diff: third_party/WebKit/Source/core/paint/BoxPainter.cpp

Issue 2942123002: Break LayoutObject dependency for NinePieceImagePainter (Closed)
Patch Set: Pass document explicitly Created 3 years, 6 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 "core/paint/BoxPainter.h" 5 #include "core/paint/BoxPainter.h"
6 6
7 #include "core/HTMLNames.h" 7 #include "core/HTMLNames.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/frame/LocalFrameView.h" 9 #include "core/frame/LocalFrameView.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
11 #include "core/html/HTMLFrameOwnerElement.h" 11 #include "core/html/HTMLFrameOwnerElement.h"
12 #include "core/layout/BackgroundBleedAvoidance.h" 12 #include "core/layout/BackgroundBleedAvoidance.h"
13 #include "core/layout/ImageQualityController.h" 13 #include "core/layout/ImageQualityController.h"
14 #include "core/layout/LayoutBox.h" 14 #include "core/layout/LayoutBox.h"
15 #include "core/layout/LayoutBoxModelObject.h" 15 #include "core/layout/LayoutBoxModelObject.h"
16 #include "core/layout/LayoutObject.h" 16 #include "core/layout/LayoutObject.h"
17 #include "core/layout/LayoutTable.h" 17 #include "core/layout/LayoutTable.h"
18 #include "core/layout/LayoutTheme.h" 18 #include "core/layout/LayoutTheme.h"
19 #include "core/layout/compositing/CompositedLayerMapping.h" 19 #include "core/layout/compositing/CompositedLayerMapping.h"
20 #include "core/layout/line/RootInlineBox.h" 20 #include "core/layout/line/RootInlineBox.h"
21 #include "core/page/ChromeClient.h" 21 #include "core/page/ChromeClient.h"
22 #include "core/page/Page.h" 22 #include "core/page/Page.h"
23 #include "core/paint/BackgroundImageGeometry.h" 23 #include "core/paint/BackgroundImageGeometry.h"
24 #include "core/paint/BoxBorderPainter.h"
25 #include "core/paint/BoxDecorationData.h" 24 #include "core/paint/BoxDecorationData.h"
26 #include "core/paint/LayoutObjectDrawingRecorder.h" 25 #include "core/paint/LayoutObjectDrawingRecorder.h"
27 #include "core/paint/NinePieceImagePainter.h" 26 #include "core/paint/NinePieceImagePainter.h"
28 #include "core/paint/ObjectPainter.h" 27 #include "core/paint/ObjectPainter.h"
29 #include "core/paint/PaintInfo.h" 28 #include "core/paint/PaintInfo.h"
30 #include "core/paint/PaintLayer.h" 29 #include "core/paint/PaintLayer.h"
31 #include "core/paint/ScrollRecorder.h" 30 #include "core/paint/ScrollRecorder.h"
32 #include "core/paint/ThemePainter.h" 31 #include "core/paint/ThemePainter.h"
33 #include "core/style/ShadowList.h" 32 #include "core/style/ShadowList.h"
34 #include "platform/LengthFunctions.h" 33 #include "platform/LengthFunctions.h"
35 #include "platform/geometry/LayoutPoint.h" 34 #include "platform/geometry/LayoutPoint.h"
36 #include "platform/geometry/LayoutRectOutsets.h" 35 #include "platform/geometry/LayoutRectOutsets.h"
37 #include "platform/graphics/GraphicsContextStateSaver.h" 36 #include "platform/graphics/GraphicsContextStateSaver.h"
38 #include "platform/graphics/paint/CompositingDisplayItem.h" 37 #include "platform/graphics/paint/CompositingDisplayItem.h"
38 #include "platform/wtf/Optional.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 bool BoxPainter::IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer( 42 bool BoxPainter::IsPaintingBackgroundOfPaintContainerIntoScrollingContentsLayer(
43 const LayoutBoxModelObject* obj, 43 const LayoutBoxModelObject* obj,
44 const PaintInfo& paint_info) { 44 const PaintInfo& paint_info) {
45 return paint_info.PaintFlags() & kPaintLayerPaintingOverflowContents && 45 return paint_info.PaintFlags() & kPaintLayerPaintingOverflowContents &&
46 !(paint_info.PaintFlags() & 46 !(paint_info.PaintFlags() &
47 kPaintLayerPaintingCompositingBackgroundPhase) && 47 kPaintLayerPaintingCompositingBackgroundPhase) &&
48 obj == paint_info.PaintContainer(); 48 obj == paint_info.PaintContainer();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 // The theme will tell us whether or not we should also paint the CSS 185 // The theme will tell us whether or not we should also paint the CSS
186 // border. 186 // border.
187 if (box_decoration_data.has_border_decoration && 187 if (box_decoration_data.has_border_decoration &&
188 (!box_decoration_data.has_appearance || 188 (!box_decoration_data.has_appearance ||
189 (!theme_painted && 189 (!theme_painted &&
190 LayoutTheme::GetTheme().Painter().PaintBorderOnly( 190 LayoutTheme::GetTheme().Painter().PaintBorderOnly(
191 layout_box_, paint_info, snapped_paint_rect))) && 191 layout_box_, paint_info, snapped_paint_rect))) &&
192 !(layout_box_.IsTable() && 192 !(layout_box_.IsTable() &&
193 ToLayoutTable(&layout_box_)->ShouldCollapseBorders())) { 193 ToLayoutTable(&layout_box_)->ShouldCollapseBorders())) {
194 PaintBorder(layout_box_, paint_info, paint_rect, style, 194 PaintBorder(layout_box_, layout_box_.GetDocument(), GetNode(), paint_info,
195 box_decoration_data.bleed_avoidance); 195 paint_rect, style, box_decoration_data.bleed_avoidance);
196 } 196 }
197 } 197 }
198 198
199 if (box_decoration_data.bleed_avoidance == kBackgroundBleedClipLayer) 199 if (box_decoration_data.bleed_avoidance == kBackgroundBleedClipLayer)
200 paint_info.context.EndLayer(); 200 paint_info.context.EndLayer();
201 } 201 }
202 202
203 void BoxPainter::PaintBackground(const PaintInfo& paint_info, 203 void BoxPainter::PaintBackground(const PaintInfo& paint_info,
204 const LayoutRect& paint_rect, 204 const LayoutRect& paint_rect,
205 const Color& background_color, 205 const Color& background_color,
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 all_mask_images_loaded &= mask_box_image->IsLoaded(); 636 all_mask_images_loaded &= mask_box_image->IsLoaded();
637 637
638 all_mask_images_loaded &= mask_layers.ImagesAreLoaded(); 638 all_mask_images_loaded &= mask_layers.ImagesAreLoaded();
639 639
640 paint_info.context.BeginLayer(1, SkBlendMode::kDstIn); 640 paint_info.context.BeginLayer(1, SkBlendMode::kDstIn);
641 } 641 }
642 642
643 if (all_mask_images_loaded) { 643 if (all_mask_images_loaded) {
644 PaintFillLayers(paint_info, Color::kTransparent, 644 PaintFillLayers(paint_info, Color::kTransparent,
645 layout_box_.Style()->MaskLayers(), paint_rect); 645 layout_box_.Style()->MaskLayers(), paint_rect);
646 PaintNinePieceImage(layout_box_, paint_info.context, paint_rect, 646 NinePieceImagePainter::Paint(paint_info.context, layout_box_,
647 layout_box_.StyleRef(), 647 layout_box_.GetDocument(), GetNode(),
648 layout_box_.Style()->MaskBoxImage()); 648 paint_rect, layout_box_.StyleRef(),
649 layout_box_.StyleRef().MaskBoxImage());
649 } 650 }
650 651
651 if (push_transparency_layer) 652 if (push_transparency_layer)
652 paint_info.context.EndLayer(); 653 paint_info.context.EndLayer();
653 } 654 }
654 655
655 void BoxPainter::PaintClippingMask(const PaintInfo& paint_info, 656 void BoxPainter::PaintClippingMask(const PaintInfo& paint_info,
656 const LayoutPoint& paint_offset) { 657 const LayoutPoint& paint_offset) {
657 DCHECK(paint_info.phase == kPaintPhaseClippingMask); 658 DCHECK(paint_info.phase == kPaintPhaseClippingMask);
658 659
659 if (layout_box_.Style()->Visibility() != EVisibility::kVisible) 660 if (layout_box_.Style()->Visibility() != EVisibility::kVisible)
660 return; 661 return;
661 662
662 if (!layout_box_.Layer() || 663 if (!layout_box_.Layer() ||
663 layout_box_.Layer()->GetCompositingState() != kPaintsIntoOwnBacking) 664 layout_box_.Layer()->GetCompositingState() != kPaintsIntoOwnBacking)
664 return; 665 return;
665 666
666 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible( 667 if (LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible(
667 paint_info.context, layout_box_, paint_info.phase)) 668 paint_info.context, layout_box_, paint_info.phase))
668 return; 669 return;
669 670
670 IntRect paint_rect = 671 IntRect paint_rect =
671 PixelSnappedIntRect(LayoutRect(paint_offset, layout_box_.Size())); 672 PixelSnappedIntRect(LayoutRect(paint_offset, layout_box_.Size()));
672 LayoutObjectDrawingRecorder drawing_recorder(paint_info.context, layout_box_, 673 LayoutObjectDrawingRecorder drawing_recorder(paint_info.context, layout_box_,
673 paint_info.phase, paint_rect); 674 paint_info.phase, paint_rect);
674 paint_info.context.FillRect(paint_rect, Color::kBlack); 675 paint_info.context.FillRect(paint_rect, Color::kBlack);
675 } 676 }
676 677
677 bool BoxPainter::PaintNinePieceImage(const LayoutBoxModelObject& obj, 678 Node* BoxPainter::GetNode() {
678 GraphicsContext& graphics_context, 679 Node* node = nullptr;
679 const LayoutRect& rect, 680 const LayoutObject* layout_object = &layout_box_;
680 const ComputedStyle& style, 681 for (; layout_object && !node; layout_object = layout_object->Parent()) {
681 const NinePieceImage& nine_piece_image, 682 node = layout_object->GeneratingNode();
682 SkBlendMode op) { 683 }
683 return NinePieceImagePainter().Paint(graphics_context, obj, rect, style, 684 return node;
684 nine_piece_image, op);
685 }
686
687 void BoxPainter::PaintBorder(const LayoutBoxModelObject& obj,
688 const PaintInfo& info,
689 const LayoutRect& rect,
690 const ComputedStyle& style,
691 BackgroundBleedAvoidance bleed_avoidance,
692 bool include_logical_left_edge,
693 bool include_logical_right_edge) {
694 // border-image is not affected by border-radius.
695 if (PaintNinePieceImage(obj, info.context, rect, style, style.BorderImage()))
696 return;
697
698 const BoxBorderPainter border_painter(rect, style, bleed_avoidance,
699 include_logical_left_edge,
700 include_logical_right_edge);
701 border_painter.PaintBorder(info, rect);
702 } 685 }
703 686
704 } // namespace blink 687 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BoxPainter.h ('k') | third_party/WebKit/Source/core/paint/BoxPainterBase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698