mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove beforeunload events.
R=abarth@chromium.org Review URL: https://codereview.chromium.org/645513006
This commit is contained in:
parent
22d3fe4be3
commit
94b71abca0
@ -37,7 +37,6 @@
|
||||
#include "bindings/core/v8/V8EventTarget.h"
|
||||
#include "bindings/core/v8/V8HiddenValue.h"
|
||||
#include "core/dom/Document.h"
|
||||
#include "core/events/BeforeUnloadEvent.h"
|
||||
#include "core/events/Event.h"
|
||||
#include "core/inspector/InspectorCounters.h"
|
||||
|
||||
@ -141,11 +140,6 @@ void V8AbstractEventListener::invokeEventHandler(Event* event, v8::Local<v8::Val
|
||||
if (returnValue.IsEmpty())
|
||||
return;
|
||||
|
||||
if (m_isAttribute && !returnValue->IsNull() && !returnValue->IsUndefined() && event->isBeforeUnloadEvent()) {
|
||||
TOSTRING_VOID(V8StringResource<>, stringReturnValue, returnValue);
|
||||
toBeforeUnloadEvent(event)->setReturnValue(stringReturnValue);
|
||||
}
|
||||
|
||||
if (m_isAttribute && shouldPreventDefault(returnValue))
|
||||
event->preventDefault();
|
||||
}
|
||||
|
||||
@ -619,8 +619,6 @@ sky_core_files = [
|
||||
"events/AnimationPlayerEvent.h",
|
||||
"events/BeforeTextInsertedEvent.cpp",
|
||||
"events/BeforeTextInsertedEvent.h",
|
||||
"events/BeforeUnloadEvent.cpp",
|
||||
"events/BeforeUnloadEvent.h",
|
||||
"events/CompositionEvent.cpp",
|
||||
"events/CompositionEvent.h",
|
||||
"events/CustomEvent.cpp",
|
||||
@ -1289,7 +1287,6 @@ core_idl_files = get_path_info([
|
||||
"dom/shadow/ShadowRoot.idl",
|
||||
"editing/Selection.idl",
|
||||
"events/AnimationPlayerEvent.idl",
|
||||
"events/BeforeUnloadEvent.idl",
|
||||
"events/CompositionEvent.idl",
|
||||
"events/CustomEvent.idl",
|
||||
"events/ErrorEvent.idl",
|
||||
@ -1411,7 +1408,6 @@ core_event_idl_files = get_path_info([
|
||||
"css/FontFaceSetLoadEvent.idl",
|
||||
"css/MediaQueryListEvent.idl",
|
||||
"events/AnimationPlayerEvent.idl",
|
||||
"events/BeforeUnloadEvent.idl",
|
||||
"events/CompositionEvent.idl",
|
||||
"events/CustomEvent.idl",
|
||||
"events/ErrorEvent.idl",
|
||||
|
||||
@ -83,7 +83,6 @@
|
||||
#include "core/editing/FrameSelection.h"
|
||||
#include "core/editing/SpellChecker.h"
|
||||
#include "core/editing/markup.h"
|
||||
#include "core/events/BeforeUnloadEvent.h"
|
||||
#include "core/events/Event.h"
|
||||
#include "core/events/EventFactory.h"
|
||||
#include "core/events/EventListener.h"
|
||||
@ -1617,8 +1616,6 @@ void Document::dispatchUnloadEvents()
|
||||
|
||||
Document::PageDismissalType Document::pageDismissalEventBeingDispatched() const
|
||||
{
|
||||
if (m_loadEventProgress == BeforeUnloadEventInProgress)
|
||||
return BeforeUnloadDismissal;
|
||||
if (m_loadEventProgress == PageHideInProgress)
|
||||
return PageHideDismissal;
|
||||
if (m_loadEventProgress == UnloadEventInProgress)
|
||||
|
||||
@ -361,7 +361,6 @@ public:
|
||||
|
||||
enum PageDismissalType {
|
||||
NoDismissal = 0,
|
||||
BeforeUnloadDismissal = 1,
|
||||
PageHideDismissal = 2,
|
||||
UnloadDismissal = 3
|
||||
};
|
||||
@ -574,8 +573,6 @@ public:
|
||||
LoadEventTried,
|
||||
LoadEventInProgress,
|
||||
LoadEventCompleted,
|
||||
BeforeUnloadEventInProgress,
|
||||
BeforeUnloadEventCompleted,
|
||||
PageHideInProgress,
|
||||
UnloadEventInProgress,
|
||||
UnloadEventHandled
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
|
||||
* Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
|
||||
* Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
|
||||
* Copyright (C) 2003, 2005, 2006 Apple Computer, Inc.
|
||||
* Copyright (C) 2013 Samsung Electronics.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "core/events/BeforeUnloadEvent.h"
|
||||
|
||||
|
||||
namespace blink {
|
||||
|
||||
BeforeUnloadEvent::BeforeUnloadEvent()
|
||||
: Event(EventTypeNames::beforeunload, false, true)
|
||||
{
|
||||
ScriptWrappable::init(this);
|
||||
}
|
||||
|
||||
BeforeUnloadEvent::~BeforeUnloadEvent()
|
||||
{
|
||||
}
|
||||
|
||||
bool BeforeUnloadEvent::isBeforeUnloadEvent() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void BeforeUnloadEvent::trace(Visitor* visitor)
|
||||
{
|
||||
Event::trace(visitor);
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
|
||||
* Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
|
||||
* Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
|
||||
* Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
|
||||
* Copyright (C) 2013 Samsung Electronics.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BeforeUnloadEvent_h
|
||||
#define BeforeUnloadEvent_h
|
||||
|
||||
#include "core/events/Event.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
class BeforeUnloadEvent FINAL : public Event {
|
||||
DEFINE_WRAPPERTYPEINFO();
|
||||
public:
|
||||
virtual ~BeforeUnloadEvent();
|
||||
|
||||
static PassRefPtrWillBeRawPtr<BeforeUnloadEvent> create()
|
||||
{
|
||||
return adoptRefWillBeNoop(new BeforeUnloadEvent);
|
||||
}
|
||||
|
||||
virtual bool isBeforeUnloadEvent() const OVERRIDE;
|
||||
|
||||
void setReturnValue(const String& returnValue) { m_returnValue = returnValue; }
|
||||
String returnValue() const { return m_returnValue; }
|
||||
|
||||
virtual const AtomicString& interfaceName() const OVERRIDE { return EventNames::BeforeUnloadEvent; }
|
||||
|
||||
virtual void trace(Visitor*) OVERRIDE;
|
||||
|
||||
private:
|
||||
BeforeUnloadEvent();
|
||||
|
||||
String m_returnValue;
|
||||
};
|
||||
|
||||
DEFINE_EVENT_TYPE_CASTS(BeforeUnloadEvent);
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // BeforeUnloadEvent_h
|
||||
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Samsung Electronics. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
interface BeforeUnloadEvent : Event {
|
||||
attribute DOMString returnValue;
|
||||
};
|
||||
@ -188,11 +188,6 @@ bool Event::isBeforeTextInsertedEvent() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Event::isBeforeUnloadEvent() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Event::setTarget(PassRefPtrWillBeRawPtr<EventTarget> target)
|
||||
{
|
||||
if (m_target == target)
|
||||
|
||||
@ -154,8 +154,6 @@ public:
|
||||
virtual bool isClipboardEvent() const;
|
||||
virtual bool isBeforeTextInsertedEvent() const;
|
||||
|
||||
virtual bool isBeforeUnloadEvent() const;
|
||||
|
||||
bool propagationStopped() const { return m_propagationStopped || m_immediatePropagationStopped; }
|
||||
bool immediatePropagationStopped() const { return m_immediatePropagationStopped; }
|
||||
|
||||
|
||||
@ -289,10 +289,7 @@ void EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
|
||||
// index |size|, so iterating up to (but not including) |size| naturally excludes
|
||||
// new event listeners.
|
||||
|
||||
if (event->type() == EventTypeNames::beforeunload) {
|
||||
if (LocalDOMWindow* executingWindow = this->executingWindow())
|
||||
UseCounter::count(executingWindow->document(), UseCounter::DocumentBeforeUnloadFired);
|
||||
} else if (event->type() == EventTypeNames::unload) {
|
||||
if (event->type() == EventTypeNames::unload) {
|
||||
if (LocalDOMWindow* executingWindow = this->executingWindow())
|
||||
UseCounter::count(executingWindow->document(), UseCounter::DocumentUnloadFired);
|
||||
} else if (event->type() == EventTypeNames::DOMFocusIn || event->type() == EventTypeNames::DOMFocusOut) {
|
||||
|
||||
@ -26,7 +26,6 @@ autocompleteerror
|
||||
beforecopy
|
||||
beforecut
|
||||
beforepaste
|
||||
beforeunload
|
||||
beginEvent
|
||||
blocked
|
||||
blur
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
namespace blink {
|
||||
|
||||
namespace DOMWindowEventHandlers {
|
||||
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(beforeunload);
|
||||
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(hashchange);
|
||||
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(languagechange);
|
||||
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(message);
|
||||
|
||||
@ -112,12 +112,6 @@ static DOMWindowSet& windowsWithUnloadEventListeners()
|
||||
return windowsWithUnloadEventListeners;
|
||||
}
|
||||
|
||||
static DOMWindowSet& windowsWithBeforeUnloadEventListeners()
|
||||
{
|
||||
DEFINE_STATIC_LOCAL(DOMWindowSet, windowsWithBeforeUnloadEventListeners, ());
|
||||
return windowsWithBeforeUnloadEventListeners;
|
||||
}
|
||||
|
||||
static void addUnloadEventListener(LocalDOMWindow* domWindow)
|
||||
{
|
||||
DOMWindowSet& set = windowsWithUnloadEventListeners();
|
||||
@ -148,42 +142,6 @@ static void removeAllUnloadEventListeners(LocalDOMWindow* domWindow)
|
||||
enableSuddenTermination();
|
||||
}
|
||||
|
||||
static void addBeforeUnloadEventListener(LocalDOMWindow* domWindow)
|
||||
{
|
||||
DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
|
||||
if (set.isEmpty())
|
||||
disableSuddenTermination();
|
||||
set.add(domWindow);
|
||||
}
|
||||
|
||||
static void removeBeforeUnloadEventListener(LocalDOMWindow* domWindow)
|
||||
{
|
||||
DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
|
||||
DOMWindowSet::iterator it = set.find(domWindow);
|
||||
if (it == set.end())
|
||||
return;
|
||||
set.remove(it);
|
||||
if (set.isEmpty())
|
||||
enableSuddenTermination();
|
||||
}
|
||||
|
||||
static void removeAllBeforeUnloadEventListeners(LocalDOMWindow* domWindow)
|
||||
{
|
||||
DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
|
||||
DOMWindowSet::iterator it = set.find(domWindow);
|
||||
if (it == set.end())
|
||||
return;
|
||||
set.removeAll(it);
|
||||
if (set.isEmpty())
|
||||
enableSuddenTermination();
|
||||
}
|
||||
|
||||
static bool allowsBeforeUnloadListeners(LocalDOMWindow* window)
|
||||
{
|
||||
ASSERT_ARG(window, window);
|
||||
return window->frame();
|
||||
}
|
||||
|
||||
unsigned LocalDOMWindow::pendingUnloadEventListeners() const
|
||||
{
|
||||
return windowsWithUnloadEventListeners().count(const_cast<LocalDOMWindow*>(this));
|
||||
@ -855,19 +813,7 @@ bool LocalDOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<
|
||||
if (eventType == EventTypeNames::unload) {
|
||||
UseCounter::count(document(), UseCounter::DocumentUnloadRegistered);
|
||||
addUnloadEventListener(this);
|
||||
} else if (eventType == EventTypeNames::beforeunload) {
|
||||
UseCounter::count(document(), UseCounter::DocumentBeforeUnloadRegistered);
|
||||
if (allowsBeforeUnloadListeners(this)) {
|
||||
// This is confusingly named. It doesn't actually add the listener. It just increments a count
|
||||
// so that we know we have listeners registered for the purposes of determining if we can
|
||||
// fast terminate the renderer process.
|
||||
addBeforeUnloadEventListener(this);
|
||||
} else {
|
||||
// Subframes return false from allowsBeforeUnloadListeners.
|
||||
UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegistered);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -883,8 +829,6 @@ bool LocalDOMWindow::removeEventListener(const AtomicString& eventType, PassRefP
|
||||
|
||||
if (eventType == EventTypeNames::unload) {
|
||||
removeUnloadEventListener(this);
|
||||
} else if (eventType == EventTypeNames::beforeunload && allowsBeforeUnloadListeners(this)) {
|
||||
removeBeforeUnloadEventListener(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -928,7 +872,6 @@ void LocalDOMWindow::removeAllEventListenersInternal(BroadcastListenerRemoval mo
|
||||
}
|
||||
|
||||
removeAllUnloadEventListeners(this);
|
||||
removeAllBeforeUnloadEventListeners(this);
|
||||
}
|
||||
|
||||
void LocalDOMWindow::removeAllEventListeners()
|
||||
|
||||
@ -121,8 +121,6 @@ public:
|
||||
SVGAnimationElement = 90,
|
||||
KeyboardEventKeyLocation = 91,
|
||||
LineClamp = 96,
|
||||
SubFrameBeforeUnloadRegistered = 97,
|
||||
SubFrameBeforeUnloadFired = 98,
|
||||
TextReplaceWholeText = 100,
|
||||
ConsoleMarkTimeline = 102,
|
||||
CSSPseudoElementUserAgentCustomPseudo = 103,
|
||||
@ -185,8 +183,6 @@ public:
|
||||
InputTypePasswordMaxLength = 193,
|
||||
PrefixedPageVisibility = 196,
|
||||
CSSStyleSheetInsertRuleOptionalArg = 198, // Inconsistent with the specification and other browsers.
|
||||
DocumentBeforeUnloadRegistered = 200,
|
||||
DocumentBeforeUnloadFired = 201,
|
||||
DocumentUnloadRegistered = 202,
|
||||
DocumentUnloadFired = 203,
|
||||
SVGLocatableNearestViewportElement = 204,
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
] interface WindowEventHandlers {
|
||||
//attribute EventHandler onafterprint;
|
||||
//attribute EventHandler onbeforeprint;
|
||||
attribute EventHandler onbeforeunload;
|
||||
attribute EventHandler onhashchange;
|
||||
attribute EventHandler onlanguagechange;
|
||||
attribute EventHandler onmessage;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user