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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2191533003: Refactor Timer classes in preparation for landing FrameTimers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 { 1923 {
1924 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); 1924 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus));
1925 } 1925 }
1926 1926
1927 void Document::clearFocusedElementSoon() 1927 void Document::clearFocusedElementSoon()
1928 { 1928 {
1929 if (!m_clearFocusedElementTimer.isActive()) 1929 if (!m_clearFocusedElementTimer.isActive())
1930 m_clearFocusedElementTimer.startOneShot(0, BLINK_FROM_HERE); 1930 m_clearFocusedElementTimer.startOneShot(0, BLINK_FROM_HERE);
1931 } 1931 }
1932 1932
1933 void Document::clearFocusedElementTimerFired(Timer<Document>*) 1933 void Document::clearFocusedElementTimerFired(TimerBase*)
1934 { 1934 {
1935 updateStyleAndLayoutTree(); 1935 updateStyleAndLayoutTree();
1936 m_clearFocusedElementTimer.stop(); 1936 m_clearFocusedElementTimer.stop();
1937 1937
1938 if (m_focusedElement && !m_focusedElement->isFocusable()) 1938 if (m_focusedElement && !m_focusedElement->isFocusable())
1939 m_focusedElement->blur(); 1939 m_focusedElement->blur();
1940 } 1940 }
1941 1941
1942 // FIXME: This is a bad idea and needs to be removed eventually. 1942 // FIXME: This is a bad idea and needs to be removed eventually.
1943 // Other browsers load stylesheets before they continue parsing the web page. 1943 // Other browsers load stylesheets before they continue parsing the web page.
(...skipping 2874 matching lines...) Expand 10 before | Expand all | Expand 10 after
4818 // Schedule dropping of the ElementDataCache. We keep it alive for a while a fter parsing finishes 4818 // Schedule dropping of the ElementDataCache. We keep it alive for a while a fter parsing finishes
4819 // so that dynamically inserted content can also benefit from sharing optimi zations. 4819 // so that dynamically inserted content can also benefit from sharing optimi zations.
4820 // Note that we don't refresh the timer on cache access since that could lea d to huge caches being kept 4820 // Note that we don't refresh the timer on cache access since that could lea d to huge caches being kept
4821 // alive indefinitely by something innocuous like JS setting .innerHTML repe atedly on a timer. 4821 // alive indefinitely by something innocuous like JS setting .innerHTML repe atedly on a timer.
4822 m_elementDataCacheClearTimer.startOneShot(10, BLINK_FROM_HERE); 4822 m_elementDataCacheClearTimer.startOneShot(10, BLINK_FROM_HERE);
4823 4823
4824 // Parser should have picked up all preloads by now 4824 // Parser should have picked up all preloads by now
4825 m_fetcher->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads); 4825 m_fetcher->clearPreloads(ResourceFetcher::ClearSpeculativeMarkupPreloads);
4826 } 4826 }
4827 4827
4828 void Document::elementDataCacheClearTimerFired(Timer<Document>*) 4828 void Document::elementDataCacheClearTimerFired(TimerBase*)
4829 { 4829 {
4830 m_elementDataCache.clear(); 4830 m_elementDataCache.clear();
4831 } 4831 }
4832 4832
4833 void Document::beginLifecycleUpdatesIfRenderingReady() 4833 void Document::beginLifecycleUpdatesIfRenderingReady()
4834 { 4834 {
4835 if (!isActive()) 4835 if (!isActive())
4836 return; 4836 return;
4837 if (!isRenderingReady()) 4837 if (!isRenderingReady())
4838 return; 4838 return;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
5128 m_updateFocusAppearanceSelectionBahavior = selectionbehavioronfocus; 5128 m_updateFocusAppearanceSelectionBahavior = selectionbehavioronfocus;
5129 if (!m_updateFocusAppearanceTimer.isActive()) 5129 if (!m_updateFocusAppearanceTimer.isActive())
5130 m_updateFocusAppearanceTimer.startOneShot(0, BLINK_FROM_HERE); 5130 m_updateFocusAppearanceTimer.startOneShot(0, BLINK_FROM_HERE);
5131 } 5131 }
5132 5132
5133 void Document::cancelFocusAppearanceUpdate() 5133 void Document::cancelFocusAppearanceUpdate()
5134 { 5134 {
5135 m_updateFocusAppearanceTimer.stop(); 5135 m_updateFocusAppearanceTimer.stop();
5136 } 5136 }
5137 5137
5138 void Document::updateFocusAppearanceTimerFired(Timer<Document>*) 5138 void Document::updateFocusAppearanceTimerFired(TimerBase*)
5139 { 5139 {
5140 Element* element = focusedElement(); 5140 Element* element = focusedElement();
5141 if (!element) 5141 if (!element)
5142 return; 5142 return;
5143 updateStyleAndLayout(); 5143 updateStyleAndLayout();
5144 if (element->isFocusable()) 5144 if (element->isFocusable())
5145 element->updateFocusAppearance(m_updateFocusAppearanceSelectionBahavior) ; 5145 element->updateFocusAppearance(m_updateFocusAppearanceSelectionBahavior) ;
5146 } 5146 }
5147 5147
5148 void Document::attachRange(Range* range) 5148 void Document::attachRange(Range* range)
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
5375 // incrementLoadEventDelayCount and decrementLoadEventDelayCount in 5375 // incrementLoadEventDelayCount and decrementLoadEventDelayCount in
5376 // Node destructors. 5376 // Node destructors.
5377 if (ThreadState::current()->sweepForbidden()) { 5377 if (ThreadState::current()->sweepForbidden()) {
5378 if (!m_loadEventDelayCount) 5378 if (!m_loadEventDelayCount)
5379 checkLoadEventSoon(); 5379 checkLoadEventSoon();
5380 return true; 5380 return true;
5381 } 5381 }
5382 return m_loadEventDelayCount; 5382 return m_loadEventDelayCount;
5383 } 5383 }
5384 5384
5385 void Document::loadEventDelayTimerFired(Timer<Document>*) 5385 void Document::loadEventDelayTimerFired(TimerBase*)
5386 { 5386 {
5387 if (frame()) 5387 if (frame())
5388 frame()->loader().checkCompleted(); 5388 frame()->loader().checkCompleted();
5389 } 5389 }
5390 5390
5391 void Document::loadPluginsSoon() 5391 void Document::loadPluginsSoon()
5392 { 5392 {
5393 // FIXME: Remove this timer once we don't need to compute layout to load plu gins. 5393 // FIXME: Remove this timer once we don't need to compute layout to load plu gins.
5394 if (!m_pluginLoadingTimer.isActive()) 5394 if (!m_pluginLoadingTimer.isActive())
5395 m_pluginLoadingTimer.startOneShot(0, BLINK_FROM_HERE); 5395 m_pluginLoadingTimer.startOneShot(0, BLINK_FROM_HERE);
5396 } 5396 }
5397 5397
5398 void Document::pluginLoadingTimerFired(Timer<Document>*) 5398 void Document::pluginLoadingTimerFired(TimerBase*)
5399 { 5399 {
5400 updateStyleAndLayout(); 5400 updateStyleAndLayout();
5401 } 5401 }
5402 5402
5403 ScriptedAnimationController& Document::ensureScriptedAnimationController() 5403 ScriptedAnimationController& Document::ensureScriptedAnimationController()
5404 { 5404 {
5405 if (!m_scriptedAnimationController) { 5405 if (!m_scriptedAnimationController) {
5406 m_scriptedAnimationController = ScriptedAnimationController::create(this ); 5406 m_scriptedAnimationController = ScriptedAnimationController::create(this );
5407 // We need to make sure that we don't start up the animation controller on a background tab, for example. 5407 // We need to make sure that we don't start up the animation controller on a background tab, for example.
5408 if (!page()) 5408 if (!page())
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
5749 void Document::removeFormAssociation(Element* element) 5749 void Document::removeFormAssociation(Element* element)
5750 { 5750 {
5751 auto it = m_associatedFormControls.find(element); 5751 auto it = m_associatedFormControls.find(element);
5752 if (it == m_associatedFormControls.end()) 5752 if (it == m_associatedFormControls.end())
5753 return; 5753 return;
5754 m_associatedFormControls.remove(it); 5754 m_associatedFormControls.remove(it);
5755 if (m_associatedFormControls.isEmpty()) 5755 if (m_associatedFormControls.isEmpty())
5756 m_didAssociateFormControlsTimer.stop(); 5756 m_didAssociateFormControlsTimer.stop();
5757 } 5757 }
5758 5758
5759 void Document::didAssociateFormControlsTimerFired(Timer<Document>* timer) 5759 void Document::didAssociateFormControlsTimerFired(TimerBase* timer)
5760 { 5760 {
5761 ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer); 5761 ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer);
5762 if (!frame() || !frame()->page()) 5762 if (!frame() || !frame()->page())
5763 return; 5763 return;
5764 5764
5765 HeapVector<Member<Element>> associatedFormControls; 5765 HeapVector<Member<Element>> associatedFormControls;
5766 copyToVector(m_associatedFormControls, associatedFormControls); 5766 copyToVector(m_associatedFormControls, associatedFormControls);
5767 5767
5768 frame()->page()->chromeClient().didAssociateFormControls(associatedFormContr ols, frame()); 5768 frame()->page()->chromeClient().didAssociateFormControls(associatedFormContr ols, frame());
5769 m_associatedFormControls.clear(); 5769 m_associatedFormControls.clear();
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
6048 } 6048 }
6049 6049
6050 void showLiveDocumentInstances() 6050 void showLiveDocumentInstances()
6051 { 6051 {
6052 WeakDocumentSet& set = liveDocumentSet(); 6052 WeakDocumentSet& set = liveDocumentSet();
6053 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6053 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6054 for (Document* document : set) 6054 for (Document* document : set)
6055 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6055 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6056 } 6056 }
6057 #endif 6057 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698