зеркало из https://github.com/mozilla/gecko-dev.git
Bug 857820 part.1 Drop blink effect implementation r=dbaron
This commit is contained in:
Родитель
f59e63a2d2
Коммит
65e843edc3
|
@ -4,7 +4,7 @@ var testdata = {
|
|||
dummy: "fuel.fuel-test",
|
||||
string: "browser.active_color",
|
||||
integer: "permissions.default.image",
|
||||
boolean: "browser.blink_allowed"
|
||||
boolean: "browser.underline_anchors"
|
||||
};
|
||||
|
||||
function test() {
|
||||
|
@ -91,7 +91,7 @@ function test() {
|
|||
var val = Application.prefs.getValue(testdata.integer, 0);
|
||||
is(val, 1, "Reset existing integer property");
|
||||
|
||||
// PREF: boolean browser.blink_allowed == true
|
||||
// PREF: boolean browser.underline_anchors == true
|
||||
|
||||
// test to see if an existing boolean property exists
|
||||
ok(Application.prefs.has(testdata.boolean), "Check existing boolean property for existence");
|
||||
|
|
|
@ -13,13 +13,6 @@
|
|||
* author sets any. Rules with !important overrule author rules.
|
||||
*/
|
||||
|
||||
/*
|
||||
* example: turn off "blink" element blinking
|
||||
*
|
||||
* blink { text-decoration: none ! important; }
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* example: give all tables a 2px border
|
||||
*
|
||||
|
|
|
@ -37,10 +37,6 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::layout;
|
||||
|
||||
// Prefs-driven control for |text-decoration: blink|
|
||||
static bool sPrefIsLoaded = false;
|
||||
static bool sBlinkIsAllowed = true;
|
||||
|
||||
enum eNormalLineHeightControl {
|
||||
eUninitialized = -1,
|
||||
eNoExternalLeading = 0, // does not include external leading
|
||||
|
@ -1760,30 +1756,6 @@ nsHTMLReflowState::ComputeContainingBlockRectangle(nsPresContext* aPres
|
|||
}
|
||||
}
|
||||
|
||||
// Prefs callback to pick up changes
|
||||
static int
|
||||
PrefsChanged(const char *aPrefName, void *instance)
|
||||
{
|
||||
sBlinkIsAllowed =
|
||||
Preferences::GetBool("browser.blink_allowed", sBlinkIsAllowed);
|
||||
|
||||
return 0; /* PREF_OK */
|
||||
}
|
||||
|
||||
// Check to see if |text-decoration: blink| is allowed. The first time
|
||||
// called, register the callback and then force-load the pref. After that,
|
||||
// just use the cached value.
|
||||
static bool BlinkIsAllowed(void)
|
||||
{
|
||||
if (!sPrefIsLoaded) {
|
||||
// Set up a listener and check the initial value
|
||||
Preferences::RegisterCallback(PrefsChanged, "browser.blink_allowed");
|
||||
PrefsChanged(nullptr, nullptr);
|
||||
sPrefIsLoaded = true;
|
||||
}
|
||||
return sBlinkIsAllowed;
|
||||
}
|
||||
|
||||
static eNormalLineHeightControl GetNormalLineHeightCalcControl(void)
|
||||
{
|
||||
if (sNormalLineHeightControl == eUninitialized) {
|
||||
|
@ -2105,12 +2077,6 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
|
|||
CalculateBlockSideMargins(availableWidth, mComputedWidth, aFrameType);
|
||||
}
|
||||
}
|
||||
// Check for blinking text and permission to display it
|
||||
mFlags.mBlinks = (parentReflowState && parentReflowState->mFlags.mBlinks);
|
||||
if (!mFlags.mBlinks && BlinkIsAllowed()) {
|
||||
const nsStyleTextReset* st = frame->StyleTextReset();
|
||||
mFlags.mBlinks = (st->mTextBlink != NS_STYLE_TEXT_BLINK_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -366,7 +366,6 @@ public:
|
|||
// page? When true, we force something
|
||||
// that's too tall for a page/column to
|
||||
// fit anyway to avoid infinite loops.
|
||||
uint16_t mBlinks:1; // Keep track of text-decoration: blink
|
||||
uint16_t mHasClearance:1; // Block has clearance
|
||||
uint16_t mAssumingHScrollbar:1; // parent frame is an nsIScrollableFrame and it
|
||||
// is assuming a horizontal scrollbar
|
||||
|
|
|
@ -835,7 +835,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||
} else {
|
||||
static_cast<nsTextFrame*>(aFrame)->
|
||||
ReflowText(*this, availableSpaceOnLine, psd->mReflowState->rendContext,
|
||||
psd->mReflowState->mFlags.mBlinks, metrics, aReflowStatus);
|
||||
metrics, aReflowStatus);
|
||||
}
|
||||
|
||||
pfd->mJustificationNumSpaces = mTextJustificationNumSpaces;
|
||||
|
|
|
@ -512,7 +512,7 @@ public:
|
|||
|
||||
// Similar to Reflow(), but for use from nsLineLayout
|
||||
void ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
||||
nsRenderingContext* aRenderingContext, bool aShouldBlink,
|
||||
nsRenderingContext* aRenderingContext,
|
||||
nsHTMLReflowMetrics& aMetrics, nsReflowStatus& aStatus);
|
||||
|
||||
bool IsFloatingFirstLetterChild() const;
|
||||
|
|
|
@ -198,17 +198,15 @@ NS_DECLARE_FRAME_PROPERTY(FontSizeInflationProperty, nullptr)
|
|||
|
||||
#define TEXT_WHITESPACE_FLAGS (TEXT_IS_ONLY_WHITESPACE | \
|
||||
TEXT_ISNOT_ONLY_WHITESPACE)
|
||||
// This bit is set while the frame is registered as a blinking frame.
|
||||
#define TEXT_BLINK_ON NS_FRAME_STATE_BIT(29)
|
||||
|
||||
// Set when this text frame is mentioned in the userdata for mTextRun
|
||||
#define TEXT_IN_TEXTRUN_USER_DATA NS_FRAME_STATE_BIT(30)
|
||||
#define TEXT_IN_TEXTRUN_USER_DATA NS_FRAME_STATE_BIT(29)
|
||||
|
||||
// nsTextFrame.h has
|
||||
// #define TEXT_HAS_NONCOLLAPSED_CHARACTERS NS_FRAME_STATE_BIT(31)
|
||||
// #define TEXT_HAS_NONCOLLAPSED_CHARACTERS NS_FRAME_STATE_BIT(30)
|
||||
|
||||
// nsTextFrame.h has
|
||||
// #define TEXT_FORCE_TRIM_WHITESPACE NS_FRAME_STATE_BIT(32)
|
||||
// #define TEXT_FORCE_TRIM_WHITESPACE NS_FRAME_STATE_BIT(31)
|
||||
|
||||
// Set when this text frame is mentioned in the userdata for the
|
||||
// uninflated textrun property
|
||||
|
@ -3253,178 +3251,6 @@ PropertyProvider::SetupJustificationSpacing()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Helper class for managing blinking text
|
||||
|
||||
class nsBlinkTimer : public nsITimerCallback
|
||||
{
|
||||
public:
|
||||
nsBlinkTimer();
|
||||
virtual ~nsBlinkTimer();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
void AddFrame(nsPresContext* aPresContext, nsIFrame* aFrame);
|
||||
|
||||
bool RemoveFrame(nsIFrame* aFrame);
|
||||
|
||||
int32_t FrameCount();
|
||||
|
||||
void Start();
|
||||
|
||||
void Stop();
|
||||
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
||||
static void AddBlinkFrame(nsPresContext* aPresContext, nsIFrame* aFrame);
|
||||
static void RemoveBlinkFrame(nsIFrame* aFrame);
|
||||
|
||||
static bool GetBlinkIsOff() { return sState == 3; }
|
||||
|
||||
protected:
|
||||
|
||||
struct FrameData {
|
||||
nsPresContext* mPresContext; // pres context associated with the frame
|
||||
nsIFrame* mFrame;
|
||||
|
||||
|
||||
FrameData(nsPresContext* aPresContext,
|
||||
nsIFrame* aFrame)
|
||||
: mPresContext(aPresContext), mFrame(aFrame) {}
|
||||
};
|
||||
|
||||
class FrameDataComparator {
|
||||
public:
|
||||
bool Equals(const FrameData& aTimer, nsIFrame* const& aFrame) const {
|
||||
return aTimer.mFrame == aFrame;
|
||||
}
|
||||
};
|
||||
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
nsTArray<FrameData> mFrames;
|
||||
nsPresContext* mPresContext;
|
||||
|
||||
protected:
|
||||
|
||||
static nsBlinkTimer* sTextBlinker;
|
||||
static uint32_t sState; // 0-2 == on; 3 == off
|
||||
|
||||
};
|
||||
|
||||
nsBlinkTimer* nsBlinkTimer::sTextBlinker = nullptr;
|
||||
uint32_t nsBlinkTimer::sState = 0;
|
||||
|
||||
#ifdef NOISY_BLINK
|
||||
static PRTime gLastTick;
|
||||
#endif
|
||||
|
||||
nsBlinkTimer::nsBlinkTimer()
|
||||
{
|
||||
}
|
||||
|
||||
nsBlinkTimer::~nsBlinkTimer()
|
||||
{
|
||||
Stop();
|
||||
sTextBlinker = nullptr;
|
||||
}
|
||||
|
||||
void nsBlinkTimer::Start()
|
||||
{
|
||||
nsresult rv;
|
||||
mTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||
if (NS_OK == rv) {
|
||||
mTimer->InitWithCallback(this, 250, nsITimer::TYPE_REPEATING_PRECISE_CAN_SKIP);
|
||||
}
|
||||
}
|
||||
|
||||
void nsBlinkTimer::Stop()
|
||||
{
|
||||
if (nullptr != mTimer) {
|
||||
mTimer->Cancel();
|
||||
mTimer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsBlinkTimer, nsITimerCallback)
|
||||
|
||||
void nsBlinkTimer::AddFrame(nsPresContext* aPresContext, nsIFrame* aFrame) {
|
||||
mFrames.AppendElement(FrameData(aPresContext, aFrame));
|
||||
if (1 == mFrames.Length()) {
|
||||
Start();
|
||||
}
|
||||
}
|
||||
|
||||
bool nsBlinkTimer::RemoveFrame(nsIFrame* aFrame) {
|
||||
mFrames.RemoveElement(aFrame, FrameDataComparator());
|
||||
|
||||
if (mFrames.IsEmpty()) {
|
||||
Stop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t nsBlinkTimer::FrameCount() {
|
||||
return int32_t(mFrames.Length());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBlinkTimer::Notify(nsITimer *timer)
|
||||
{
|
||||
// Toggle blink state bit so that text code knows whether or not to
|
||||
// render. All text code shares the same flag so that they all blink
|
||||
// in unison.
|
||||
sState = (sState + 1) % 4;
|
||||
if (sState == 1 || sState == 2)
|
||||
// States 0, 1, and 2 are all the same.
|
||||
return NS_OK;
|
||||
|
||||
#ifdef NOISY_BLINK
|
||||
PRTime now = PR_Now();
|
||||
char buf[50];
|
||||
PRTime delta;
|
||||
delta = now - gLastTick;
|
||||
gLastTick = now;
|
||||
PR_snprintf(buf, sizeof(buf), "%lldusec", delta);
|
||||
printf("%s\n", buf);
|
||||
#endif
|
||||
|
||||
uint32_t n = mFrames.Length();
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
FrameData& frameData = mFrames.ElementAt(i);
|
||||
|
||||
// Determine damaged area and tell view manager to redraw it
|
||||
// blink doesn't blink outline ... I hope
|
||||
frameData.mFrame->InvalidateFrame();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
void nsBlinkTimer::AddBlinkFrame(nsPresContext* aPresContext, nsIFrame* aFrame)
|
||||
{
|
||||
if (!sTextBlinker)
|
||||
{
|
||||
sTextBlinker = new nsBlinkTimer;
|
||||
}
|
||||
|
||||
NS_ADDREF(sTextBlinker);
|
||||
|
||||
sTextBlinker->AddFrame(aPresContext, aFrame);
|
||||
}
|
||||
|
||||
|
||||
// static
|
||||
void nsBlinkTimer::RemoveBlinkFrame(nsIFrame* aFrame)
|
||||
{
|
||||
NS_ASSERTION(sTextBlinker, "Should have blink timer here");
|
||||
|
||||
nsBlinkTimer* blinkTimer = sTextBlinker; // copy so we can call NS_RELEASE on it
|
||||
|
||||
blinkTimer->RemoveFrame(aFrame);
|
||||
NS_RELEASE(blinkTimer);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static nscolor
|
||||
EnsureDifferentColors(nscolor colorA, nscolor colorB)
|
||||
{
|
||||
|
@ -4246,10 +4072,6 @@ NS_IMPL_FRAMEARENA_HELPERS(nsContinuingTextFrame)
|
|||
|
||||
nsTextFrame::~nsTextFrame()
|
||||
{
|
||||
if (0 != (mState & TEXT_BLINK_ON))
|
||||
{
|
||||
nsBlinkTimer::RemoveBlinkFrame(this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4619,10 +4441,6 @@ nsTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||
|
||||
DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame");
|
||||
|
||||
if ((0 != (mState & TEXT_BLINK_ON)) && nsBlinkTimer::GetBlinkIsOff() &&
|
||||
PresContext()->IsDynamic() && !aBuilder->IsForEventDelivery())
|
||||
return;
|
||||
|
||||
aLists.Content()->AppendNewToTop(
|
||||
new (aBuilder) nsDisplayText(aBuilder, this));
|
||||
}
|
||||
|
@ -7629,8 +7447,7 @@ nsTextFrame::Reflow(nsPresContext* aPresContext,
|
|||
}
|
||||
|
||||
ReflowText(*aReflowState.mLineLayout, aReflowState.availableWidth,
|
||||
aReflowState.rendContext, aReflowState.mFlags.mBlinks,
|
||||
aMetrics, aStatus);
|
||||
aReflowState.rendContext, aMetrics, aStatus);
|
||||
|
||||
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
||||
return NS_OK;
|
||||
|
@ -7667,7 +7484,6 @@ private:
|
|||
void
|
||||
nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
||||
nsRenderingContext* aRenderingContext,
|
||||
bool aShouldBlink,
|
||||
nsHTMLReflowMetrics& aMetrics,
|
||||
nsReflowStatus& aStatus)
|
||||
{
|
||||
|
@ -7687,9 +7503,9 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
|||
// Set up flags and clear out state
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Clear out the reflow state flags in mState (without destroying
|
||||
// the TEXT_BLINK_ON bit). We also clear the whitespace flags because this
|
||||
// can change whether the frame maps whitespace-only text or not.
|
||||
// Clear out the reflow state flags in mState. We also clear the whitespace
|
||||
// flags because this can change whether the frame maps whitespace-only text
|
||||
// or not.
|
||||
RemoveStateBits(TEXT_REFLOW_FLAGS | TEXT_WHITESPACE_FLAGS);
|
||||
|
||||
// Temporarily map all possible content while we construct our new textrun.
|
||||
|
@ -7705,19 +7521,6 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
|||
return;
|
||||
}
|
||||
|
||||
if (aShouldBlink) {
|
||||
if (0 == (mState & TEXT_BLINK_ON)) {
|
||||
mState |= TEXT_BLINK_ON;
|
||||
nsBlinkTimer::AddBlinkFrame(presContext, this);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (0 != (mState & TEXT_BLINK_ON)) {
|
||||
mState &= ~TEXT_BLINK_ON;
|
||||
nsBlinkTimer::RemoveBlinkFrame(this);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NOISY_BIDI
|
||||
printf("Reflowed textframe\n");
|
||||
#endif
|
||||
|
|
|
@ -509,10 +509,6 @@ s, strike, del {
|
|||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
blink {
|
||||
text-decoration: blink;
|
||||
}
|
||||
|
||||
big {
|
||||
font-size: larger;
|
||||
}
|
||||
|
|
|
@ -2655,11 +2655,6 @@ nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) co
|
|||
{
|
||||
if (mVerticalAlign == aOther.mVerticalAlign
|
||||
&& mUnicodeBidi == aOther.mUnicodeBidi) {
|
||||
// Reflow for blink changes
|
||||
if (mTextBlink != aOther.mTextBlink) {
|
||||
return NS_STYLE_HINT_REFLOW;
|
||||
}
|
||||
|
||||
uint8_t lineStyle = GetDecorationStyle();
|
||||
uint8_t otherLineStyle = aOther.GetDecorationStyle();
|
||||
if (mTextDecorationLine != aOther.mTextDecorationLine ||
|
||||
|
|
|
@ -112,7 +112,6 @@ pref("browser.anchor_color", "#0000EE");
|
|||
pref("browser.active_color", "#EE0000");
|
||||
pref("browser.visited_color", "#551A8B");
|
||||
pref("browser.underline_anchors", true);
|
||||
pref("browser.blink_allowed", true);
|
||||
pref("browser.enable_automatic_image_resizing", false);
|
||||
pref("browser.enable_click_image_resizing", true);
|
||||
|
||||
|
|
|
@ -13,13 +13,6 @@
|
|||
* author sets any. Rules with !important overrule author rules.
|
||||
*/
|
||||
|
||||
/*
|
||||
* example: turn off "blink" element blinking
|
||||
*
|
||||
* blink { text-decoration: none ! important; }
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* example: give all tables a 2px border
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче