Bug 1457719 - Part 4 - Remove the "autorepeatbutton" element. r=bz

The DoMouseClick helper is also removed because no other caller can now pass a null aEvent. Other MouseClicked implementations are also updated since aEvent cannot be null, which was already the case.

MozReview-Commit-ID: 3bTJ6cZW9ZA

--HG--
extra : rebase_source : ae1bafe7144f6f428e2ef4e7047d5c64e0a19e8c
This commit is contained in:
Paolo Amadini 2018-06-01 11:15:56 +01:00
parent ff86c8779d
commit 61cbbdb92c
17 changed files with 23 additions and 291 deletions

View File

@ -1547,7 +1547,7 @@ nsXBLPrototypeBinding::WriteNamespace(nsIObjectOutputStream* aStream,
bool CheckTagNameWhiteList(int32_t aNameSpaceID, nsAtom *aTagName)
{
static Element::AttrValuesArray kValidXULTagNames[] = {
&nsGkAtoms::autorepeatbutton, &nsGkAtoms::box, &nsGkAtoms::browser,
&nsGkAtoms::box, &nsGkAtoms::browser,
&nsGkAtoms::button, &nsGkAtoms::hbox, &nsGkAtoms::image, &nsGkAtoms::menu,
&nsGkAtoms::menubar, &nsGkAtoms::menuitem, &nsGkAtoms::menupopup,
&nsGkAtoms::row, &nsGkAtoms::slider, &nsGkAtoms::spacer,

View File

@ -237,7 +237,6 @@ GetClickableAncestor(nsIFrame* aFrame, nsAtom* stopAt = nullptr, nsAutoString* a
if (content->IsAnyOfXULElements(nsGkAtoms::button,
nsGkAtoms::checkbox,
nsGkAtoms::radio,
nsGkAtoms::autorepeatbutton,
nsGkAtoms::menu,
nsGkAtoms::menubutton,
nsGkAtoms::menuitem,

View File

@ -234,9 +234,6 @@ static FrameCtorDebugFlags gFlags[] = {
//------------------------------------------------------------------
nsIFrame*
NS_NewAutoRepeatBoxFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle);
nsContainerFrame*
NS_NewRootBoxFrame (nsIPresShell* aPresShell, ComputedStyle* aStyle);
@ -4292,7 +4289,6 @@ nsCSSFrameConstructor::FindXULTagData(Element* aElement,
SCROLLABLE_XUL_CREATE(thumb, NS_NewButtonBoxFrame),
SCROLLABLE_XUL_CREATE(checkbox, NS_NewButtonBoxFrame),
SCROLLABLE_XUL_CREATE(radio, NS_NewButtonBoxFrame),
SCROLLABLE_XUL_CREATE(autorepeatbutton, NS_NewAutoRepeatBoxFrame),
SCROLLABLE_XUL_CREATE(titlebar, NS_NewTitleBarFrame),
SCROLLABLE_XUL_CREATE(resizer, NS_NewResizerFrame),
SCROLLABLE_XUL_CREATE(toolbarpaletteitem, NS_NewBoxFrame),

View File

@ -6,7 +6,6 @@
FRAME_ID(BRFrame, Br, Leaf)
FRAME_ID(DetailsFrame, Details, NotLeaf)
FRAME_ID(nsAutoRepeatBoxFrame, Box, NotLeaf)
FRAME_ID(nsBCTableCellFrame, BCTableCell, NotLeaf)
FRAME_ID(nsBackdropFrame, Backdrop, Leaf)
FRAME_ID(nsBlockFrame, Block, NotLeaf)

View File

@ -1,3 +0,0 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="document.getElementById('label').control='c';">
<label id="label"><hbox><listboxbody><hbox/><tooltip/></listboxbody><autorepeatbutton/></hbox></label>
</window>

View File

@ -74,7 +74,6 @@ load 432068-2.xul
load 433296-1.xul
load 433429.xul
load 452185.html
load 460900-1.xul
load 464149-1.xul
asserts(0-1) load 464407-1.xhtml # Bugs 450974, 1267054, 718883
load 467080.xul

View File

@ -49,7 +49,6 @@ UNIFIED_SOURCES += [
'nsRootBoxFrame.cpp',
'nsScrollbarButtonFrame.cpp',
'nsScrollbarFrame.cpp',
'nsScrollBoxFrame.cpp',
'nsSliderFrame.cpp',
'nsSprocketLayout.cpp',
'nsStackFrame.cpp',

View File

@ -197,40 +197,25 @@ nsButtonBoxFrame::Blurred()
}
void
nsButtonBoxFrame::DoMouseClick(WidgetGUIEvent* aEvent, bool aTrustEvent)
nsButtonBoxFrame::MouseClicked(WidgetGUIEvent* aEvent)
{
// Don't execute if we're disabled.
if (mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
nsGkAtoms::_true, eCaseMatters))
return;
// Execute the oncommand event handler.
bool isShift = false;
bool isControl = false;
bool isAlt = false;
bool isMeta = false;
uint16_t inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
if(aEvent) {
WidgetInputEvent* inputEvent = aEvent->AsInputEvent();
isShift = inputEvent->IsShift();
isControl = inputEvent->IsControl();
isAlt = inputEvent->IsAlt();
isMeta = inputEvent->IsMeta();
WidgetMouseEventBase* mouseEvent = aEvent->AsMouseEventBase();
if (mouseEvent) {
inputSource = mouseEvent->inputSource;
}
}
// Have the content handle the event, propagating it according to normal DOM rules.
nsCOMPtr<nsIPresShell> shell = PresContext()->GetPresShell();
if (shell) {
nsContentUtils::DispatchXULCommand(mContent,
aEvent ?
aEvent->IsTrusted() : aTrustEvent,
nullptr, shell,
isControl, isAlt, isShift, isMeta, inputSource);
}
if (!shell)
return;
// Execute the oncommand event handler.
WidgetInputEvent* inputEvent = aEvent->AsInputEvent();
WidgetMouseEventBase* mouseEvent = aEvent->AsMouseEventBase();
nsContentUtils::DispatchXULCommand(mContent, aEvent->IsTrusted(), nullptr,
shell, inputEvent->IsControl(),
inputEvent->IsAlt(), inputEvent->IsShift(),
inputEvent->IsMeta(),
mouseEvent ? mouseEvent->inputSource
: MouseEventBinding::MOZ_SOURCE_UNKNOWN);
}

View File

@ -32,8 +32,7 @@ public:
mozilla::WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus) override;
virtual void MouseClicked(mozilla::WidgetGUIEvent* aEvent)
{ DoMouseClick(aEvent, false); }
virtual void MouseClicked(mozilla::WidgetGUIEvent* aEvent);
void Blurred();
@ -43,11 +42,6 @@ public:
}
#endif
/**
* Our implementation of MouseClicked.
* @param aTrustEvent if true and aEvent as null, then assume the event was trusted
*/
void DoMouseClick(mozilla::WidgetGUIEvent* aEvent, bool aTrustEvent);
void UpdateMouseThrough() override { AddStateBits(NS_FRAME_MOUSE_THROUGH_NEVER); }
private:

View File

@ -535,23 +535,9 @@ nsResizerFrame::GetDirection()
void
nsResizerFrame::MouseClicked(WidgetMouseEvent* aEvent)
{
bool isTrusted = false;
bool isShift = false;
bool isControl = false;
bool isAlt = false;
bool isMeta = false;
uint16_t inputSource = dom::MouseEventBinding::MOZ_SOURCE_UNKNOWN;
if(aEvent) {
isShift = aEvent->IsShift();
isControl = aEvent->IsControl();
isAlt = aEvent->IsAlt();
isMeta = aEvent->IsMeta();
inputSource = aEvent->inputSource;
}
// Execute the oncommand event handler.
nsContentUtils::DispatchXULCommand(mContent, isTrusted, nullptr,
nullptr, isControl, isAlt,
isShift, isMeta, inputSource);
nsContentUtils::DispatchXULCommand(mContent, false, nullptr,
nullptr, aEvent->IsControl(),
aEvent->IsAlt(), aEvent->IsShift(),
aEvent->IsMeta(), aEvent->inputSource);
}

View File

@ -1,184 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsCOMPtr.h"
#include "nsPresContext.h"
#include "nsGkAtoms.h"
#include "nsButtonBoxFrame.h"
#include "nsITimer.h"
#include "nsRepeatService.h"
#include "mozilla/MouseEvents.h"
#include "nsIContent.h"
using namespace mozilla;
class nsAutoRepeatBoxFrame final : public nsButtonBoxFrame
{
public:
NS_DECL_FRAMEARENA_HELPERS(nsAutoRepeatBoxFrame)
friend nsIFrame* NS_NewAutoRepeatBoxFrame(nsIPresShell* aPresShell,
ComputedStyle* aStyle);
virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override;
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
nsAtom* aAttribute,
int32_t aModType) override;
virtual nsresult HandleEvent(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus) override;
NS_IMETHOD HandlePress(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus) override;
NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus) override;
protected:
explicit nsAutoRepeatBoxFrame(ComputedStyle* aStyle):
nsButtonBoxFrame(aStyle, kClassID) {}
void StartRepeat() {
if (IsActivatedOnHover()) {
// No initial delay on hover.
nsRepeatService::GetInstance()->Start(Notify, this,
mContent->OwnerDoc(),
NS_LITERAL_CSTRING("DoMouseClick"),
0);
} else {
nsRepeatService::GetInstance()->Start(Notify, this,
mContent->OwnerDoc(),
NS_LITERAL_CSTRING("DoMouseClick"));
}
}
void StopRepeat() {
nsRepeatService::GetInstance()->Stop(Notify, this);
}
void Notify();
static void Notify(void* aData) {
static_cast<nsAutoRepeatBoxFrame*>(aData)->Notify();
}
bool mTrustedEvent;
bool IsActivatedOnHover();
};
nsIFrame*
NS_NewAutoRepeatBoxFrame (nsIPresShell* aPresShell, ComputedStyle* aStyle)
{
return new (aPresShell) nsAutoRepeatBoxFrame(aStyle);
}
NS_IMPL_FRAMEARENA_HELPERS(nsAutoRepeatBoxFrame)
nsresult
nsAutoRepeatBoxFrame::HandleEvent(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
NS_ENSURE_ARG_POINTER(aEventStatus);
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
return NS_OK;
}
switch(aEvent->mMessage) {
// repeat mode may be "hover" for repeating while the mouse is hovering
// over the element, otherwise repetition is done while the element is
// active (pressed).
case eMouseEnterIntoWidget:
case eMouseOver:
if (IsActivatedOnHover()) {
StartRepeat();
mTrustedEvent = aEvent->IsTrusted();
}
break;
case eMouseExitFromWidget:
case eMouseOut:
// always stop on mouse exit
StopRepeat();
// Not really necessary but do this to be safe
mTrustedEvent = false;
break;
case eMouseClick: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->IsLeftClickEvent()) {
// skip button frame handling to prevent click handling
return nsBoxFrame::HandleEvent(aPresContext, mouseEvent, aEventStatus);
}
break;
}
default:
break;
}
return nsButtonBoxFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
NS_IMETHODIMP
nsAutoRepeatBoxFrame::HandlePress(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
if (!IsActivatedOnHover()) {
StartRepeat();
mTrustedEvent = aEvent->IsTrusted();
DoMouseClick(aEvent, mTrustedEvent);
}
return NS_OK;
}
NS_IMETHODIMP
nsAutoRepeatBoxFrame::HandleRelease(nsPresContext* aPresContext,
WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
if (!IsActivatedOnHover()) {
StopRepeat();
}
return NS_OK;
}
nsresult
nsAutoRepeatBoxFrame::AttributeChanged(int32_t aNameSpaceID,
nsAtom* aAttribute,
int32_t aModType)
{
if (aAttribute == nsGkAtoms::type) {
StopRepeat();
}
return NS_OK;
}
void
nsAutoRepeatBoxFrame::Notify()
{
DoMouseClick(nullptr, mTrustedEvent);
}
void
nsAutoRepeatBoxFrame::DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData)
{
// Ensure our repeat service isn't going... it's possible that a scrollbar can disappear out
// from under you while you're in the process of scrolling.
StopRepeat();
nsButtonBoxFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
}
bool
nsAutoRepeatBoxFrame::IsActivatedOnHover()
{
return mContent->AsElement()->AttrValueIs(
kNameSpaceID_None, nsGkAtoms::repeat, nsGkAtoms::hover, eCaseMatters);
}

View File

@ -225,13 +225,6 @@ void nsScrollbarButtonFrame::Notify()
}
}
void
nsScrollbarButtonFrame::MouseClicked(WidgetGUIEvent* aEvent)
{
nsButtonBoxFrame::MouseClicked(aEvent);
//MouseClicked();
}
nsresult
nsScrollbarButtonFrame::GetChildWithTag(nsAtom* atom, nsIFrame* start,
nsIFrame*& result)

View File

@ -63,8 +63,6 @@ public:
nsEventStatus* aEventStatus) override;
protected:
virtual void MouseClicked(mozilla::WidgetGUIEvent* aEvent) override;
void StartRepeat() {
nsRepeatService::GetInstance()->Start(Notify, this,
mContent->OwnerDoc(),

View File

@ -168,23 +168,9 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
void
nsTitleBarFrame::MouseClicked(WidgetMouseEvent* aEvent)
{
bool isTrusted = false;
bool isShift = false;
bool isControl = false;
bool isAlt = false;
bool isMeta = false;
uint16_t inputSource = dom::MouseEventBinding::MOZ_SOURCE_UNKNOWN;
if(aEvent) {
isShift = aEvent->IsShift();
isControl = aEvent->IsControl();
isAlt = aEvent->IsAlt();
isMeta = aEvent->IsMeta();
inputSource = aEvent->inputSource;
}
// Execute the oncommand event handler.
nsContentUtils::DispatchXULCommand(mContent, isTrusted, nullptr,
nullptr, isControl, isAlt,
isShift, isMeta, inputSource);
nsContentUtils::DispatchXULCommand(mContent, false, nullptr,
nullptr, aEvent->IsControl(),
aEvent->IsAlt(), aEvent->IsShift(),
aEvent->IsMeta(), aEvent->inputSource);
}

View File

@ -606,16 +606,6 @@
</handlers>
</binding>
<binding id="autorepeatbutton" extends="chrome://global/content/bindings/general.xml#basecontrol">
<resources>
<stylesheet src="chrome://global/skin/scrollbox.css"/>
</resources>
<content repeat="hover">
<xul:image class="autorepeatbutton-icon"/>
</content>
</binding>
<binding id="arrowscrollbox-clicktoscroll" extends="chrome://global/content/bindings/scrollbox.xml#arrowscrollbox">
<content>
<xul:toolbarbutton class="scrollbutton-up"

View File

@ -872,10 +872,6 @@ arrowscrollbox[clicktoscroll="true"] {
-moz-binding: url("chrome://global/content/bindings/scrollbox.xml#arrowscrollbox-clicktoscroll");
}
autorepeatbutton {
-moz-binding: url("chrome://global/content/bindings/scrollbox.xml#autorepeatbutton");
}
/********** stringbundle **********/
stringbundle,

View File

@ -144,7 +144,6 @@ GK_ATOM(autocomplete, "autocomplete")
GK_ATOM(autocomplete_richlistbox, "autocomplete-richlistbox")
GK_ATOM(autofocus, "autofocus")
GK_ATOM(autoplay, "autoplay")
GK_ATOM(autorepeatbutton, "autorepeatbutton")
GK_ATOM(axis, "axis")
GK_ATOM(b, "b")
GK_ATOM(background, "background")