Nothing Special   »   [go: up one dir, main page]

Attachment #431535: patch 10: draw 'outline-color' using the visited-dependent style for bug #147777

View | Details | Raw Unified | Return to bug 147777
Collapse All | Expand All

(-)a/layout/base/nsCSSRendering.cpp (-11 / +9 lines)
Line     Link Here 
 Lines 715-754   GetOutlineInnerRect(nsIFrame* aFrame) Link Here 
715
}
715
}
716
716
717
void
717
void
718
nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
718
nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
719
                             nsIRenderingContext& aRenderingContext,
719
                             nsIRenderingContext& aRenderingContext,
720
                             nsIFrame* aForFrame,
720
                             nsIFrame* aForFrame,
721
                             const nsRect& aDirtyRect,
721
                             const nsRect& aDirtyRect,
722
                             const nsRect& aBorderArea,
722
                             const nsRect& aBorderArea,
723
                             const nsStyleBorder& aStyleBorder,
724
                             const nsStyleOutline& aOutlineStyle,
725
                             nsStyleContext* aStyleContext)
723
                             nsStyleContext* aStyleContext)
726
{
724
{
727
  nscoord             twipsRadii[8];
725
  nscoord             twipsRadii[8];
728
726
729
  // Get our style context's color struct.
727
  // Get our style context's color struct.
730
  const nsStyleColor* ourColor = aStyleContext->GetStyleColor();
728
  const nsStyleColor* ourColor = aStyleContext->GetStyleColor();
729
  const nsStyleOutline* ourOutline = aStyleContext->GetStyleOutline();
731
730
732
  nscoord width;
731
  nscoord width;
733
  aOutlineStyle.GetOutlineWidth(width);
732
  ourOutline->GetOutlineWidth(width);
734
733
735
  if (width == 0) {
734
  if (width == 0) {
736
    // Empty outline
735
    // Empty outline
737
    return;
736
    return;
738
  }
737
  }
739
738
740
  nsStyleContext* bgContext = nsCSSRendering::FindNonTransparentBackground
739
  nsStyleContext* bgContext = nsCSSRendering::FindNonTransparentBackground
741
    (aStyleContext, PR_FALSE);
740
    (aStyleContext, PR_FALSE);
742
  nscolor bgColor =
741
  nscolor bgColor =
743
    bgContext->GetVisitedDependentColor(eCSSProperty_background_color);
742
    bgContext->GetVisitedDependentColor(eCSSProperty_background_color);
744
743
745
  // get the radius for our outline
744
  // get the radius for our outline
746
  GetBorderRadiusTwips(aOutlineStyle.mOutlineRadius, aBorderArea.width,
745
  GetBorderRadiusTwips(ourOutline->mOutlineRadius, aBorderArea.width,
747
                       twipsRadii);
746
                       twipsRadii);
748
747
749
  // When the outline property is set on :-moz-anonymous-block or
748
  // When the outline property is set on :-moz-anonymous-block or
750
  // :-moz-anonyomus-positioned-block pseudo-elements, it inherited that
749
  // :-moz-anonyomus-positioned-block pseudo-elements, it inherited that
751
  // outline from the inline that was broken because it contained a
750
  // outline from the inline that was broken because it contained a
752
  // block.  In that case, we don't want a really wide outline if the
751
  // block.  In that case, we don't want a really wide outline if the
753
  // block inside the inline is narrow, so union the actual contents of
752
  // block inside the inline is narrow, so union the actual contents of
754
  // the anonymous blocks.
753
  // the anonymous blocks.
 Lines 773-789   nsCSSRendering::PaintOutline(nsPresConte Link Here 
773
      // the border.
772
      // the border.
774
      nsRect r(GetOutlineInnerRect(frameForArea) +
773
      nsRect r(GetOutlineInnerRect(frameForArea) +
775
               frameForArea->GetOffsetTo(aForFrame));
774
               frameForArea->GetOffsetTo(aForFrame));
776
      innerRect.UnionRect(innerRect, r);
775
      innerRect.UnionRect(innerRect, r);
777
    }
776
    }
778
  }
777
  }
779
778
780
  innerRect += aBorderArea.TopLeft();
779
  innerRect += aBorderArea.TopLeft();
781
  nscoord offset = aOutlineStyle.mOutlineOffset;
780
  nscoord offset = ourOutline->mOutlineOffset;
782
  innerRect.Inflate(offset, offset);
781
  innerRect.Inflate(offset, offset);
783
  // If the dirty rect is completely inside the border area (e.g., only the
782
  // If the dirty rect is completely inside the border area (e.g., only the
784
  // content is being painted), then we can skip out now
783
  // content is being painted), then we can skip out now
785
  // XXX this isn't exactly true for rounded borders, where the inside curves may
784
  // XXX this isn't exactly true for rounded borders, where the inside curves may
786
  // encroach into the content area.  A safer calculation would be to
785
  // encroach into the content area.  A safer calculation would be to
787
  // shorten insideRect by the radius one each side before performing this test.
786
  // shorten insideRect by the radius one each side before performing this test.
788
  if (innerRect.Contains(aDirtyRect))
787
  if (innerRect.Contains(aDirtyRect))
789
    return;
788
    return;
 Lines 798-824   nsCSSRendering::PaintOutline(nsPresConte Link Here 
798
  gfxRect oRect(RectToGfxRect(outerRect, twipsPerPixel));
797
  gfxRect oRect(RectToGfxRect(outerRect, twipsPerPixel));
799
798
800
  // convert the radii
799
  // convert the radii
801
  nsMargin outlineMargin(width, width, width, width);
800
  nsMargin outlineMargin(width, width, width, width);
802
  gfxCornerSizes outlineRadii;
801
  gfxCornerSizes outlineRadii;
803
  ComputePixelRadii(twipsRadii, outerRect, 0, twipsPerPixel,
802
  ComputePixelRadii(twipsRadii, outerRect, 0, twipsPerPixel,
804
                    &outlineRadii);
803
                    &outlineRadii);
805
804
806
  PRUint8 outlineStyle = aOutlineStyle.GetOutlineStyle();
805
  PRUint8 outlineStyle = ourOutline->GetOutlineStyle();
807
  PRUint8 outlineStyles[4] = { outlineStyle,
806
  PRUint8 outlineStyles[4] = { outlineStyle,
808
                               outlineStyle,
807
                               outlineStyle,
809
                               outlineStyle,
808
                               outlineStyle,
810
                               outlineStyle };
809
                               outlineStyle };
811
810
812
  nscolor outlineColor;
811
  // This handles treating the initial color as 'currentColor'; if we
813
  // PR_FALSE means use the initial color; PR_TRUE means a color was
812
  // ever want 'invert' back we'll need to do a bit of work here too.
814
  // set.
813
  nscolor outlineColor =
815
  if (!aOutlineStyle.GetOutlineColor(outlineColor))
814
    aStyleContext->GetVisitedDependentColor(eCSSProperty_outline_color);
816
    outlineColor = ourColor->mColor;
817
  nscolor outlineColors[4] = { outlineColor,
815
  nscolor outlineColors[4] = { outlineColor,
818
                               outlineColor,
816
                               outlineColor,
819
                               outlineColor,
817
                               outlineColor,
820
                               outlineColor };
818
                               outlineColor };
821
819
822
  // convert the border widths
820
  // convert the border widths
823
  gfxFloat outlineWidths[4] = { width / twipsPerPixel,
821
  gfxFloat outlineWidths[4] = { width / twipsPerPixel,
824
                                width / twipsPerPixel,
822
                                width / twipsPerPixel,
(-)a/layout/base/nsCSSRendering.h (-2 lines)
Line     Link Here 
 Lines 120-137   struct nsCSSRendering { Link Here 
120
   * Both aDirtyRect and aBorderArea are in the local coordinate space
120
   * Both aDirtyRect and aBorderArea are in the local coordinate space
121
   * of aForFrame
121
   * of aForFrame
122
   */
122
   */
123
  static void PaintOutline(nsPresContext* aPresContext,
123
  static void PaintOutline(nsPresContext* aPresContext,
124
                          nsIRenderingContext& aRenderingContext,
124
                          nsIRenderingContext& aRenderingContext,
125
                          nsIFrame* aForFrame,
125
                          nsIFrame* aForFrame,
126
                          const nsRect& aDirtyRect,
126
                          const nsRect& aDirtyRect,
127
                          const nsRect& aBorderArea,
127
                          const nsRect& aBorderArea,
128
                          const nsStyleBorder& aBorderStyle,
129
                          const nsStyleOutline& aOutlineStyle,
130
                          nsStyleContext* aStyleContext);
128
                          nsStyleContext* aStyleContext);
131
129
132
  /**
130
  /**
133
   * Render keyboard focus on an element.
131
   * Render keyboard focus on an element.
134
   * |aFocusRect| is the outer rectangle of the focused element.
132
   * |aFocusRect| is the outer rectangle of the focused element.
135
   * Uses a fixed style equivalent to "1px dotted |aColor|".
133
   * Uses a fixed style equivalent to "1px dotted |aColor|".
136
   * Not used for controls, because the native theme may differ.
134
   * Not used for controls, because the native theme may differ.
137
   */
135
   */
(-)a/layout/base/nsDisplayList.cpp (-2 lines)
Line     Link Here 
 Lines 1162-1179   nsDisplayOutline::GetBounds(nsDisplayLis Link Here 
1162
void
1162
void
1163
nsDisplayOutline::Paint(nsDisplayListBuilder* aBuilder,
1163
nsDisplayOutline::Paint(nsDisplayListBuilder* aBuilder,
1164
                        nsIRenderingContext* aCtx) {
1164
                        nsIRenderingContext* aCtx) {
1165
  // TODO join outlines together
1165
  // TODO join outlines together
1166
  nsPoint offset = aBuilder->ToReferenceFrame(mFrame);
1166
  nsPoint offset = aBuilder->ToReferenceFrame(mFrame);
1167
  nsCSSRendering::PaintOutline(mFrame->PresContext(), *aCtx, mFrame,
1167
  nsCSSRendering::PaintOutline(mFrame->PresContext(), *aCtx, mFrame,
1168
                               mVisibleRect,
1168
                               mVisibleRect,
1169
                               nsRect(offset, mFrame->GetSize()),
1169
                               nsRect(offset, mFrame->GetSize()),
1170
                               *mFrame->GetStyleBorder(),
1171
                               *mFrame->GetStyleOutline(),
1172
                               mFrame->GetStyleContext());
1170
                               mFrame->GetStyleContext());
1173
}
1171
}
1174
1172
1175
PRBool
1173
PRBool
1176
nsDisplayOutline::ComputeVisibility(nsDisplayListBuilder* aBuilder,
1174
nsDisplayOutline::ComputeVisibility(nsDisplayListBuilder* aBuilder,
1177
                                    nsRegion* aVisibleRegion,
1175
                                    nsRegion* aVisibleRegion,
1178
                                    nsRegion* aVisibleRegionBeforeMove) {
1176
                                    nsRegion* aVisibleRegionBeforeMove) {
1179
  NS_ASSERTION((aVisibleRegionBeforeMove != nsnull) == aBuilder->HasMovingFrames(),
1177
  NS_ASSERTION((aVisibleRegionBeforeMove != nsnull) == aBuilder->HasMovingFrames(),
(-)a/layout/mathml/nsMathMLChar.cpp (-2 / +1 lines)
Line     Link Here 
 Lines 2005-2022   void nsDisplayMathMLCharDebug::Paint(nsD Link Here 
2005
  PRIntn skipSides = 0;
2005
  PRIntn skipSides = 0;
2006
  nsPresContext* presContext = mFrame->PresContext();
2006
  nsPresContext* presContext = mFrame->PresContext();
2007
  const nsStyleBorder* border = mFrame->GetStyleBorder();
2007
  const nsStyleBorder* border = mFrame->GetStyleBorder();
2008
  nsStyleContext* styleContext = mFrame->GetStyleContext();
2008
  nsStyleContext* styleContext = mFrame->GetStyleContext();
2009
  nsRect rect = mRect + aBuilder->ToReferenceFrame(mFrame);
2009
  nsRect rect = mRect + aBuilder->ToReferenceFrame(mFrame);
2010
  nsCSSRendering::PaintBorder(presContext, *aCtx, mFrame,
2010
  nsCSSRendering::PaintBorder(presContext, *aCtx, mFrame,
2011
                              mVisibleRect, rect, styleContext, skipSides);
2011
                              mVisibleRect, rect, styleContext, skipSides);
2012
  nsCSSRendering::PaintOutline(presContext, *aCtx, mFrame,
2012
  nsCSSRendering::PaintOutline(presContext, *aCtx, mFrame,
2013
                               mVisibleRect, rect, *border,
2013
                               mVisibleRect, rect, styleContext);
2014
                               *mFrame->GetStyleOutline(), styleContext);
2015
}
2014
}
2016
#endif
2015
#endif
2017
2016
2018
2017
2019
nsresult
2018
nsresult
2020
nsMathMLChar::Display(nsDisplayListBuilder*   aBuilder,
2019
nsMathMLChar::Display(nsDisplayListBuilder*   aBuilder,
2021
                      nsIFrame*               aForFrame,
2020
                      nsIFrame*               aForFrame,
2022
                      const nsDisplayListSet& aLists,
2021
                      const nsDisplayListSet& aLists,
(-)a/layout/style/nsStyleAnimation.cpp (+2 lines)
Line     Link Here 
 Lines 1354-1369   nsStyleAnimation::ExtractComputedValue(n Link Here 
1354
                             aComputedValue);
1354
                             aComputedValue);
1355
          break;
1355
          break;
1356
1356
1357
        case eCSSProperty_outline_color: {
1357
        case eCSSProperty_outline_color: {
1358
          const nsStyleOutline *styleOutline =
1358
          const nsStyleOutline *styleOutline =
1359
            static_cast<const nsStyleOutline*>(styleStruct);
1359
            static_cast<const nsStyleOutline*>(styleStruct);
1360
          nscolor color;
1360
          nscolor color;
1361
        #ifdef GFX_HAS_INVERT
1361
        #ifdef GFX_HAS_INVERT
1362
          // This isn't right.  And note that outline drawing itself
1363
          // goes through this codepath via GetVisitedDependentColor.
1362
          styleOutline->GetOutlineColor(color);
1364
          styleOutline->GetOutlineColor(color);
1363
        #else
1365
        #else
1364
          if (!styleOutline->GetOutlineColor(color))
1366
          if (!styleOutline->GetOutlineColor(color))
1365
            color = aStyleContext->GetStyleColor()->mColor;
1367
            color = aStyleContext->GetStyleColor()->mColor;
1366
        #endif
1368
        #endif
1367
          aComputedValue.SetColorValue(color);
1369
          aComputedValue.SetColorValue(color);
1368
          break;
1370
          break;
1369
        }
1371
        }
(-)a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp (-4 / +2 lines)
Line     Link Here 
 Lines 3897-3926   nsTreeBodyFrame::PaintDropFeedback(const Link Here 
3897
void
3897
void
3898
nsTreeBodyFrame::PaintBackgroundLayer(nsStyleContext*      aStyleContext,
3898
nsTreeBodyFrame::PaintBackgroundLayer(nsStyleContext*      aStyleContext,
3899
                                      nsPresContext*      aPresContext,
3899
                                      nsPresContext*      aPresContext,
3900
                                      nsIRenderingContext& aRenderingContext,
3900
                                      nsIRenderingContext& aRenderingContext,
3901
                                      const nsRect&        aRect,
3901
                                      const nsRect&        aRect,
3902
                                      const nsRect&        aDirtyRect)
3902
                                      const nsRect&        aDirtyRect)
3903
{
3903
{
3904
  const nsStyleBorder* myBorder = aStyleContext->GetStyleBorder();
3904
  const nsStyleBorder* myBorder = aStyleContext->GetStyleBorder();
3905
  const nsStyleOutline* myOutline = aStyleContext->GetStyleOutline();
3905
3906
  
3907
  nsCSSRendering::PaintBackgroundWithSC(aPresContext, aRenderingContext,
3906
  nsCSSRendering::PaintBackgroundWithSC(aPresContext, aRenderingContext,
3908
                                        this, aDirtyRect, aRect,
3907
                                        this, aDirtyRect, aRect,
3909
                                        aStyleContext, *myBorder,
3908
                                        aStyleContext, *myBorder,
3910
                                        nsCSSRendering::PAINTBG_SYNC_DECODE_IMAGES);
3909
                                        nsCSSRendering::PAINTBG_SYNC_DECODE_IMAGES);
3911
3910
3912
  nsCSSRendering::PaintBorderWithStyleBorder(aPresContext, aRenderingContext,
3911
  nsCSSRendering::PaintBorderWithStyleBorder(aPresContext, aRenderingContext,
3913
                                             this, aDirtyRect, aRect,
3912
                                             this, aDirtyRect, aRect,
3914
                                             *myBorder, mStyleContext);
3913
                                             *myBorder, mStyleContext);
3915
3914
3916
  nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
3915
  nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
3917
                               aDirtyRect, aRect, *myBorder, *myOutline,
3916
                               aDirtyRect, aRect, aStyleContext);
3918
                               aStyleContext);
3919
}
3917
}
3920
3918
3921
// Scrolling
3919
// Scrolling
3922
nsresult
3920
nsresult
3923
nsTreeBodyFrame::EnsureRowIsVisible(PRInt32 aRow)
3921
nsTreeBodyFrame::EnsureRowIsVisible(PRInt32 aRow)
3924
{
3922
{
3925
  ScrollParts parts = GetScrollParts();
3923
  ScrollParts parts = GetScrollParts();
3926
  nsresult rv = EnsureRowIsVisibleInternal(parts, aRow);
3924
  nsresult rv = EnsureRowIsVisibleInternal(parts, aRow);

Return to bug 147777