Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: Source/core/frame/LocalFrame.cpp

Issue 206603002: Add EventHandlerRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test for external handlers. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 15 matching lines...) Expand all
26 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 26 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 * Boston, MA 02110-1301, USA. 27 * Boston, MA 02110-1301, USA.
28 */ 28 */
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "core/frame/LocalFrame.h" 31 #include "core/frame/LocalFrame.h"
32 32
33 #include "RuntimeEnabledFeatures.h" 33 #include "RuntimeEnabledFeatures.h"
34 #include "bindings/v8/ScriptController.h" 34 #include "bindings/v8/ScriptController.h"
35 #include "core/dom/DocumentType.h" 35 #include "core/dom/DocumentType.h"
36 #include "core/dom/WheelController.h" 36 #include "core/dom/EventHandlerRegistry.h"
37 #include "core/editing/Editor.h" 37 #include "core/editing/Editor.h"
38 #include "core/editing/FrameSelection.h" 38 #include "core/editing/FrameSelection.h"
39 #include "core/editing/InputMethodController.h" 39 #include "core/editing/InputMethodController.h"
40 #include "core/editing/SpellChecker.h" 40 #include "core/editing/SpellChecker.h"
41 #include "core/editing/htmlediting.h" 41 #include "core/editing/htmlediting.h"
42 #include "core/editing/markup.h" 42 #include "core/editing/markup.h"
43 #include "core/events/Event.h" 43 #include "core/events/Event.h"
44 #include "core/fetch/ResourceFetcher.h" 44 #include "core/fetch/ResourceFetcher.h"
45 #include "core/frame/DOMWindow.h" 45 #include "core/frame/DOMWindow.h"
46 #include "core/frame/FrameHost.h" 46 #include "core/frame/FrameHost.h"
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 document()->mediaQueryAffectingValueChanged(); 459 document()->mediaQueryAffectingValueChanged();
460 for (RefPtr<LocalFrame> child = tree().firstChild(); child; child = child->t ree().nextSibling()) 460 for (RefPtr<LocalFrame> child = tree().firstChild(); child; child = child->t ree().nextSibling())
461 child->deviceOrPageScaleFactorChanged(); 461 child->deviceOrPageScaleFactorChanged();
462 } 462 }
463 463
464 void LocalFrame::notifyChromeClientWheelEventHandlerCountChanged() const 464 void LocalFrame::notifyChromeClientWheelEventHandlerCountChanged() const
465 { 465 {
466 // Ensure that this method is being called on the main frame of the page. 466 // Ensure that this method is being called on the main frame of the page.
467 ASSERT(isMainFrame()); 467 ASSERT(isMainFrame());
468 468
469 unsigned count = 0; 469 EventHandlerRegistry* registry = EventHandlerRegistry::from(*document());
470 for (const LocalFrame* frame = this; frame; frame = frame->tree().traverseNe xt()) { 470 unsigned count = registry->externalEventHandlerCount(EventHandlerRegistry::W heelEvent);
471 if (frame->document()) 471 const EventTargetSet* targets = registry->eventHandlerTargets(EventHandlerRe gistry::WheelEvent);
472 count += WheelController::from(*frame->document())->wheelEventHandle rCount(); 472 if (targets) {
473 for (EventTargetSet::const_iterator iter = targets->begin(); iter != tar gets->end(); ++iter)
474 count += iter->value;
473 } 475 }
474
475 m_host->chrome().client().numWheelEventHandlersChanged(count); 476 m_host->chrome().client().numWheelEventHandlersChanged(count);
476 } 477 }
477 478
478 bool LocalFrame::isURLAllowed(const KURL& url) const 479 bool LocalFrame::isURLAllowed(const KURL& url) const
479 { 480 {
480 // We allow one level of self-reference because some sites depend on that, 481 // We allow one level of self-reference because some sites depend on that,
481 // but we don't allow more than one. 482 // but we don't allow more than one.
482 if (page()->subframeCount() >= Page::maxNumberOfFrames) 483 if (page()->subframeCount() >= Page::maxNumberOfFrames)
483 return false; 484 return false;
484 bool foundSelfReference = false; 485 bool foundSelfReference = false;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 { 595 {
595 if (!m_host) 596 if (!m_host)
596 return 0; 597 return 0;
597 598
598 double ratio = m_host->deviceScaleFactor(); 599 double ratio = m_host->deviceScaleFactor();
599 ratio *= pageZoomFactor(); 600 ratio *= pageZoomFactor();
600 return ratio; 601 return ratio;
601 } 602 }
602 603
603 } // namespace WebCore 604 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698