| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 using namespace HTMLNames; | 242 using namespace HTMLNames; |
| 243 | 243 |
| 244 static const unsigned cMaxWriteRecursionDepth = 21; | 244 static const unsigned cMaxWriteRecursionDepth = 21; |
| 245 | 245 |
| 246 // This amount of time must have elapsed before we will even consider scheduling
a layout without a delay. | 246 // This amount of time must have elapsed before we will even consider scheduling
a layout without a delay. |
| 247 // FIXME: For faster machines this value can really be lowered to 200. 250 is a
dequate, but a little high | 247 // FIXME: For faster machines this value can really be lowered to 200. 250 is a
dequate, but a little high |
| 248 // for dual G5s. :) | 248 // for dual G5s. :) |
| 249 static const int cLayoutScheduleThreshold = 250; | 249 static const int cLayoutScheduleThreshold = 250; |
| 250 | 250 |
| 251 namespace { |
| 252 |
| 253 void updateViewportApplyScroll(Element* documentElement) |
| 254 { |
| 255 if (!documentElement |
| 256 || !documentElement->isHTMLElement() |
| 257 || documentElement->document().ownerElement()) |
| 258 return; |
| 259 |
| 260 if (documentElement->getApplyScroll()) |
| 261 return; |
| 262 |
| 263 ScrollStateCallback* applyScroll = |
| 264 new ViewportScrollCallback(documentElement->document()); |
| 265 |
| 266 // Use disable-native-scroll since the ViewportScrollCallback needs to |
| 267 // apply scroll actions before (TopControls) and after (overscroll) |
| 268 // scrolling the element so it applies scroll to the element itself. |
| 269 documentElement->setApplyScroll( |
| 270 applyScroll, |
| 271 "disable-native-scroll"); |
| 272 } |
| 273 |
| 274 } // namespace |
| 275 |
| 251 // DOM Level 2 says (letters added): | 276 // DOM Level 2 says (letters added): |
| 252 // | 277 // |
| 253 // a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl. | 278 // a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl. |
| 254 // b) Name characters other than Name-start characters must have one of the cate
gories Mc, Me, Mn, Lm, or Nd. | 279 // b) Name characters other than Name-start characters must have one of the cate
gories Mc, Me, Mn, Lm, or Nd. |
| 255 // c) Characters in the compatibility area (i.e. with character code greater tha
n #xF900 and less than #xFFFE) are not allowed in XML names. | 280 // c) Characters in the compatibility area (i.e. with character code greater tha
n #xF900 and less than #xFFFE) are not allowed in XML names. |
| 256 // d) Characters which have a font or compatibility decomposition (i.e. those wi
th a "compatibility formatting tag" in field 5 of the database -- marked by fiel
d 5 beginning with a "<") are not allowed. | 281 // d) Characters which have a font or compatibility decomposition (i.e. those wi
th a "compatibility formatting tag" in field 5 of the database -- marked by fiel
d 5 beginning with a "<") are not allowed. |
| 257 // e) The following characters are treated as name-start characters rather than
name characters, because the property file classifies them as Alphabetic: [#x02B
B-#x02C1], #x0559, #x06E5, #x06E6. | 282 // e) The following characters are treated as name-start characters rather than
name characters, because the property file classifies them as Alphabetic: [#x02B
B-#x02C1], #x0559, #x06E5, #x06E6. |
| 258 // f) Characters #x20DD-#x20E0 are excluded (in accordance with Unicode, section
5.14). | 283 // f) Characters #x20DD-#x20E0 are excluded (in accordance with Unicode, section
5.14). |
| 259 // g) Character #x00B7 is classified as an extender, because the property list s
o identifies it. | 284 // g) Character #x00B7 is classified as an extender, because the property list s
o identifies it. |
| 260 // h) Character #x0387 is added as a name character, because #x00B7 is its canon
ical equivalent. | 285 // h) Character #x0387 is added as a name character, because #x00B7 is its canon
ical equivalent. |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 if (!frame()) | 602 if (!frame()) |
| 578 return 0; | 603 return 0; |
| 579 | 604 |
| 580 return domWindow()->location(); | 605 return domWindow()->location(); |
| 581 } | 606 } |
| 582 | 607 |
| 583 void Document::childrenChanged(const ChildrenChange& change) | 608 void Document::childrenChanged(const ChildrenChange& change) |
| 584 { | 609 { |
| 585 ContainerNode::childrenChanged(change); | 610 ContainerNode::childrenChanged(change); |
| 586 m_documentElement = ElementTraversal::firstWithin(*this); | 611 m_documentElement = ElementTraversal::firstWithin(*this); |
| 587 } | |
| 588 | 612 |
| 589 void Document::updateViewportApplyScroll() | 613 // Installs the viewport scrolling callback (the "applyScroll" in Scroll |
| 590 { | 614 // Customization lingo) on the documentElement. This callback is |
| 591 if (!m_documentElement | 615 // responsible for viewport related scroll actions like top controls |
| 592 || !m_documentElement->isHTMLElement() | 616 // movement and overscroll glow as well as actually scrolling the root |
| 593 || ownerElement()) | 617 // viewport. |
| 594 return; | 618 updateViewportApplyScroll(m_documentElement); |
| 595 | |
| 596 Element* newScrollingElement = scrollingElement(); | |
| 597 | |
| 598 // If there is no scrolling element (in QuirksMode and body is scrollable), | |
| 599 // install the viewport scroll callback on the <HTML> element. | |
| 600 if (!newScrollingElement) | |
| 601 newScrollingElement = m_documentElement; | |
| 602 | |
| 603 if (newScrollingElement == m_oldScrollingElement) | |
| 604 return; | |
| 605 | |
| 606 ScrollStateCallback* applyScroll = nullptr; | |
| 607 | |
| 608 // If the scrolling element changed, remove the apply scroll from the | |
| 609 // old one and keep it to put on the new scrolling element. | |
| 610 if (m_oldScrollingElement) { | |
| 611 applyScroll = m_oldScrollingElement->getApplyScroll(); | |
| 612 m_oldScrollingElement->removeApplyScroll(); | |
| 613 } | |
| 614 | |
| 615 if (newScrollingElement) { | |
| 616 if (!applyScroll) | |
| 617 applyScroll = new ViewportScrollCallback(*this, *frameHost()); | |
| 618 | |
| 619 // Use disable-native-scroll since the ViewportScrollCallback needs to | |
| 620 // apply scroll actions before (TopControls) and after (overscroll) | |
| 621 // scrolling the element so it applies scroll to the element itself. | |
| 622 newScrollingElement->setApplyScroll( | |
| 623 applyScroll, | |
| 624 "disable-native-scroll"); | |
| 625 } | |
| 626 | |
| 627 m_oldScrollingElement = newScrollingElement; | |
| 628 } | 619 } |
| 629 | 620 |
| 630 AtomicString Document::convertLocalName(const AtomicString& name) | 621 AtomicString Document::convertLocalName(const AtomicString& name) |
| 631 { | 622 { |
| 632 return isHTMLDocument() ? name.lower() : name; | 623 return isHTMLDocument() ? name.lower() : name; |
| 633 } | 624 } |
| 634 | 625 |
| 635 Element* Document::createElement(const AtomicString& name, ExceptionState& excep
tionState) | 626 Element* Document::createElement(const AtomicString& name, ExceptionState& excep
tionState) |
| 636 { | 627 { |
| 637 if (!isValidName(name)) { | 628 if (!isValidName(name)) { |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 | 1889 |
| 1899 if (frameView->needsLayout()) | 1890 if (frameView->needsLayout()) |
| 1900 frameView->layout(); | 1891 frameView->layout(); |
| 1901 | 1892 |
| 1902 if (lifecycle().state() < DocumentLifecycle::LayoutClean) | 1893 if (lifecycle().state() < DocumentLifecycle::LayoutClean) |
| 1903 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); | 1894 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); |
| 1904 } | 1895 } |
| 1905 | 1896 |
| 1906 void Document::layoutUpdated() | 1897 void Document::layoutUpdated() |
| 1907 { | 1898 { |
| 1908 updateViewportApplyScroll(); | |
| 1909 | |
| 1910 // Plugins can run script inside layout which can detach the page. | 1899 // Plugins can run script inside layout which can detach the page. |
| 1911 // TODO(esprehn): Can this still happen now that all plugins are out of | 1900 // TODO(esprehn): Can this still happen now that all plugins are out of |
| 1912 // process? | 1901 // process? |
| 1913 if (frame() && frame()->page()) | 1902 if (frame() && frame()->page()) |
| 1914 frame()->page()->chromeClient().layoutUpdated(frame()); | 1903 frame()->page()->chromeClient().layoutUpdated(frame()); |
| 1915 | 1904 |
| 1916 markers().updateRenderedRectsForMarkers(); | 1905 markers().updateRenderedRectsForMarkers(); |
| 1917 | 1906 |
| 1918 // The layout system may perform layouts with pending stylesheets. When | 1907 // The layout system may perform layouts with pending stylesheets. When |
| 1919 // recording first layout time, we ignore these layouts, since painting is | 1908 // recording first layout time, we ignore these layouts, since painting is |
| (...skipping 3948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5868 visitor->trace(m_styleEngine); | 5857 visitor->trace(m_styleEngine); |
| 5869 visitor->trace(m_formController); | 5858 visitor->trace(m_formController); |
| 5870 visitor->trace(m_visitedLinkState); | 5859 visitor->trace(m_visitedLinkState); |
| 5871 visitor->trace(m_frame); | 5860 visitor->trace(m_frame); |
| 5872 visitor->trace(m_domWindow); | 5861 visitor->trace(m_domWindow); |
| 5873 visitor->trace(m_fetcher); | 5862 visitor->trace(m_fetcher); |
| 5874 visitor->trace(m_parser); | 5863 visitor->trace(m_parser); |
| 5875 visitor->trace(m_contextFeatures); | 5864 visitor->trace(m_contextFeatures); |
| 5876 visitor->trace(m_styleSheetList); | 5865 visitor->trace(m_styleSheetList); |
| 5877 visitor->trace(m_documentTiming); | 5866 visitor->trace(m_documentTiming); |
| 5878 visitor->trace(m_oldScrollingElement); | |
| 5879 visitor->trace(m_mediaQueryMatcher); | 5867 visitor->trace(m_mediaQueryMatcher); |
| 5880 visitor->trace(m_scriptedAnimationController); | 5868 visitor->trace(m_scriptedAnimationController); |
| 5881 visitor->trace(m_scriptedIdleTaskController); | 5869 visitor->trace(m_scriptedIdleTaskController); |
| 5882 visitor->trace(m_taskRunner); | 5870 visitor->trace(m_taskRunner); |
| 5883 visitor->trace(m_textAutosizer); | 5871 visitor->trace(m_textAutosizer); |
| 5884 visitor->trace(m_registrationContext); | 5872 visitor->trace(m_registrationContext); |
| 5885 visitor->trace(m_customElementMicrotaskRunQueue); | 5873 visitor->trace(m_customElementMicrotaskRunQueue); |
| 5886 visitor->trace(m_elementDataCache); | 5874 visitor->trace(m_elementDataCache); |
| 5887 visitor->trace(m_associatedFormControls); | 5875 visitor->trace(m_associatedFormControls); |
| 5888 visitor->trace(m_useElementsNeedingUpdate); | 5876 visitor->trace(m_useElementsNeedingUpdate); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5914 #ifndef NDEBUG | 5902 #ifndef NDEBUG |
| 5915 using namespace blink; | 5903 using namespace blink; |
| 5916 void showLiveDocumentInstances() | 5904 void showLiveDocumentInstances() |
| 5917 { | 5905 { |
| 5918 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5906 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 5919 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5907 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5920 for (Document* document : set) | 5908 for (Document* document : set) |
| 5921 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 5909 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
| 5922 } | 5910 } |
| 5923 #endif | 5911 #endif |
| OLD | NEW |