| 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 14 matching lines...) Expand all Loading... |
| 25 * Boston, MA 02110-1301, USA. | 25 * Boston, MA 02110-1301, USA. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "sky/engine/core/dom/Document.h" | 28 #include "sky/engine/core/dom/Document.h" |
| 29 | 29 |
| 30 #include "gen/sky/core/HTMLElementFactory.h" | 30 #include "gen/sky/core/HTMLElementFactory.h" |
| 31 #include "gen/sky/platform/RuntimeEnabledFeatures.h" | 31 #include "gen/sky/platform/RuntimeEnabledFeatures.h" |
| 32 #include "sky/engine/bindings/exception_messages.h" | 32 #include "sky/engine/bindings/exception_messages.h" |
| 33 #include "sky/engine/bindings/exception_state.h" | 33 #include "sky/engine/bindings/exception_state.h" |
| 34 #include "sky/engine/bindings/exception_state_placeholder.h" | 34 #include "sky/engine/bindings/exception_state_placeholder.h" |
| 35 #include "sky/engine/core/animation/AnimationTimeline.h" | |
| 36 #include "sky/engine/core/animation/DocumentAnimations.h" | |
| 37 #include "sky/engine/core/css/CSSFontSelector.h" | 35 #include "sky/engine/core/css/CSSFontSelector.h" |
| 38 #include "sky/engine/core/css/CSSStyleDeclaration.h" | 36 #include "sky/engine/core/css/CSSStyleDeclaration.h" |
| 39 #include "sky/engine/core/css/CSSStyleSheet.h" | 37 #include "sky/engine/core/css/CSSStyleSheet.h" |
| 40 #include "sky/engine/core/css/MediaQueryMatcher.h" | 38 #include "sky/engine/core/css/MediaQueryMatcher.h" |
| 41 #include "sky/engine/core/css/StylePropertySet.h" | 39 #include "sky/engine/core/css/StylePropertySet.h" |
| 42 #include "sky/engine/core/css/StyleSheetContents.h" | 40 #include "sky/engine/core/css/StyleSheetContents.h" |
| 43 #include "sky/engine/core/css/parser/BisonCSSParser.h" | 41 #include "sky/engine/core/css/parser/BisonCSSParser.h" |
| 44 #include "sky/engine/core/css/resolver/FontBuilder.h" | 42 #include "sky/engine/core/css/resolver/FontBuilder.h" |
| 45 #include "sky/engine/core/css/resolver/StyleResolver.h" | 43 #include "sky/engine/core/css/resolver/StyleResolver.h" |
| 46 #include "sky/engine/core/css/resolver/StyleResolverStats.h" | 44 #include "sky/engine/core/css/resolver/StyleResolverStats.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 #if !ENABLE(OILPAN) | 222 #if !ENABLE(OILPAN) |
| 225 , m_weakFactory(this) | 223 , m_weakFactory(this) |
| 226 #endif | 224 #endif |
| 227 , m_contextDocument(initializer.contextDocument()) | 225 , m_contextDocument(initializer.contextDocument()) |
| 228 , m_loadEventDelayCount(0) | 226 , m_loadEventDelayCount(0) |
| 229 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) | 227 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) |
| 230 , m_didSetReferrerPolicy(false) | 228 , m_didSetReferrerPolicy(false) |
| 231 , m_referrerPolicy(ReferrerPolicyDefault) | 229 , m_referrerPolicy(ReferrerPolicyDefault) |
| 232 , m_elementRegistry(initializer.elementRegistry()) | 230 , m_elementRegistry(initializer.elementRegistry()) |
| 233 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi
red) | 231 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi
red) |
| 234 , m_timeline(AnimationTimeline::create(this)) | |
| 235 , m_templateDocumentHost(nullptr) | 232 , m_templateDocumentHost(nullptr) |
| 236 , m_hasViewportUnits(false) | 233 , m_hasViewportUnits(false) |
| 237 , m_styleRecalcElementCounter(0) | 234 , m_styleRecalcElementCounter(0) |
| 238 , m_frameView(nullptr) | 235 , m_frameView(nullptr) |
| 239 { | 236 { |
| 240 setClient(this); | 237 setClient(this); |
| 241 | 238 |
| 242 if (!m_elementRegistry) | 239 if (!m_elementRegistry) |
| 243 m_elementRegistry = CustomElementRegistry::Create(); | 240 m_elementRegistry = CustomElementRegistry::Create(); |
| 244 | 241 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 272 | 269 |
| 273 // FIXME: Oilpan: Not removing event listeners here also means that we do | 270 // FIXME: Oilpan: Not removing event listeners here also means that we do |
| 274 // not notify the inspector instrumentation that the event listeners are | 271 // not notify the inspector instrumentation that the event listeners are |
| 275 // gone. The Document and all the nodes in the document are gone, so maybe | 272 // gone. The Document and all the nodes in the document are gone, so maybe |
| 276 // that is OK? | 273 // that is OK? |
| 277 removeAllEventListenersRecursively(); | 274 removeAllEventListenersRecursively(); |
| 278 #endif | 275 #endif |
| 279 | 276 |
| 280 #if !ENABLE(OILPAN) | 277 #if !ENABLE(OILPAN) |
| 281 | 278 |
| 282 m_timeline->detachFromDocument(); | |
| 283 | |
| 284 if (m_elemSheet) | 279 if (m_elemSheet) |
| 285 m_elemSheet->clearOwnerNode(); | 280 m_elemSheet->clearOwnerNode(); |
| 286 | 281 |
| 287 // We must call clearRareData() here since a Document class inherits TreeSco
pe | 282 // We must call clearRareData() here since a Document class inherits TreeSco
pe |
| 288 // as well as Node. See a comment on TreeScope.h for the reason. | 283 // as well as Node. See a comment on TreeScope.h for the reason. |
| 289 if (hasRareData()) | 284 if (hasRareData()) |
| 290 clearRareData(); | 285 clearRareData(); |
| 291 | 286 |
| 292 #ifndef NDEBUG | 287 #ifndef NDEBUG |
| 293 liveDocumentSet().remove(this); | 288 liveDocumentSet().remove(this); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 641 |
| 647 const AtomicString& Document::dir() | 642 const AtomicString& Document::dir() |
| 648 { | 643 { |
| 649 return nullAtom; | 644 return nullAtom; |
| 650 } | 645 } |
| 651 | 646 |
| 652 void Document::setDir(const AtomicString& value) | 647 void Document::setDir(const AtomicString& value) |
| 653 { | 648 { |
| 654 } | 649 } |
| 655 | 650 |
| 656 PageVisibilityState Document::pageVisibilityState() const | |
| 657 { | |
| 658 // The visibility of the document is inherited from the visibility of the | |
| 659 // page. If there is no page associated with the document, we will assume | |
| 660 // that the page is hidden, as specified by the spec: | |
| 661 // http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.
html#dom-document-hidden | |
| 662 if (!m_frame || !m_frame->page()) | |
| 663 return PageVisibilityStateHidden; | |
| 664 return m_frame->page()->visibilityState(); | |
| 665 } | |
| 666 | |
| 667 String Document::visibilityState() const | |
| 668 { | |
| 669 return pageVisibilityStateString(pageVisibilityState()); | |
| 670 } | |
| 671 | |
| 672 bool Document::hidden() const | |
| 673 { | |
| 674 return pageVisibilityState() != PageVisibilityStateVisible; | |
| 675 } | |
| 676 | |
| 677 void Document::didChangeVisibilityState() | |
| 678 { | |
| 679 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); | |
| 680 } | |
| 681 | |
| 682 String Document::nodeName() const | 651 String Document::nodeName() const |
| 683 { | 652 { |
| 684 return "#document"; | 653 return "#document"; |
| 685 } | 654 } |
| 686 | 655 |
| 687 Node::NodeType Document::nodeType() const | 656 Node::NodeType Document::nodeType() const |
| 688 { | 657 { |
| 689 return DOCUMENT_NODE; | 658 return DOCUMENT_NODE; |
| 690 } | 659 } |
| 691 | 660 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 | 702 |
| 734 bool Document::needsFullRenderTreeUpdate() const | 703 bool Document::needsFullRenderTreeUpdate() const |
| 735 { | 704 { |
| 736 if (!isActive() || !view()) | 705 if (!isActive() || !view()) |
| 737 return false; | 706 return false; |
| 738 if (needsStyleRecalc()) | 707 if (needsStyleRecalc()) |
| 739 return true; | 708 return true; |
| 740 // FIXME: The childNeedsDistributionRecalc bit means either self or children
, we should fix that. | 709 // FIXME: The childNeedsDistributionRecalc bit means either self or children
, we should fix that. |
| 741 if (childNeedsDistributionRecalc()) | 710 if (childNeedsDistributionRecalc()) |
| 742 return true; | 711 return true; |
| 743 if (DocumentAnimations::needsOutdatedAnimationPlayerUpdate(*this)) | |
| 744 return true; | |
| 745 return false; | 712 return false; |
| 746 } | 713 } |
| 747 | 714 |
| 748 bool Document::shouldScheduleRenderTreeUpdate() const | 715 bool Document::shouldScheduleRenderTreeUpdate() const |
| 749 { | 716 { |
| 750 if (!isActive()) | 717 if (!isActive()) |
| 751 return false; | 718 return false; |
| 752 if (inStyleRecalc()) | 719 if (inStyleRecalc()) |
| 753 return false; | 720 return false; |
| 754 // InPreLayout will recalc style itself. There's no reason to schedule anoth
er recalc. | 721 // InPreLayout will recalc style itself. There's no reason to schedule anoth
er recalc. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 765 | 732 |
| 766 scheduleVisualUpdate(); | 733 scheduleVisualUpdate(); |
| 767 | 734 |
| 768 // TODO(esprehn): We should either rename this state, or change the other | 735 // TODO(esprehn): We should either rename this state, or change the other |
| 769 // users of scheduleVisualUpdate() so they don't expect different states. | 736 // users of scheduleVisualUpdate() so they don't expect different states. |
| 770 m_lifecycle.ensureStateAtMost(DocumentLifecycle::VisualUpdatePending); | 737 m_lifecycle.ensureStateAtMost(DocumentLifecycle::VisualUpdatePending); |
| 771 } | 738 } |
| 772 | 739 |
| 773 void Document::scheduleVisualUpdate() | 740 void Document::scheduleVisualUpdate() |
| 774 { | 741 { |
| 775 if (page()) | |
| 776 page()->animator().scheduleVisualUpdate(); | |
| 777 } | 742 } |
| 778 | 743 |
| 779 void Document::updateDistributionIfNeeded() | 744 void Document::updateDistributionIfNeeded() |
| 780 { | 745 { |
| 781 ScriptForbiddenScope forbidScript; | 746 ScriptForbiddenScope forbidScript; |
| 782 | 747 |
| 783 if (!childNeedsDistributionRecalc()) | 748 if (!childNeedsDistributionRecalc()) |
| 784 return; | 749 return; |
| 785 TRACE_EVENT0("blink", "Document::updateDistributionIfNeeded"); | 750 TRACE_EVENT0("blink", "Document::updateDistributionIfNeeded"); |
| 786 recalcDistribution(); | 751 recalcDistribution(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 | 799 |
| 835 // Script can run below in WidgetUpdates, so protect the LocalFrame. | 800 // Script can run below in WidgetUpdates, so protect the LocalFrame. |
| 836 // FIXME: Can this still happen? How does script run inside | 801 // FIXME: Can this still happen? How does script run inside |
| 837 // UpdateSuspendScope::performDeferredWidgetTreeOperations() ? | 802 // UpdateSuspendScope::performDeferredWidgetTreeOperations() ? |
| 838 RefPtr<LocalFrame> protect(m_frame); | 803 RefPtr<LocalFrame> protect(m_frame); |
| 839 | 804 |
| 840 TRACE_EVENT0("blink", "Document::updateRenderTree"); | 805 TRACE_EVENT0("blink", "Document::updateRenderTree"); |
| 841 | 806 |
| 842 m_styleRecalcElementCounter = 0; | 807 m_styleRecalcElementCounter = 0; |
| 843 | 808 |
| 844 DocumentAnimations::updateOutdatedAnimationPlayersIfNeeded(*this); | |
| 845 evaluateMediaQueryListIfNeeded(); | 809 evaluateMediaQueryListIfNeeded(); |
| 846 updateDistributionIfNeeded(); | 810 updateDistributionIfNeeded(); |
| 847 | 811 |
| 848 // FIXME: We should update style on our ancestor chain before proceeding | 812 // FIXME: We should update style on our ancestor chain before proceeding |
| 849 // however doing so currently causes several tests to crash, as LocalFrame::
setDocument calls Document::attach | 813 // however doing so currently causes several tests to crash, as LocalFrame::
setDocument calls Document::attach |
| 850 // before setting the LocalDOMWindow on the LocalFrame, or the SecurityOrigi
n on the document. The attach, in turn | 814 // before setting the LocalDOMWindow on the LocalFrame, or the SecurityOrigi
n on the document. The attach, in turn |
| 851 // resolves style (here) and then when we resolve style on the parent chain,
we may end up | 815 // resolves style (here) and then when we resolve style on the parent chain,
we may end up |
| 852 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed | 816 // re-attaching our containing iframe, which when asked HTMLFrameElementBase
::isURLAllowed |
| 853 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. | 817 // hits a null-dereference due to security code always assuming the document
has a SecurityOrigin. |
| 854 | 818 |
| 855 updateStyle(change); | 819 updateStyle(change); |
| 856 | 820 |
| 857 if (m_focusedElement && !m_focusedElement->isFocusable()) | 821 if (m_focusedElement && !m_focusedElement->isFocusable()) |
| 858 clearFocusedElementSoon(); | 822 clearFocusedElementSoon(); |
| 859 | |
| 860 ASSERT(!m_timeline->hasOutdatedAnimationPlayer()); | |
| 861 } | 823 } |
| 862 | 824 |
| 863 void Document::updateStyle(StyleRecalcChange change) | 825 void Document::updateStyle(StyleRecalcChange change) |
| 864 { | 826 { |
| 865 TRACE_EVENT0("blink", "Document::updateStyle"); | 827 TRACE_EVENT0("blink", "Document::updateStyle"); |
| 866 | 828 |
| 867 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); | 829 m_lifecycle.advanceTo(DocumentLifecycle::InStyleRecalc); |
| 868 | 830 |
| 869 if (styleChangeType() >= SubtreeStyleChange) | 831 if (styleChangeType() >= SubtreeStyleChange) |
| 870 change = Force; | 832 change = Force; |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 RefPtr<Event> event = Event::create(EventTypeNames::resize); | 1531 RefPtr<Event> event = Event::create(EventTypeNames::resize); |
| 1570 event->setTarget(domWindow()); | 1532 event->setTarget(domWindow()); |
| 1571 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release()); | 1533 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release()); |
| 1572 } | 1534 } |
| 1573 | 1535 |
| 1574 void Document::enqueueMediaQueryChangeListeners(Vector<RefPtr<MediaQueryListList
ener> >& listeners) | 1536 void Document::enqueueMediaQueryChangeListeners(Vector<RefPtr<MediaQueryListList
ener> >& listeners) |
| 1575 { | 1537 { |
| 1576 ensureScriptedAnimationController().enqueueMediaQueryChangeListeners(listene
rs); | 1538 ensureScriptedAnimationController().enqueueMediaQueryChangeListeners(listene
rs); |
| 1577 } | 1539 } |
| 1578 | 1540 |
| 1579 void Document::addListenerTypeIfNeeded(const AtomicString& eventType) | |
| 1580 { | |
| 1581 if (eventType == EventTypeNames::animationstart) { | |
| 1582 addListenerType(ANIMATIONSTART_LISTENER); | |
| 1583 } else if (eventType == EventTypeNames::animationend) { | |
| 1584 addListenerType(ANIMATIONEND_LISTENER); | |
| 1585 } else if (eventType == EventTypeNames::animationiteration) { | |
| 1586 addListenerType(ANIMATIONITERATION_LISTENER); | |
| 1587 } else if (eventType == EventTypeNames::transitionend) { | |
| 1588 addListenerType(TRANSITIONEND_LISTENER); | |
| 1589 } | |
| 1590 } | |
| 1591 | |
| 1592 const AtomicString& Document::referrer() const | 1541 const AtomicString& Document::referrer() const |
| 1593 { | 1542 { |
| 1594 return nullAtom; | 1543 return nullAtom; |
| 1595 } | 1544 } |
| 1596 | 1545 |
| 1597 static bool isValidNameNonASCII(const LChar* characters, unsigned length) | 1546 static bool isValidNameNonASCII(const LChar* characters, unsigned length) |
| 1598 { | 1547 { |
| 1599 if (!isValidNameStart(characters[0])) | 1548 if (!isValidNameStart(characters[0])) |
| 1600 return false; | 1549 return false; |
| 1601 | 1550 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 return static_cast<DocumentLifecycleNotifier&>(LifecycleContext<Document>::l
ifecycleNotifier()); | 1885 return static_cast<DocumentLifecycleNotifier&>(LifecycleContext<Document>::l
ifecycleNotifier()); |
| 1937 } | 1886 } |
| 1938 | 1887 |
| 1939 Element* Document::activeElement() const | 1888 Element* Document::activeElement() const |
| 1940 { | 1889 { |
| 1941 if (Element* element = treeScope().adjustedFocusedElement()) | 1890 if (Element* element = treeScope().adjustedFocusedElement()) |
| 1942 return element; | 1891 return element; |
| 1943 return nullptr; | 1892 return nullptr; |
| 1944 } | 1893 } |
| 1945 | 1894 |
| 1946 void Document::getTransitionElementData(Vector<TransitionElementData>& elementDa
ta) | |
| 1947 { | |
| 1948 } | |
| 1949 | |
| 1950 bool Document::hasFocus() const | 1895 bool Document::hasFocus() const |
| 1951 { | 1896 { |
| 1952 Page* page = this->page(); | 1897 Page* page = this->page(); |
| 1953 if (!page) | 1898 if (!page) |
| 1954 return false; | 1899 return false; |
| 1955 if (!page->focusController().isActive() || !page->focusController().isFocuse
d()) | 1900 if (!page->focusController().isActive() || !page->focusController().isFocuse
d()) |
| 1956 return false; | 1901 return false; |
| 1957 Frame* focusedFrame = page->focusController().focusedFrame(); | 1902 Frame* focusedFrame = page->focusController().focusedFrame(); |
| 1958 return focusedFrame && focusedFrame == frame(); | 1903 return focusedFrame && focusedFrame == frame(); |
| 1959 } | 1904 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1975 using namespace blink; | 1920 using namespace blink; |
| 1976 void showLiveDocumentInstances() | 1921 void showLiveDocumentInstances() |
| 1977 { | 1922 { |
| 1978 WeakDocumentSet& set = liveDocumentSet(); | 1923 WeakDocumentSet& set = liveDocumentSet(); |
| 1979 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 1924 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 1980 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { | 1925 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { |
| 1981 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); | 1926 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); |
| 1982 } | 1927 } |
| 1983 } | 1928 } |
| 1984 #endif | 1929 #endif |
| OLD | NEW |