mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 382721 - Part 9: Warn about too large dotted/dashed corner. r=jrmuizel
This commit is contained in:
parent
f56d021842
commit
5fd0e1df86
@ -175,3 +175,6 @@ PESubgridNotSupported=Support for the ‘subgrid’ keyword of CSS Grid is not e
|
||||
PEMoreThanOneGridRepeatAutoFillInNameList=Only one repeat(auto-fill, …) is allowed in a name list for a subgrid.
|
||||
PEMoreThanOneGridRepeatAutoFillFitInTrackList=Only one repeat(auto-fill, …) or repeat(auto-fit, …) is allowed in a track list.
|
||||
PEMoreThanOneGridRepeatTrackSize=Only one track size is allowed inside repeat(auto-fit/auto-fill, …).
|
||||
|
||||
TooLargeDashedRadius=Border radius is too large for ‘dashed’ style (the limit is 100000px). Rendering as solid.
|
||||
TooLargeDottedRadius=Border radius is too large for ‘dotted’ style (the limit is 100000px). Rendering as solid.
|
||||
|
@ -797,7 +797,14 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext,
|
||||
aDrawTarget.FillRect(joinedBorderAreaPx, color);
|
||||
#endif
|
||||
|
||||
nsCSSBorderRenderer br(aPresContext->Type(),
|
||||
nsIDocument* document = nullptr;
|
||||
nsIContent* content = aForFrame->GetContent();
|
||||
if (content) {
|
||||
document = content->OwnerDoc();
|
||||
}
|
||||
|
||||
nsCSSBorderRenderer br(aPresContext,
|
||||
document,
|
||||
&aDrawTarget,
|
||||
dirtyRect,
|
||||
joinedBorderAreaPx,
|
||||
@ -936,9 +943,16 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
|
||||
Float(width / twipsPerPixel) };
|
||||
Rect dirtyRect = NSRectToRect(aDirtyRect, twipsPerPixel);
|
||||
|
||||
nsIDocument* document = nullptr;
|
||||
nsIContent* content = aForFrame->GetContent();
|
||||
if (content) {
|
||||
document = content->OwnerDoc();
|
||||
}
|
||||
|
||||
// start drawing
|
||||
|
||||
nsCSSBorderRenderer br(aPresContext->Type(),
|
||||
nsCSSBorderRenderer br(aPresContext,
|
||||
document,
|
||||
aRenderingContext.GetDrawTarget(),
|
||||
dirtyRect,
|
||||
oRect,
|
||||
@ -986,7 +1000,8 @@ nsCSSRendering::PaintFocus(nsPresContext* aPresContext,
|
||||
// something that CSS can style, this function will then have access
|
||||
// to a style context and can use the same logic that PaintBorder
|
||||
// and PaintOutline do.)
|
||||
nsCSSBorderRenderer br(aPresContext->Type(),
|
||||
nsCSSBorderRenderer br(aPresContext,
|
||||
nullptr,
|
||||
aDrawTarget,
|
||||
focusRect,
|
||||
focusRect,
|
||||
|
@ -16,11 +16,13 @@
|
||||
#include "DottedCornerFinder.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCSSColorUtils.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsExpirationTracker.h"
|
||||
#include "RoundedRect.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsStyleStruct.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "gfx2DGlue.h"
|
||||
@ -162,7 +164,8 @@ typedef enum {
|
||||
CORNER_DOT
|
||||
} CornerStyle;
|
||||
|
||||
nsCSSBorderRenderer::nsCSSBorderRenderer(nsPresContext::nsPresContextType aPresContextType,
|
||||
nsCSSBorderRenderer::nsCSSBorderRenderer(nsPresContext* aPresContext,
|
||||
const nsIDocument* aDocument,
|
||||
DrawTarget* aDrawTarget,
|
||||
const Rect& aDirtyRect,
|
||||
Rect& aOuterRect,
|
||||
@ -172,7 +175,8 @@ nsCSSBorderRenderer::nsCSSBorderRenderer(nsPresContext::nsPresContextType aPresC
|
||||
const nscolor* aBorderColors,
|
||||
nsBorderColors* const* aCompositeColors,
|
||||
nscolor aBackgroundColor)
|
||||
: mPresContextType(aPresContextType),
|
||||
: mPresContext(aPresContext),
|
||||
mDocument(aDocument),
|
||||
mDrawTarget(aDrawTarget),
|
||||
mDirtyRect(aDirtyRect),
|
||||
mOuterRect(aOuterRect),
|
||||
@ -2465,6 +2469,19 @@ nsCSSBorderRenderer::DrawFallbackSolidCorner(mozilla::css::Side aSide,
|
||||
|
||||
RefPtr<Path> path = builder->Finish();
|
||||
mDrawTarget->Fill(path, ColorPattern(ToDeviceColor(borderColor)));
|
||||
|
||||
if (mDocument) {
|
||||
if (!mPresContext->HasWarnedAboutTooLargeDashedOrDottedRadius()) {
|
||||
mPresContext->SetHasWarnedAboutTooLargeDashedOrDottedRadius();
|
||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
||||
NS_LITERAL_CSTRING("CSS"),
|
||||
mDocument,
|
||||
nsContentUtils::eCSS_PROPERTIES,
|
||||
mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED
|
||||
? "TooLargeDashedRadius"
|
||||
: "TooLargeDottedRadius");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2910,7 +2927,7 @@ nsCSSBorderRenderer::DrawNoCompositeColorSolidBorder()
|
||||
Float skirtSize = 0.0f, skirtSlope = 0.0f;
|
||||
// the sides don't match, so compute a skirt
|
||||
if (firstColor != secondColor &&
|
||||
mPresContextType != nsPresContext::eContext_Print) {
|
||||
mPresContext->Type() != nsPresContext::eContext_Print) {
|
||||
Point cornerDir = outerCorner - innerCorner;
|
||||
ComputeCornerSkirtSize(firstColor.a, secondColor.a,
|
||||
cornerDir.DotProduct(cornerMults[i]),
|
||||
|
@ -60,6 +60,9 @@ typedef enum {
|
||||
BorderColorStyleDark
|
||||
} BorderColorStyle;
|
||||
|
||||
class nsIDocument;
|
||||
class nsPresContext;
|
||||
|
||||
class nsCSSBorderRenderer final
|
||||
{
|
||||
typedef mozilla::gfx::Bezier Bezier;
|
||||
@ -74,7 +77,8 @@ class nsCSSBorderRenderer final
|
||||
|
||||
public:
|
||||
|
||||
nsCSSBorderRenderer(nsPresContext::nsPresContextType aPresContextType,
|
||||
nsCSSBorderRenderer(nsPresContext* aPresContext,
|
||||
const nsIDocument* aDocument,
|
||||
DrawTarget* aDrawTarget,
|
||||
const Rect& aDirtyRect,
|
||||
Rect& aOuterRect,
|
||||
@ -105,8 +109,9 @@ private:
|
||||
|
||||
RectCornerRadii mBorderCornerDimensions;
|
||||
|
||||
// the PresContext type
|
||||
nsPresContext::nsPresContextType mPresContextType;
|
||||
// Target document to report warning
|
||||
nsPresContext* mPresContext;
|
||||
const nsIDocument* mDocument;
|
||||
|
||||
// destination DrawTarget and dirty rect
|
||||
DrawTarget* mDrawTarget;
|
||||
|
@ -1093,6 +1093,14 @@ public:
|
||||
mHasWarnedAboutPositionedTableParts = true;
|
||||
}
|
||||
|
||||
bool HasWarnedAboutTooLargeDashedOrDottedRadius() const {
|
||||
return mHasWarnedAboutTooLargeDashedOrDottedRadius;
|
||||
}
|
||||
|
||||
void SetHasWarnedAboutTooLargeDashedOrDottedRadius() {
|
||||
mHasWarnedAboutTooLargeDashedOrDottedRadius = true;
|
||||
}
|
||||
|
||||
static bool StyloEnabled()
|
||||
{
|
||||
// Stylo (the Servo backend for Gecko's style system) is generally enabled
|
||||
@ -1382,6 +1390,8 @@ protected:
|
||||
|
||||
unsigned mHasWarnedAboutPositionedTableParts : 1;
|
||||
|
||||
unsigned mHasWarnedAboutTooLargeDashedOrDottedRadius : 1;
|
||||
|
||||
// Have we added quirk.css to the style set?
|
||||
unsigned mQuirkSheetAdded : 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user