OLD | NEW |
---|---|
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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 } | 354 } |
355 | 355 |
356 return false; | 356 return false; |
357 } | 357 } |
358 | 358 |
359 static void printNavigationErrorMessage(const LocalFrame& frame, const KURL& act iveURL, const char* reason) | 359 static void printNavigationErrorMessage(const LocalFrame& frame, const KURL& act iveURL, const char* reason) |
360 { | 360 { |
361 String message = "Unsafe JavaScript attempt to initiate navigation for frame with URL '" + frame.document()->url().string() + "' from frame with URL '" + ac tiveURL.string() + "'. " + reason + "\n"; | 361 String message = "Unsafe JavaScript attempt to initiate navigation for frame with URL '" + frame.document()->url().string() + "' from frame with URL '" + ac tiveURL.string() + "'. " + reason + "\n"; |
362 | 362 |
363 // FIXME: should we print to the console of the document performing the navi gation instead? | 363 // FIXME: should we print to the console of the document performing the navi gation instead? |
364 frame.domWindow()->printErrorMessage(message); | 364 frame.localDOMWindow()->printErrorMessage(message); |
365 } | 365 } |
366 | 366 |
367 uint64_t Document::s_globalTreeVersion = 0; | 367 uint64_t Document::s_globalTreeVersion = 0; |
368 | 368 |
369 #ifndef NDEBUG | 369 #ifndef NDEBUG |
370 using WeakDocumentSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<Document>>; | 370 using WeakDocumentSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<Document>>; |
371 static WeakDocumentSet& liveDocumentSet() | 371 static WeakDocumentSet& liveDocumentSet() |
372 { | 372 { |
373 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakDocumentSet>, set, (adoptPtrW illBeNoop(new WeakDocumentSet()))); | 373 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakDocumentSet>, set, (adoptPtrW illBeNoop(new WeakDocumentSet()))); |
374 return *set; | 374 return *set; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 registerObserver(document); | 436 registerObserver(document); |
437 } | 437 } |
438 | 438 |
439 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses) | 439 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses) |
440 : ContainerNode(0, CreateDocument) | 440 : ContainerNode(0, CreateDocument) |
441 , TreeScope(*this) | 441 , TreeScope(*this) |
442 , m_hasNodesWithPlaceholderStyle(false) | 442 , m_hasNodesWithPlaceholderStyle(false) |
443 , m_evaluateMediaQueriesOnStyleRecalc(false) | 443 , m_evaluateMediaQueriesOnStyleRecalc(false) |
444 , m_pendingSheetLayout(NoLayoutWithPendingSheets) | 444 , m_pendingSheetLayout(NoLayoutWithPendingSheets) |
445 , m_frame(initializer.frame()) | 445 , m_frame(initializer.frame()) |
446 , m_domWindow(m_frame ? m_frame->domWindow() : 0) | 446 , m_domWindow(m_frame ? m_frame->localDOMWindow() : 0) |
447 , m_importsController(initializer.importsController()) | 447 , m_importsController(initializer.importsController()) |
448 , m_activeParserCount(0) | 448 , m_activeParserCount(0) |
449 , m_contextFeatures(ContextFeatures::defaultSwitch()) | 449 , m_contextFeatures(ContextFeatures::defaultSwitch()) |
450 , m_wellFormed(false) | 450 , m_wellFormed(false) |
451 , m_printing(false) | 451 , m_printing(false) |
452 , m_paginatedForScreen(false) | 452 , m_paginatedForScreen(false) |
453 , m_compatibilityMode(NoQuirksMode) | 453 , m_compatibilityMode(NoQuirksMode) |
454 , m_compatibilityModeLocked(false) | 454 , m_compatibilityModeLocked(false) |
455 , m_executeScriptsWaitingForResourcesTimer(this, &Document::executeScriptsWa itingForResourcesTimerFired) | 455 , m_executeScriptsWaitingForResourcesTimer(this, &Document::executeScriptsWa itingForResourcesTimerFired) |
456 , m_hasAutofocused(false) | 456 , m_hasAutofocused(false) |
(...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2627 // The DocumentLoader (and thus its DocumentLoadTiming) might get de stroyed | 2627 // The DocumentLoader (and thus its DocumentLoadTiming) might get de stroyed |
2628 // while dispatching the event, so protect it to prevent writing the end | 2628 // while dispatching the event, so protect it to prevent writing the end |
2629 // time into freed memory. | 2629 // time into freed memory. |
2630 RefPtr<DocumentLoader> documentLoader = m_frame->loader().provision alDocumentLoader(); | 2630 RefPtr<DocumentLoader> documentLoader = m_frame->loader().provision alDocumentLoader(); |
2631 m_loadEventProgress = UnloadEventInProgress; | 2631 m_loadEventProgress = UnloadEventInProgress; |
2632 RefPtrWillBeRawPtr<Event> unloadEvent(Event::create(EventTypeNames:: unload)); | 2632 RefPtrWillBeRawPtr<Event> unloadEvent(Event::create(EventTypeNames:: unload)); |
2633 if (documentLoader && !documentLoader->timing()->unloadEventStart() && !documentLoader->timing()->unloadEventEnd()) { | 2633 if (documentLoader && !documentLoader->timing()->unloadEventStart() && !documentLoader->timing()->unloadEventEnd()) { |
2634 DocumentLoadTiming* timing = documentLoader->timing(); | 2634 DocumentLoadTiming* timing = documentLoader->timing(); |
2635 ASSERT(timing->navigationStart()); | 2635 ASSERT(timing->navigationStart()); |
2636 timing->markUnloadEventStart(); | 2636 timing->markUnloadEventStart(); |
2637 m_frame->domWindow()->dispatchEvent(unloadEvent, this); | 2637 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, this); |
2638 timing->markUnloadEventEnd(); | 2638 timing->markUnloadEventEnd(); |
2639 } else { | 2639 } else { |
2640 m_frame->domWindow()->dispatchEvent(unloadEvent, m_frame->docume nt()); | 2640 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, m_frame->d ocument()); |
2641 } | 2641 } |
2642 } | 2642 } |
2643 m_loadEventProgress = UnloadEventHandled; | 2643 m_loadEventProgress = UnloadEventHandled; |
2644 } | 2644 } |
2645 | 2645 |
2646 if (!m_frame) | 2646 if (!m_frame) |
2647 return; | 2647 return; |
2648 | 2648 |
2649 // Don't remove event listeners from a transitional empty document (see http s://bugs.webkit.org/show_bug.cgi?id=28716 for more information). | 2649 // Don't remove event listeners from a transitional empty document (see http s://bugs.webkit.org/show_bug.cgi?id=28716 for more information). |
2650 bool keepEventListeners = m_frame->loader().stateMachine()->isDisplayingInit ialEmptyDocument() && m_frame->loader().provisionalDocumentLoader() | 2650 bool keepEventListeners = m_frame->loader().stateMachine()->isDisplayingInit ialEmptyDocument() && m_frame->loader().provisionalDocumentLoader() |
(...skipping 2547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5198 m_scriptedAnimationController->cancelCallback(id); | 5198 m_scriptedAnimationController->cancelCallback(id); |
5199 } | 5199 } |
5200 | 5200 |
5201 void Document::serviceScriptedAnimations(double monotonicAnimationStartTime) | 5201 void Document::serviceScriptedAnimations(double monotonicAnimationStartTime) |
5202 { | 5202 { |
5203 if (!m_scriptedAnimationController) | 5203 if (!m_scriptedAnimationController) |
5204 return; | 5204 return; |
5205 m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationS tartTime); | 5205 m_scriptedAnimationController->serviceScriptedAnimations(monotonicAnimationS tartTime); |
5206 } | 5206 } |
5207 | 5207 |
5208 PassRefPtrWillBeRawPtr<Touch> Document::createTouch(LocalDOMWindow* window, Even tTarget* target, int identifier, double pageX, double pageY, double screenX, dou ble screenY, double radiusX, double radiusY, float rotationAngle, float force) c onst | 5208 PassRefPtrWillBeRawPtr<Touch> Document::createTouch(DOMWindow* window, EventTarg et* target, int identifier, double pageX, double pageY, double screenX, double s creenY, double radiusX, double radiusY, float rotationAngle, float force) const |
haraken
2014/10/31 06:07:04
Why doesn't this method take a LocalDOMWindow* par
dcheng
2014/10/31 06:31:01
This is tricky. This is required because of severa
| |
5209 { | 5209 { |
5210 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly | 5210 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly |
5211 // passing Infinity/NaN. | 5211 // passing Infinity/NaN. |
5212 if (!std::isfinite(pageX)) | 5212 if (!std::isfinite(pageX)) |
5213 pageX = 0; | 5213 pageX = 0; |
5214 if (!std::isfinite(pageY)) | 5214 if (!std::isfinite(pageY)) |
5215 pageY = 0; | 5215 pageY = 0; |
5216 if (!std::isfinite(screenX)) | 5216 if (!std::isfinite(screenX)) |
5217 screenX = 0; | 5217 screenX = 0; |
5218 if (!std::isfinite(screenY)) | 5218 if (!std::isfinite(screenY)) |
5219 screenY = 0; | 5219 screenY = 0; |
5220 if (!std::isfinite(radiusX)) | 5220 if (!std::isfinite(radiusX)) |
5221 radiusX = 0; | 5221 radiusX = 0; |
5222 if (!std::isfinite(radiusY)) | 5222 if (!std::isfinite(radiusY)) |
5223 radiusY = 0; | 5223 radiusY = 0; |
5224 if (!std::isfinite(rotationAngle)) | 5224 if (!std::isfinite(rotationAngle)) |
5225 rotationAngle = 0; | 5225 rotationAngle = 0; |
5226 if (!std::isfinite(force)) | 5226 if (!std::isfinite(force)) |
5227 force = 0; | 5227 force = 0; |
5228 | 5228 |
5229 // FIXME: It's not clear from the documentation at | 5229 // FIXME: It's not clear from the documentation at |
5230 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html | 5230 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html |
5231 // 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 | 5231 // 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 |
5232 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 | 5232 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 |
5233 LocalFrame* frame = window ? window->frame() : this->frame(); | 5233 LocalFrame* frame = window ? toLocalDOMWindow(window)->frame() : this->frame (); |
haraken
2014/10/31 06:07:04
Here we're assuming that |window| is a LocalDOMWin
dcheng
2014/10/31 06:31:01
This change is actually incorrect--I forgot to upd
| |
5234 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force); | 5234 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force); |
5235 } | 5235 } |
5236 | 5236 |
5237 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch>>& touches) const | 5237 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch>>& touches) const |
5238 { | 5238 { |
5239 return TouchList::adopt(touches); | 5239 return TouchList::adopt(touches); |
5240 } | 5240 } |
5241 | 5241 |
5242 DocumentLoader* Document::loader() const | 5242 DocumentLoader* Document::loader() const |
5243 { | 5243 { |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5824 #ifndef NDEBUG | 5824 #ifndef NDEBUG |
5825 using namespace blink; | 5825 using namespace blink; |
5826 void showLiveDocumentInstances() | 5826 void showLiveDocumentInstances() |
5827 { | 5827 { |
5828 WeakDocumentSet& set = liveDocumentSet(); | 5828 WeakDocumentSet& set = liveDocumentSet(); |
5829 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5829 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5830 for (Document* document : set) | 5830 for (Document* document : set) |
5831 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); | 5831 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); |
5832 } | 5832 } |
5833 #endif | 5833 #endif |
OLD | NEW |