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

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

Issue 867653005: Remove outline painting on inlines. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 { 249 {
250 IntRect intRect = enclosingIntRect(rect); 250 IntRect intRect = enclosingIntRect(rect);
251 intRect.move(m_accumulatedOffset.x(), m_accumulatedOffset.y()); 251 intRect.move(m_accumulatedOffset.x(), m_accumulatedOffset.y());
252 m_rects.append(intRect); 252 m_rects.append(intRect);
253 } 253 }
254 private: 254 private:
255 Vector<IntRect>& m_rects; 255 Vector<IntRect>& m_rects;
256 const LayoutPoint& m_accumulatedOffset; 256 const LayoutPoint& m_accumulatedOffset;
257 }; 257 };
258 258
259 } // unnamed namespace
260
261 void RenderInline::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accu mulatedOffset) const
262 {
263 AbsoluteRectsGeneratorContext context(rects, accumulatedOffset);
264 generateLineBoxRects(context);
265 }
266
267
268 namespace {
269
270 class AbsoluteQuadsGeneratorContext { 259 class AbsoluteQuadsGeneratorContext {
271 public: 260 public:
272 AbsoluteQuadsGeneratorContext(const RenderInline* renderer, Vector<FloatQuad >& quads) 261 AbsoluteQuadsGeneratorContext(const RenderInline* renderer, Vector<FloatQuad >& quads)
273 : m_quads(quads) 262 : m_quads(quads)
274 , m_geometryMap() 263 , m_geometryMap()
275 { 264 {
276 m_geometryMap.pushMappingsToAncestor(renderer, 0); 265 m_geometryMap.pushMappingsToAncestor(renderer, 0);
277 } 266 }
278 267
279 void operator()(const FloatRect& rect) 268 void operator()(const FloatRect& rect)
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 } // unnamed namespace 769 } // unnamed namespace
781 770
782 void RenderInline::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) const 771 void RenderInline::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) const
783 { 772 {
784 AbsoluteRectsIgnoringEmptyRectsGeneratorContext context(rects, additionalOff set); 773 AbsoluteRectsIgnoringEmptyRectsGeneratorContext context(rects, additionalOff set);
785 generateLineBoxRects(context); 774 generateLineBoxRects(context);
786 775
787 addChildFocusRingRects(rects, additionalOffset, paintContainer); 776 addChildFocusRingRects(rects, additionalOffset, paintContainer);
788 } 777 }
789 778
790 namespace {
791
792 class AbsoluteLayoutRectsGeneratorContext {
793 public:
794 AbsoluteLayoutRectsGeneratorContext(Vector<LayoutRect>& rects, const LayoutP oint& accumulatedOffset)
795 : m_rects(rects)
796 , m_accumulatedOffset(accumulatedOffset) { }
797
798 void operator()(const FloatRect& rect)
799 {
800 LayoutRect layoutRect(rect);
801 layoutRect.move(m_accumulatedOffset.x(), m_accumulatedOffset.y());
802 m_rects.append(layoutRect);
803 }
804 private:
805 Vector<LayoutRect>& m_rects;
806 const LayoutPoint& m_accumulatedOffset;
807 };
808
809 }
810
811 void RenderInline::paintOutline(PaintInfo& paintInfo, const LayoutPoint& paintOf fset)
812 {
813 RenderStyle* styleToUse = style();
814 if (!styleToUse->hasOutline())
815 return;
816
817 if (styleToUse->outlineStyleIsAuto())
818 return;
819
820 if (styleToUse->outlineStyle() == BNONE)
821 return;
822
823 Vector<LayoutRect> rects;
824
825 rects.append(LayoutRect());
826 for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
827 RootInlineBox& root = curr->root();
828 LayoutUnit top = std::max<LayoutUnit>(root.lineTop(), curr->logicalTop() );
829 LayoutUnit bottom = std::min<LayoutUnit>(root.lineBottom(), curr->logica lBottom());
830 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - t op));
831 }
832 rects.append(LayoutRect());
833
834 Color outlineColor = resolveColor(styleToUse, CSSPropertyOutlineColor);
835 bool useTransparencyLayer = outlineColor.hasAlpha();
836
837 GraphicsContext* graphicsContext = paintInfo.context;
838 if (useTransparencyLayer) {
839 graphicsContext->beginTransparencyLayer(static_cast<float>(outlineColor. alpha()) / 255);
840 outlineColor = Color(outlineColor.red(), outlineColor.green(), outlineCo lor.blue());
841 }
842
843 for (unsigned i = 1; i < rects.size() - 1; i++)
844 paintOutlineForLine(graphicsContext, paintOffset, rects.at(i - 1), rects .at(i), rects.at(i + 1), outlineColor);
845
846 if (useTransparencyLayer)
847 graphicsContext->endLayer();
848 }
849
850 void RenderInline::paintOutlineForLine(GraphicsContext* graphicsContext, const L ayoutPoint& paintOffset,
851 const LayoutRect& lastline, const LayoutR ect& thisline, const LayoutRect& nextline,
852 const Color outlineColor)
853 {
854 RenderStyle* styleToUse = style();
855 int outlineWidth = styleToUse->outlineWidth();
856 EBorderStyle outlineStyle = styleToUse->outlineStyle();
857
858 bool antialias = shouldAntialiasLines(graphicsContext);
859
860 int offset = style()->outlineOffset();
861
862 LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - offset, paintOff set.y() + thisline.y() - offset),
863 LayoutSize(thisline.width() + offset, thisline.height() + offset));
864
865 IntRect pixelSnappedBox = pixelSnappedIntRect(box);
866 if (pixelSnappedBox.width() < 0 || pixelSnappedBox.height() < 0)
867 return;
868 IntRect pixelSnappedLastLine = pixelSnappedIntRect(paintOffset.x() + lastlin e.x(), 0, lastline.width(), 0);
869 IntRect pixelSnappedNextLine = pixelSnappedIntRect(paintOffset.x() + nextlin e.x(), 0, nextline.width(), 0);
870
871 // left edge
872 drawLineForBoxSide(graphicsContext,
873 pixelSnappedBox.x() - outlineWidth,
874 pixelSnappedBox.y() - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
875 pixelSnappedBox.x(),
876 pixelSnappedBox.maxY() + (nextline.isEmpty() || thisline.x() <= nextline .x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : 0),
877 BSLeft,
878 outlineColor, outlineStyle,
879 (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth),
880 (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.maxX() - 1) <= thisline.x() ? outlineWidth : -outlineWidth),
881 antialias);
882
883 // right edge
884 drawLineForBoxSide(graphicsContext,
885 pixelSnappedBox.maxX(),
886 pixelSnappedBox.y() - (lastline.isEmpty() || lastline.maxX() < thisline. maxX() || (thisline.maxX() - 1) <= lastline.x() ? outlineWidth : 0),
887 pixelSnappedBox.maxX() + outlineWidth,
888 pixelSnappedBox.maxY() + (nextline.isEmpty() || nextline.maxX() <= thisl ine.maxX() || (thisline.maxX() - 1) <= nextline.x() ? outlineWidth : 0),
889 BSRight,
890 outlineColor, outlineStyle,
891 (lastline.isEmpty() || lastline.maxX() < thisline.maxX() || (thisline.ma xX() - 1) <= lastline.x() ? outlineWidth : -outlineWidth),
892 (nextline.isEmpty() || nextline.maxX() <= thisline.maxX() || (thisline.m axX() - 1) <= nextline.x() ? outlineWidth : -outlineWidth),
893 antialias);
894 // upper edge
895 if (thisline.x() < lastline.x())
896 drawLineForBoxSide(graphicsContext,
897 pixelSnappedBox.x() - outlineWidth,
898 pixelSnappedBox.y() - outlineWidth,
899 std::min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? 1000000 : pixelSnappedLastLine.x())),
900 pixelSnappedBox.y(),
901 BSTop, outlineColor, outlineStyle,
902 outlineWidth,
903 (!lastline.isEmpty() && paintOffset.x() + lastline.x() + 1 < pixelSn appedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth,
904 antialias);
905
906 if (lastline.maxX() < thisline.maxX())
907 drawLineForBoxSide(graphicsContext,
908 std::max(lastline.isEmpty() ? -1000000 : pixelSnappedLastLine.maxX() , pixelSnappedBox.x() - outlineWidth),
909 pixelSnappedBox.y() - outlineWidth,
910 pixelSnappedBox.maxX() + outlineWidth,
911 pixelSnappedBox.y(),
912 BSTop, outlineColor, outlineStyle,
913 (!lastline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOf fset.x() + lastline.maxX()) ? -outlineWidth : outlineWidth,
914 outlineWidth, antialias);
915
916 if (thisline.x() == thisline.maxX())
917 drawLineForBoxSide(graphicsContext,
918 pixelSnappedBox.x() - outlineWidth,
919 pixelSnappedBox.y() - outlineWidth,
920 pixelSnappedBox.maxX() + outlineWidth,
921 pixelSnappedBox.y(),
922 BSTop, outlineColor, outlineStyle,
923 outlineWidth,
924 outlineWidth,
925 antialias);
926
927 // lower edge
928 if (thisline.x() < nextline.x())
929 drawLineForBoxSide(graphicsContext,
930 pixelSnappedBox.x() - outlineWidth,
931 pixelSnappedBox.maxY(),
932 std::min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : 1000000),
933 pixelSnappedBox.maxY() + outlineWidth,
934 BSBottom, outlineColor, outlineStyle,
935 outlineWidth,
936 (!nextline.isEmpty() && paintOffset.x() + nextline.x() + 1 < pixelSn appedBox.maxX() + outlineWidth) ? -outlineWidth : outlineWidth,
937 antialias);
938
939 if (nextline.maxX() < thisline.maxX())
940 drawLineForBoxSide(graphicsContext,
941 std::max(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : -100000 0, pixelSnappedBox.x() - outlineWidth),
942 pixelSnappedBox.maxY(),
943 pixelSnappedBox.maxX() + outlineWidth,
944 pixelSnappedBox.maxY() + outlineWidth,
945 BSBottom, outlineColor, outlineStyle,
946 (!nextline.isEmpty() && pixelSnappedBox.x() - outlineWidth < paintOf fset.x() + nextline.maxX()) ? -outlineWidth : outlineWidth,
947 outlineWidth, antialias);
948
949 if (thisline.x() == thisline.maxX())
950 drawLineForBoxSide(graphicsContext,
951 pixelSnappedBox.x() - outlineWidth,
952 pixelSnappedBox.maxY(),
953 pixelSnappedBox.maxX() + outlineWidth,
954 pixelSnappedBox.maxY() + outlineWidth,
955 BSBottom, outlineColor, outlineStyle,
956 outlineWidth,
957 outlineWidth,
958 antialias);
959 }
960
961 } // namespace blink 779 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698