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

Side by Side Diff: Source/WebCore/dom/Document.cpp

Issue 6537003: Merge 78648 - 2011-02-15 James Robinson <jamesr@chromium.org>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/648/
Patch Set: Created 9 years, 10 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
« no previous file with comments | « Source/WebCore/dom/Document.h ('k') | Source/WebCore/dom/ScriptExecutionContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 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 * 10 *
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 #if ENABLE(XHTMLMP) 202 #if ENABLE(XHTMLMP)
203 #include "HTMLNoScriptElement.h" 203 #include "HTMLNoScriptElement.h"
204 #endif 204 #endif
205 205
206 #if ENABLE(FULLSCREEN_API) 206 #if ENABLE(FULLSCREEN_API)
207 #include "RenderFullScreen.h" 207 #include "RenderFullScreen.h"
208 #endif 208 #endif
209 209
210 #if ENABLE(REQUEST_ANIMATION_FRAME) 210 #if ENABLE(REQUEST_ANIMATION_FRAME)
211 #include "RequestAnimationFrameCallback.h" 211 #include "RequestAnimationFrameCallback.h"
212 #include "ScriptedAnimationController.h"
212 #endif 213 #endif
213 214
214 using namespace std; 215 using namespace std;
215 using namespace WTF; 216 using namespace WTF;
216 using namespace Unicode; 217 using namespace Unicode;
217 218
218 namespace WebCore { 219 namespace WebCore {
219 220
220 using namespace HTMLNames; 221 using namespace HTMLNames;
221 222
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 #if ENABLE(FULLSCREEN_API) 423 #if ENABLE(FULLSCREEN_API)
423 , m_isFullScreen(0) 424 , m_isFullScreen(0)
424 , m_areKeysEnabledInFullScreen(0) 425 , m_areKeysEnabledInFullScreen(0)
425 , m_fullScreenRenderer(0) 426 , m_fullScreenRenderer(0)
426 , m_fullScreenChangeDelayTimer(this, &Document::fullScreenChangeDelayTimerFi red) 427 , m_fullScreenChangeDelayTimer(this, &Document::fullScreenChangeDelayTimerFi red)
427 #endif 428 #endif
428 , m_loadEventDelayCount(0) 429 , m_loadEventDelayCount(0)
429 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) 430 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)
430 , m_directionSetOnDocumentElement(false) 431 , m_directionSetOnDocumentElement(false)
431 , m_writingModeSetOnDocumentElement(false) 432 , m_writingModeSetOnDocumentElement(false)
432 #if ENABLE(REQUEST_ANIMATION_FRAME)
433 , m_nextRequestAnimationFrameCallbackId(0)
434 #endif
435 { 433 {
436 m_document = this; 434 m_document = this;
437 435
438 m_pageGroupUserSheetCacheValid = false; 436 m_pageGroupUserSheetCacheValid = false;
439 437
440 m_printing = false; 438 m_printing = false;
441 m_paginatedForScreen = false; 439 m_paginatedForScreen = false;
442 440
443 m_ignoreAutofocus = false; 441 m_ignoreAutofocus = false;
444 442
(...skipping 4280 matching lines...) Expand 10 before | Expand all | Expand 10 after
4725 context->task->performTask(document); 4723 context->task->performTask(document);
4726 4724
4727 delete context; 4725 delete context;
4728 } 4726 }
4729 4727
4730 void Document::postTask(PassOwnPtr<Task> task) 4728 void Document::postTask(PassOwnPtr<Task> task)
4731 { 4729 {
4732 callOnMainThread(performTask, new PerformTaskContext(m_weakReference, task)) ; 4730 callOnMainThread(performTask, new PerformTaskContext(m_weakReference, task)) ;
4733 } 4731 }
4734 4732
4733 void Document::suspendScriptedAnimationControllerCallbacks()
4734 {
4735 #if ENABLE(REQUEST_ANIMATION_FRAME)
4736 if (m_scriptedAnimationController)
4737 m_scriptedAnimationController->suspend();
4738 #endif
4739 }
4740
4741 void Document::resumeScriptedAnimationControllerCallbacks()
4742 {
4743 #if ENABLE(REQUEST_ANIMATION_FRAME)
4744 if (m_scriptedAnimationController)
4745 m_scriptedAnimationController->resume();
4746 #endif
4747 }
4748
4735 Element* Document::findAnchor(const String& name) 4749 Element* Document::findAnchor(const String& name)
4736 { 4750 {
4737 if (name.isEmpty()) 4751 if (name.isEmpty())
4738 return 0; 4752 return 0;
4739 if (Element* element = getElementById(name)) 4753 if (Element* element = getElementById(name))
4740 return element; 4754 return element;
4741 for (Node* node = this; node; node = node->traverseNextNode()) { 4755 for (Node* node = this; node; node = node->traverseNextNode()) {
4742 if (node->hasTagName(aTag)) { 4756 if (node->hasTagName(aTag)) {
4743 HTMLAnchorElement* anchor = static_cast<HTMLAnchorElement*>(node); 4757 HTMLAnchorElement* anchor = static_cast<HTMLAnchorElement*>(node);
4744 if (inQuirksMode()) { 4758 if (inQuirksMode()) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
4955 m_loadEventDelayTimer.startOneShot(0); 4969 m_loadEventDelayTimer.startOneShot(0);
4956 } 4970 }
4957 4971
4958 void Document::loadEventDelayTimerFired(Timer<Document>*) 4972 void Document::loadEventDelayTimerFired(Timer<Document>*)
4959 { 4973 {
4960 if (frame()) 4974 if (frame())
4961 frame()->loader()->checkCompleted(); 4975 frame()->loader()->checkCompleted();
4962 } 4976 }
4963 4977
4964 #if ENABLE(REQUEST_ANIMATION_FRAME) 4978 #if ENABLE(REQUEST_ANIMATION_FRAME)
4965 int Document::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallba ck> callback, Element* e) 4979 int Document::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallba ck> callback, Element* animationElement)
4966 { 4980 {
4967 if (!m_requestAnimationFrameCallbacks) 4981 if (!m_scriptedAnimationController)
4968 m_requestAnimationFrameCallbacks = new RequestAnimationFrameCallbackList ; 4982 m_scriptedAnimationController = ScriptedAnimationController::create(this );
4969 int id = m_nextRequestAnimationFrameCallbackId++; 4983
4970 callback->m_firedOrCancelled = false; 4984 return m_scriptedAnimationController->registerCallback(callback, animationEl ement);
4971 callback->m_id = id;
4972 callback->m_element = e;
4973 m_requestAnimationFrameCallbacks->append(callback);
4974 if (FrameView* v = view())
4975 v->scheduleAnimation();
4976 return id;
4977 } 4985 }
4978 4986
4979 void Document::webkitCancelRequestAnimationFrame(int id) 4987 void Document::webkitCancelRequestAnimationFrame(int id)
4980 { 4988 {
4981 if (!m_requestAnimationFrameCallbacks) 4989 if (!m_scriptedAnimationController)
4982 return; 4990 return;
4983 for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size(); ++i) { 4991 m_scriptedAnimationController->cancelCallback(id);
4984 if (m_requestAnimationFrameCallbacks->at(i)->m_id == id) {
4985 m_requestAnimationFrameCallbacks->at(i)->m_firedOrCancelled = true;
4986 m_requestAnimationFrameCallbacks->remove(i);
4987 return;
4988 }
4989 }
4990 } 4992 }
4991 4993
4992 void Document::serviceScriptedAnimations() 4994 void Document::serviceScriptedAnimations()
4993 { 4995 {
4994 if (!m_requestAnimationFrameCallbacks) 4996 if (!m_scriptedAnimationController)
4995 return; 4997 return;
4996 // We want to run the callback for all elements in the document that have re gistered 4998 m_scriptedAnimationController->serviceScriptedAnimations(time);
4997 // for a callback and that are visible. Running the callbacks can cause new callbacks
4998 // to be registered, existing callbacks to be cancelled, and elements to gai n or lose
4999 // visibility so this code has to iterate carefully.
5000
5001 // FIXME: Currently, this code doesn't do any visibility tests beyond checki ng display:
5002
5003 // First, generate a list of callbacks to consider. Callbacks registered fr om this point
5004 // on are considered only for the "next" frame, not this one.
5005 RequestAnimationFrameCallbackList callbacks(*m_requestAnimationFrameCallback s);
5006
5007 // Firing the callback may cause the visibility of other elements to change. To avoid
5008 // missing any callbacks, we keep iterating through the list of candiate cal lbacks and firing
5009 // them until nothing new becomes visible.
5010 bool firedCallback;
5011 do {
5012 firedCallback = false;
5013 // A previous iteration may have invalidated style (or layout). Update styles for each iteration
5014 // for now since all we check is the existence of a renderer.
5015 updateStyleIfNeeded();
5016 for (size_t i = 0; i < callbacks.size(); ++i) {
5017 RequestAnimationFrameCallback* callback = callbacks[i].get();
5018 if (!callback->m_firedOrCancelled && (!callback->m_element || callba ck->m_element->renderer())) {
5019 callback->m_firedOrCancelled = true;
5020 callback->handleEvent();
5021 firedCallback = true;
5022 callbacks.remove(i);
5023 break;
5024 }
5025 }
5026 } while (firedCallback);
5027
5028 // Remove any callbacks we fired from the list of pending callbacks.
5029 for (size_t i = 0; i < m_requestAnimationFrameCallbacks->size();) {
5030 if (m_requestAnimationFrameCallbacks->at(i)->m_firedOrCancelled)
5031 m_requestAnimationFrameCallbacks->remove(i);
5032 else
5033 ++i;
5034 }
5035
5036 // In most cases we expect this list to be empty, so no need to keep around the vector's inline buffer.
5037 if (!m_requestAnimationFrameCallbacks->size())
5038 m_requestAnimationFrameCallbacks.clear();
5039 else if (FrameView* v = view())
5040 v->scheduleAnimation();
5041 } 4999 }
5042 #endif 5000 #endif
5043 5001
5044 #if ENABLE(TOUCH_EVENTS) 5002 #if ENABLE(TOUCH_EVENTS)
5045 PassRefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const 5003 PassRefPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, int pageX, int pageY, int screenX, int screenY, ExceptionCode&) const
5046 { 5004 {
5047 // FIXME: It's not clear from the documentation at 5005 // FIXME: It's not clear from the documentation at
5048 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html 5006 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
5049 // when this method should throw and nor is it by inspection of iOS behavior . It would be nice to verify any cases where it throws under iOS 5007 // when this method should throw and nor is it by inspection of iOS behavior . It would be nice to verify any cases where it throws under iOS
5050 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 5008 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5083 // This functions is used for checking such possibility of FOUCs. 5041 // This functions is used for checking such possibility of FOUCs.
5084 // Note that the implementation considers only empty or <head> only contents as a FOUC cause 5042 // Note that the implementation considers only empty or <head> only contents as a FOUC cause
5085 // rather than missing <body>, because non-HTML document like SVG and arbitr ary XML from foreign namespace 5043 // rather than missing <body>, because non-HTML document like SVG and arbitr ary XML from foreign namespace
5086 // should be painted even if there is no <body>. 5044 // should be painted even if there is no <body>.
5087 if (didLayoutWithPendingStylesheets()) 5045 if (didLayoutWithPendingStylesheets())
5088 return true; 5046 return true;
5089 return !hasHeadSibling(this); 5047 return !hasHeadSibling(this);
5090 } 5048 }
5091 5049
5092 } // namespace WebCore 5050 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/dom/Document.h ('k') | Source/WebCore/dom/ScriptExecutionContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698