| 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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 // insert one), so we resume here too. That does mean XHTML documents make | 591 // insert one), so we resume here too. That does mean XHTML documents make |
| 592 // frames when there's only a <head>, but such documents are pretty rare. | 592 // frames when there's only a <head>, but such documents are pretty rare. |
| 593 if (m_documentElement && !isHTMLDocument()) | 593 if (m_documentElement && !isHTMLDocument()) |
| 594 beginLifecycleUpdatesIfRenderingReady(); | 594 beginLifecycleUpdatesIfRenderingReady(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt
ate) | 597 void Document::setRootScroller(Element* newScroller, ExceptionState& exceptionSt
ate) |
| 598 { | 598 { |
| 599 DCHECK(newScroller); | 599 DCHECK(newScroller); |
| 600 | 600 |
| 601 if (ownerElement()) { | 601 if (!frame() || !frame()->isMainFrame()) { |
| 602 exceptionState.throwDOMException( | 602 exceptionState.throwDOMException( |
| 603 WrongDocumentError, | 603 WrongDocumentError, |
| 604 "Root scroller cannot be set on a document within a frame."); | 604 "Root scroller can only be set on the top window's document."); |
| 605 return; | 605 return; |
| 606 } | 606 } |
| 607 | 607 |
| 608 if (newScroller->document() != this) { | 608 if (newScroller->document() != this) { |
| 609 exceptionState.throwDOMException( | 609 exceptionState.throwDOMException( |
| 610 WrongDocumentError, | 610 WrongDocumentError, |
| 611 "Element isn't in this document."); | 611 "Element isn't in this document."); |
| 612 return; | 612 return; |
| 613 } | 613 } |
| 614 | 614 |
| 615 FrameHost* host = frameHost(); | 615 FrameHost* host = frameHost(); |
| 616 if (!host) | 616 if (!host) |
| 617 return; | 617 return; |
| 618 | 618 |
| 619 RootScroller* rootScroller = host->rootScroller(); | 619 RootScroller* rootScroller = host->rootScroller(); |
| 620 DCHECK(rootScroller); | 620 DCHECK(rootScroller); |
| 621 | 621 |
| 622 if (!rootScroller->set(*newScroller)) { | 622 if (!rootScroller->set(*newScroller)) { |
| 623 exceptionState.throwDOMException( | 623 exceptionState.throwDOMException( |
| 624 InvalidStateError, | 624 InvalidStateError, |
| 625 "Element cannot be set as root scroller. Must be block or iframe."); | 625 "Element cannot be set as root scroller. Must be block or iframe."); |
| 626 } | 626 } |
| 627 } | 627 } |
| 628 | 628 |
| 629 Element* Document::rootScroller() | 629 Element* Document::rootScroller() |
| 630 { | 630 { |
| 631 if (ownerElement()) | 631 // TODO(bokan): Should child frames return the documentElement or nullptr? |
| 632 if (!isInMainFrame()) |
| 632 return documentElement(); | 633 return documentElement(); |
| 633 | 634 |
| 634 FrameHost* host = frameHost(); | 635 FrameHost* host = frameHost(); |
| 635 if (!host) | 636 if (!host) |
| 636 return nullptr; | 637 return nullptr; |
| 637 | 638 |
| 638 RootScroller* rootScroller = host->rootScroller(); | 639 RootScroller* rootScroller = host->rootScroller(); |
| 639 DCHECK(rootScroller); | 640 DCHECK(rootScroller); |
| 640 | 641 |
| 641 updateLayoutIgnorePendingStylesheets(); | 642 updateLayoutIgnorePendingStylesheets(); |
| 642 | 643 |
| 643 return rootScroller->get(); | 644 return rootScroller->get(); |
| 644 } | 645 } |
| 645 | 646 |
| 647 bool Document::isInMainFrame() const |
| 648 { |
| 649 return frame() && frame()->isMainFrame(); |
| 650 } |
| 651 |
| 646 AtomicString Document::convertLocalName(const AtomicString& name) | 652 AtomicString Document::convertLocalName(const AtomicString& name) |
| 647 { | 653 { |
| 648 return isHTMLDocument() ? name.lower() : name; | 654 return isHTMLDocument() ? name.lower() : name; |
| 649 } | 655 } |
| 650 | 656 |
| 651 Element* Document::createElement(const AtomicString& name, ExceptionState& excep
tionState) | 657 Element* Document::createElement(const AtomicString& name, ExceptionState& excep
tionState) |
| 652 { | 658 { |
| 653 if (!isValidName(name)) { | 659 if (!isValidName(name)) { |
| 654 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr
ovided ('" + name + "') is not a valid name."); | 660 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr
ovided ('" + name + "') is not a valid name."); |
| 655 return nullptr; | 661 return nullptr; |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1879 | 1885 |
| 1880 ScriptForbiddenScope forbidScript; | 1886 ScriptForbiddenScope forbidScript; |
| 1881 | 1887 |
| 1882 FrameView* frameView = view(); | 1888 FrameView* frameView = view(); |
| 1883 if (frameView && frameView->isInPerformLayout()) { | 1889 if (frameView && frameView->isInPerformLayout()) { |
| 1884 // View layout should not be re-entrant. | 1890 // View layout should not be re-entrant. |
| 1885 ASSERT_NOT_REACHED(); | 1891 ASSERT_NOT_REACHED(); |
| 1886 return; | 1892 return; |
| 1887 } | 1893 } |
| 1888 | 1894 |
| 1889 if (HTMLFrameOwnerElement* owner = ownerElement()) | 1895 if (HTMLFrameOwnerElement* owner = localOwner()) |
| 1890 owner->document().updateLayout(); | 1896 owner->document().updateLayout(); |
| 1891 | 1897 |
| 1892 updateLayoutTree(); | 1898 updateLayoutTree(); |
| 1893 | 1899 |
| 1894 if (!isActive()) | 1900 if (!isActive()) |
| 1895 return; | 1901 return; |
| 1896 | 1902 |
| 1897 if (frameView->needsLayout()) | 1903 if (frameView->needsLayout()) |
| 1898 frameView->layout(); | 1904 frameView->layout(); |
| 1899 | 1905 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1917 // first real or 'paintable' layout. | 1923 // first real or 'paintable' layout. |
| 1918 // TODO(esprehn): This doesn't really make sense, why not track the first | 1924 // TODO(esprehn): This doesn't really make sense, why not track the first |
| 1919 // beginFrame? This will catch the first layout in a page that does lots | 1925 // beginFrame? This will catch the first layout in a page that does lots |
| 1920 // of layout thrashing even though that layout might not be followed by | 1926 // of layout thrashing even though that layout might not be followed by |
| 1921 // a paint for many seconds. | 1927 // a paint for many seconds. |
| 1922 if (isRenderingReady() && body() && !styleEngine().hasPendingSheets()) { | 1928 if (isRenderingReady() && body() && !styleEngine().hasPendingSheets()) { |
| 1923 if (!m_documentTiming.firstLayout()) | 1929 if (!m_documentTiming.firstLayout()) |
| 1924 m_documentTiming.markFirstLayout(); | 1930 m_documentTiming.markFirstLayout(); |
| 1925 } | 1931 } |
| 1926 | 1932 |
| 1927 if (!ownerElement() && frameHost()) { | 1933 if (isInMainFrame() && frameHost()) { |
| 1928 if (RootScroller* rootScroller = frameHost()->rootScroller()) | 1934 DCHECK(frameHost()->rootScroller()); |
| 1929 rootScroller->didUpdateTopDocumentLayout(); | 1935 frameHost()->rootScroller()->didUpdateTopDocumentLayout(); |
| 1930 } | 1936 } |
| 1931 } | 1937 } |
| 1932 | 1938 |
| 1933 void Document::setNeedsFocusedElementCheck() | 1939 void Document::setNeedsFocusedElementCheck() |
| 1934 { | 1940 { |
| 1935 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit
hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); | 1941 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit
hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); |
| 1936 } | 1942 } |
| 1937 | 1943 |
| 1938 void Document::clearFocusedElementSoon() | 1944 void Document::clearFocusedElementSoon() |
| 1939 { | 1945 { |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 if (frame()->navigationScheduler().locationChangePending() && elapsedTime()
< cLayoutScheduleThreshold) { | 2648 if (frame()->navigationScheduler().locationChangePending() && elapsedTime()
< cLayoutScheduleThreshold) { |
| 2643 // Just bail out. Before or during the onload we were shifted to another
page. | 2649 // Just bail out. Before or during the onload we were shifted to another
page. |
| 2644 // The old i-Bench suite does this. When this happens don't bother paint
ing or laying out. | 2650 // The old i-Bench suite does this. When this happens don't bother paint
ing or laying out. |
| 2645 m_loadEventProgress = LoadEventCompleted; | 2651 m_loadEventProgress = LoadEventCompleted; |
| 2646 return; | 2652 return; |
| 2647 } | 2653 } |
| 2648 | 2654 |
| 2649 // We used to force a synchronous display and flush here. This really isn't | 2655 // We used to force a synchronous display and flush here. This really isn't |
| 2650 // necessary and can in fact be actively harmful if pages are loading at a r
ate of > 60fps | 2656 // necessary and can in fact be actively harmful if pages are loading at a r
ate of > 60fps |
| 2651 // (if your platform is syncing flushes and limiting them to 60fps). | 2657 // (if your platform is syncing flushes and limiting them to 60fps). |
| 2652 if (!ownerElement() || (ownerElement()->layoutObject() && !ownerElement()->l
ayoutObject()->needsLayout())) { | 2658 if (!localOwner() || (localOwner()->layoutObject() && !localOwner()->layoutO
bject()->needsLayout())) { |
| 2653 updateLayoutTree(); | 2659 updateLayoutTree(); |
| 2654 | 2660 |
| 2655 // Always do a layout after loading if needed. | 2661 // Always do a layout after loading if needed. |
| 2656 if (view() && layoutView() && (!layoutView()->firstChild() || layoutView
()->needsLayout())) | 2662 if (view() && layoutView() && (!layoutView()->firstChild() || layoutView
()->needsLayout())) |
| 2657 view()->layout(); | 2663 view()->layout(); |
| 2658 } | 2664 } |
| 2659 | 2665 |
| 2660 m_loadEventProgress = LoadEventCompleted; | 2666 m_loadEventProgress = LoadEventCompleted; |
| 2661 | 2667 |
| 2662 if (frame() && layoutView() && settings()->accessibilityEnabled()) { | 2668 if (frame() && layoutView() && settings()->accessibilityEnabled()) { |
| (...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4025 // Need to re-evaluate time-to-effect-change for any running animati
ons. | 4031 // Need to re-evaluate time-to-effect-change for any running animati
ons. |
| 4026 view()->scheduleAnimation(); | 4032 view()->scheduleAnimation(); |
| 4027 } | 4033 } |
| 4028 } else if (eventType == EventTypeNames::webkitTransitionEnd || eventType ==
EventTypeNames::transitionend) { | 4034 } else if (eventType == EventTypeNames::webkitTransitionEnd || eventType ==
EventTypeNames::transitionend) { |
| 4029 addListenerType(TRANSITIONEND_LISTENER); | 4035 addListenerType(TRANSITIONEND_LISTENER); |
| 4030 } else if (eventType == EventTypeNames::scroll) { | 4036 } else if (eventType == EventTypeNames::scroll) { |
| 4031 addListenerType(SCROLL_LISTENER); | 4037 addListenerType(SCROLL_LISTENER); |
| 4032 } | 4038 } |
| 4033 } | 4039 } |
| 4034 | 4040 |
| 4035 HTMLFrameOwnerElement* Document::ownerElement() const | 4041 HTMLFrameOwnerElement* Document::localOwner() const |
| 4036 { | 4042 { |
| 4037 if (!frame()) | 4043 if (!frame()) |
| 4038 return 0; | 4044 return 0; |
| 4039 // FIXME: This probably breaks the attempts to layout after a load is finish
ed in implicitClose(), and probably tons of other things... | 4045 // FIXME: This probably breaks the attempts to layout after a load is finish
ed in implicitClose(), and probably tons of other things... |
| 4040 return frame()->deprecatedLocalOwner(); | 4046 return frame()->deprecatedLocalOwner(); |
| 4041 } | 4047 } |
| 4042 | 4048 |
| 4043 bool Document::isInInvisibleSubframe() const | 4049 bool Document::isInInvisibleSubframe() const |
| 4044 { | 4050 { |
| 4045 if (!ownerElement()) | 4051 if (!localOwner()) |
| 4046 return false; // this is the root element | 4052 return false; // this is a local root element |
| 4047 | 4053 |
| 4054 // TODO(bokan): This looks like it doesn't work in OOPIF. |
| 4048 DCHECK(frame()); | 4055 DCHECK(frame()); |
| 4049 return !frame()->ownerLayoutObject(); | 4056 return !frame()->ownerLayoutObject(); |
| 4050 } | 4057 } |
| 4051 | 4058 |
| 4052 String Document::cookie(ExceptionState& exceptionState) const | 4059 String Document::cookie(ExceptionState& exceptionState) const |
| 4053 { | 4060 { |
| 4054 if (settings() && !settings()->cookieEnabled()) | 4061 if (settings() && !settings()->cookieEnabled()) |
| 4055 return String(); | 4062 return String(); |
| 4056 | 4063 |
| 4057 // FIXME: The HTML5 DOM spec states that this attribute can raise an | 4064 // FIXME: The HTML5 DOM spec states that this attribute can raise an |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4626 if (!parent || !parent->isLocalFrame()) | 4633 if (!parent || !parent->isLocalFrame()) |
| 4627 return 0; | 4634 return 0; |
| 4628 return toLocalFrame(parent)->document(); | 4635 return toLocalFrame(parent)->document(); |
| 4629 } | 4636 } |
| 4630 | 4637 |
| 4631 Document& Document::topDocument() const | 4638 Document& Document::topDocument() const |
| 4632 { | 4639 { |
| 4633 // FIXME: Not clear what topDocument() should do in the OOPI case--should it
return the topmost | 4640 // FIXME: Not clear what topDocument() should do in the OOPI case--should it
return the topmost |
| 4634 // available Document, or something else? | 4641 // available Document, or something else? |
| 4635 Document* doc = const_cast<Document*>(this); | 4642 Document* doc = const_cast<Document*>(this); |
| 4636 for (HTMLFrameOwnerElement* element = doc->ownerElement(); element; element
= doc->ownerElement()) | 4643 for (HTMLFrameOwnerElement* element = doc->localOwner(); element; element =
doc->localOwner()) |
| 4637 doc = &element->document(); | 4644 doc = &element->document(); |
| 4638 | 4645 |
| 4639 DCHECK(doc); | 4646 DCHECK(doc); |
| 4640 return *doc; | 4647 return *doc; |
| 4641 } | 4648 } |
| 4642 | 4649 |
| 4643 Document* Document::contextDocument() | 4650 Document* Document::contextDocument() |
| 4644 { | 4651 { |
| 4645 if (m_contextDocument) | 4652 if (m_contextDocument) |
| 4646 return m_contextDocument; | 4653 return m_contextDocument; |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5538 void Document::updateHoverActiveState(const HitTestRequest& request, Element* in
nerElement) | 5545 void Document::updateHoverActiveState(const HitTestRequest& request, Element* in
nerElement) |
| 5539 { | 5546 { |
| 5540 DCHECK(!request.readOnly()); | 5547 DCHECK(!request.readOnly()); |
| 5541 | 5548 |
| 5542 if (request.active() && m_frame) | 5549 if (request.active() && m_frame) |
| 5543 m_frame->eventHandler().notifyElementActivated(); | 5550 m_frame->eventHandler().notifyElementActivated(); |
| 5544 | 5551 |
| 5545 Element* innerElementInDocument = innerElement; | 5552 Element* innerElementInDocument = innerElement; |
| 5546 while (innerElementInDocument && innerElementInDocument->document() != this)
{ | 5553 while (innerElementInDocument && innerElementInDocument->document() != this)
{ |
| 5547 innerElementInDocument->document().updateHoverActiveState(request, inner
ElementInDocument); | 5554 innerElementInDocument->document().updateHoverActiveState(request, inner
ElementInDocument); |
| 5548 innerElementInDocument = innerElementInDocument->document().ownerElement
(); | 5555 innerElementInDocument = innerElementInDocument->document().localOwner()
; |
| 5549 } | 5556 } |
| 5550 | 5557 |
| 5551 updateDistribution(); | 5558 updateDistribution(); |
| 5552 Element* oldActiveElement = activeHoverElement(); | 5559 Element* oldActiveElement = activeHoverElement(); |
| 5553 if (oldActiveElement && !request.active()) { | 5560 if (oldActiveElement && !request.active()) { |
| 5554 // The oldActiveElement layoutObject is null, dropped on :active by sett
ing display: none, | 5561 // The oldActiveElement layoutObject is null, dropped on :active by sett
ing display: none, |
| 5555 // for instance. We still need to clear the ActiveChain as the mouse is
released. | 5562 // for instance. We still need to clear the ActiveChain as the mouse is
released. |
| 5556 for (Node* node = oldActiveElement; node; node = FlatTreeTraversal::pare
nt(*node)) { | 5563 for (Node* node = oldActiveElement; node; node = FlatTreeTraversal::pare
nt(*node)) { |
| 5557 DCHECK(!node->isTextNode()); | 5564 DCHECK(!node->isTextNode()); |
| 5558 node->setActive(false); | 5565 node->setActive(false); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5969 #ifndef NDEBUG | 5976 #ifndef NDEBUG |
| 5970 using namespace blink; | 5977 using namespace blink; |
| 5971 void showLiveDocumentInstances() | 5978 void showLiveDocumentInstances() |
| 5972 { | 5979 { |
| 5973 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5980 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 5974 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5981 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5975 for (Document* document : set) | 5982 for (Document* document : set) |
| 5976 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 5983 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
| 5977 } | 5984 } |
| 5978 #endif | 5985 #endif |
| OLD | NEW |