| 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 m_docType = docType; | 651 m_docType = docType; |
| 652 if (m_docType) { | 652 if (m_docType) { |
| 653 this->adoptIfNeeded(*m_docType); | 653 this->adoptIfNeeded(*m_docType); |
| 654 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.",
TextCaseInsensitive)) | 654 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.",
TextCaseInsensitive)) |
| 655 m_isMobileDocument = true; | 655 m_isMobileDocument = true; |
| 656 } | 656 } |
| 657 // Doctype affects the interpretation of the stylesheets. | 657 // Doctype affects the interpretation of the stylesheets. |
| 658 styleEngine().clearResolver(); | 658 styleEngine().clearResolver(); |
| 659 } | 659 } |
| 660 | 660 |
| 661 DocumentType* Document::doctype() const |
| 662 { |
| 663 return m_docType.get(); |
| 664 } |
| 665 |
| 661 DOMImplementation& Document::implementation() | 666 DOMImplementation& Document::implementation() |
| 662 { | 667 { |
| 663 if (!m_implementation) | 668 if (!m_implementation) |
| 664 m_implementation = DOMImplementation::create(*this); | 669 m_implementation = DOMImplementation::create(*this); |
| 665 return *m_implementation; | 670 return *m_implementation; |
| 666 } | 671 } |
| 667 | 672 |
| 673 Element* Document::documentElement() const |
| 674 { |
| 675 return m_documentElement.get(); |
| 676 } |
| 677 |
| 668 bool Document::hasAppCacheManifest() const | 678 bool Document::hasAppCacheManifest() const |
| 669 { | 679 { |
| 670 return isHTMLHtmlElement(documentElement()) && documentElement()->hasAttribu
te(manifestAttr); | 680 return isHTMLHtmlElement(documentElement()) && documentElement()->hasAttribu
te(manifestAttr); |
| 671 } | 681 } |
| 672 | 682 |
| 673 Location* Document::location() const | 683 Location* Document::location() const |
| 674 { | 684 { |
| 675 if (!frame()) | 685 if (!frame()) |
| 676 return 0; | 686 return 0; |
| 677 | 687 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 if (!registrationContext()) { | 784 if (!registrationContext()) { |
| 775 exceptionState.throwDOMException(NotSupportedError, "No element registra
tion context is available."); | 785 exceptionState.throwDOMException(NotSupportedError, "No element registra
tion context is available."); |
| 776 return ScriptValue(); | 786 return ScriptValue(); |
| 777 } | 787 } |
| 778 | 788 |
| 779 CustomElementConstructorBuilder constructorBuilder(scriptState, options); | 789 CustomElementConstructorBuilder constructorBuilder(scriptState, options); |
| 780 registrationContext()->registerElement(this, &constructorBuilder, name, vali
dNames, exceptionState); | 790 registrationContext()->registerElement(this, &constructorBuilder, name, vali
dNames, exceptionState); |
| 781 return constructorBuilder.bindingsReturnValue(); | 791 return constructorBuilder.bindingsReturnValue(); |
| 782 } | 792 } |
| 783 | 793 |
| 794 CustomElementRegistrationContext* Document::registrationContext() const |
| 795 { |
| 796 return m_registrationContext.get(); |
| 797 } |
| 798 |
| 784 CustomElementMicrotaskRunQueue* Document::customElementMicrotaskRunQueue() | 799 CustomElementMicrotaskRunQueue* Document::customElementMicrotaskRunQueue() |
| 785 { | 800 { |
| 786 if (!m_customElementMicrotaskRunQueue) | 801 if (!m_customElementMicrotaskRunQueue) |
| 787 m_customElementMicrotaskRunQueue = CustomElementMicrotaskRunQueue::creat
e(); | 802 m_customElementMicrotaskRunQueue = CustomElementMicrotaskRunQueue::creat
e(); |
| 788 return m_customElementMicrotaskRunQueue.get(); | 803 return m_customElementMicrotaskRunQueue.get(); |
| 789 } | 804 } |
| 790 | 805 |
| 791 void Document::setImportsController(HTMLImportsController* controller) | 806 void Document::setImportsController(HTMLImportsController* controller) |
| 792 { | 807 { |
| 793 ASSERT(!m_importsController || !controller); | 808 ASSERT(!m_importsController || !controller); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 } else { | 1327 } else { |
| 1313 m_titleElement = titleElement; | 1328 m_titleElement = titleElement; |
| 1314 } | 1329 } |
| 1315 | 1330 |
| 1316 if (isHTMLTitleElement(m_titleElement)) | 1331 if (isHTMLTitleElement(m_titleElement)) |
| 1317 updateTitle(toHTMLTitleElement(m_titleElement)->text()); | 1332 updateTitle(toHTMLTitleElement(m_titleElement)->text()); |
| 1318 else if (isSVGTitleElement(m_titleElement)) | 1333 else if (isSVGTitleElement(m_titleElement)) |
| 1319 updateTitle(toSVGTitleElement(m_titleElement)->textContent()); | 1334 updateTitle(toSVGTitleElement(m_titleElement)->textContent()); |
| 1320 } | 1335 } |
| 1321 | 1336 |
| 1337 Element* Document::titleElement() const |
| 1338 { |
| 1339 return m_titleElement.get(); |
| 1340 } |
| 1341 |
| 1322 void Document::removeTitle(Element* titleElement) | 1342 void Document::removeTitle(Element* titleElement) |
| 1323 { | 1343 { |
| 1324 if (m_titleElement != titleElement) | 1344 if (m_titleElement != titleElement) |
| 1325 return; | 1345 return; |
| 1326 | 1346 |
| 1327 m_titleElement = nullptr; | 1347 m_titleElement = nullptr; |
| 1328 | 1348 |
| 1329 // Update title based on first title element in the document, if one exists. | 1349 // Update title based on first title element in the document, if one exists. |
| 1330 if (isHTMLDocument() || isXHTMLDocument()) { | 1350 if (isHTMLDocument() || isXHTMLDocument()) { |
| 1331 if (HTMLTitleElement* title = Traversal<HTMLTitleElement>::firstWithin(*
this)) | 1351 if (HTMLTitleElement* title = Traversal<HTMLTitleElement>::firstWithin(*
this)) |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 { | 1995 { |
| 1976 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit
hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); | 1996 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::createWit
hExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Focus)); |
| 1977 } | 1997 } |
| 1978 | 1998 |
| 1979 void Document::clearFocusedElementSoon() | 1999 void Document::clearFocusedElementSoon() |
| 1980 { | 2000 { |
| 1981 if (!m_clearFocusedElementTimer.isActive()) | 2001 if (!m_clearFocusedElementTimer.isActive()) |
| 1982 m_clearFocusedElementTimer.startOneShot(0, BLINK_FROM_HERE); | 2002 m_clearFocusedElementTimer.startOneShot(0, BLINK_FROM_HERE); |
| 1983 } | 2003 } |
| 1984 | 2004 |
| 2005 Element* Document::focusedElement() const |
| 2006 { |
| 2007 return m_focusedElement.get(); |
| 2008 } |
| 2009 |
| 1985 void Document::clearFocusedElementTimerFired(Timer<Document>*) | 2010 void Document::clearFocusedElementTimerFired(Timer<Document>*) |
| 1986 { | 2011 { |
| 1987 updateLayoutTreeIfNeeded(); | 2012 updateLayoutTreeIfNeeded(); |
| 1988 m_clearFocusedElementTimer.stop(); | 2013 m_clearFocusedElementTimer.stop(); |
| 1989 | 2014 |
| 1990 if (m_focusedElement && !m_focusedElement->isFocusable()) | 2015 if (m_focusedElement && !m_focusedElement->isFocusable()) |
| 1991 m_focusedElement->blur(); | 2016 m_focusedElement->blur(); |
| 1992 } | 2017 } |
| 1993 | 2018 |
| 1994 // FIXME: This is a bad idea and needs to be removed eventually. | 2019 // FIXME: This is a bad idea and needs to be removed eventually. |
| (...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3002 } | 3027 } |
| 3003 | 3028 |
| 3004 void Document::disableEval(const String& errorMessage) | 3029 void Document::disableEval(const String& errorMessage) |
| 3005 { | 3030 { |
| 3006 if (!frame()) | 3031 if (!frame()) |
| 3007 return; | 3032 return; |
| 3008 | 3033 |
| 3009 frame()->script().disableEval(errorMessage); | 3034 frame()->script().disableEval(errorMessage); |
| 3010 } | 3035 } |
| 3011 | 3036 |
| 3037 ElementDataCache* Document::elementDataCache() const |
| 3038 { |
| 3039 return m_elementDataCache.get(); |
| 3040 } |
| 3012 | 3041 |
| 3013 void Document::didLoadAllImports() | 3042 void Document::didLoadAllImports() |
| 3014 { | 3043 { |
| 3015 if (!haveStylesheetsLoaded()) | 3044 if (!haveStylesheetsLoaded()) |
| 3016 return; | 3045 return; |
| 3017 if (!importLoader()) | 3046 if (!importLoader()) |
| 3018 styleResolverMayHaveChanged(); | 3047 styleResolverMayHaveChanged(); |
| 3019 didLoadAllScriptBlockingResources(); | 3048 didLoadAllScriptBlockingResources(); |
| 3020 } | 3049 } |
| 3021 | 3050 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3321 setMimeType(other.contentType()); | 3350 setMimeType(other.contentType()); |
| 3322 } | 3351 } |
| 3323 | 3352 |
| 3324 StyleSheetList* Document::styleSheets() | 3353 StyleSheetList* Document::styleSheets() |
| 3325 { | 3354 { |
| 3326 if (!m_styleSheetList) | 3355 if (!m_styleSheetList) |
| 3327 m_styleSheetList = StyleSheetList::create(this); | 3356 m_styleSheetList = StyleSheetList::create(this); |
| 3328 return m_styleSheetList.get(); | 3357 return m_styleSheetList.get(); |
| 3329 } | 3358 } |
| 3330 | 3359 |
| 3360 StyleEngine& Document::styleEngine() |
| 3361 { |
| 3362 ASSERT(m_styleEngine.get()); |
| 3363 return *m_styleEngine.get(); |
| 3364 } |
| 3365 |
| 3331 String Document::preferredStylesheetSet() const | 3366 String Document::preferredStylesheetSet() const |
| 3332 { | 3367 { |
| 3333 return m_styleEngine->preferredStylesheetSetName(); | 3368 return m_styleEngine->preferredStylesheetSetName(); |
| 3334 } | 3369 } |
| 3335 | 3370 |
| 3336 String Document::selectedStylesheetSet() const | 3371 String Document::selectedStylesheetSet() const |
| 3337 { | 3372 { |
| 3338 return m_styleEngine->selectedStylesheetSetName(); | 3373 return m_styleEngine->selectedStylesheetSetName(); |
| 3339 } | 3374 } |
| 3340 | 3375 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3396 void Document::setActiveHoverElement(PassRefPtrWillBeRawPtr<Element> newActiveEl
ement) | 3431 void Document::setActiveHoverElement(PassRefPtrWillBeRawPtr<Element> newActiveEl
ement) |
| 3397 { | 3432 { |
| 3398 if (!newActiveElement) { | 3433 if (!newActiveElement) { |
| 3399 m_activeHoverElement.clear(); | 3434 m_activeHoverElement.clear(); |
| 3400 return; | 3435 return; |
| 3401 } | 3436 } |
| 3402 | 3437 |
| 3403 m_activeHoverElement = newActiveElement; | 3438 m_activeHoverElement = newActiveElement; |
| 3404 } | 3439 } |
| 3405 | 3440 |
| 3441 Element* Document::activeHoverElement() const |
| 3442 { |
| 3443 return m_activeHoverElement.get(); |
| 3444 } |
| 3445 |
| 3446 Node* Document::hoverNode() const |
| 3447 { |
| 3448 return m_hoverNode.get(); |
| 3449 } |
| 3450 |
| 3406 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly) | 3451 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly) |
| 3407 { | 3452 { |
| 3408 if (!m_focusedElement) | 3453 if (!m_focusedElement) |
| 3409 return; | 3454 return; |
| 3410 | 3455 |
| 3411 // We can't be focused if we're not in the document. | 3456 // We can't be focused if we're not in the document. |
| 3412 if (!node->inDocument()) | 3457 if (!node->inDocument()) |
| 3413 return; | 3458 return; |
| 3414 bool contains = node->containsIncludingShadowDOM(m_focusedElement.get()); | 3459 bool contains = node->containsIncludingShadowDOM(m_focusedElement.get()); |
| 3415 if (contains && (m_focusedElement != node || !amongChildrenOnly)) | 3460 if (contains && (m_focusedElement != node || !amongChildrenOnly)) |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4428 if (!equalIgnoringCase(linkElement->type(), openSearchMIMEType) || !equa
lIgnoringCase(linkElement->rel(), openSearchRelation)) | 4473 if (!equalIgnoringCase(linkElement->type(), openSearchMIMEType) || !equa
lIgnoringCase(linkElement->rel(), openSearchRelation)) |
| 4429 continue; | 4474 continue; |
| 4430 if (linkElement->href().isEmpty()) | 4475 if (linkElement->href().isEmpty()) |
| 4431 continue; | 4476 continue; |
| 4432 return linkElement->href(); | 4477 return linkElement->href(); |
| 4433 } | 4478 } |
| 4434 | 4479 |
| 4435 return KURL(); | 4480 return KURL(); |
| 4436 } | 4481 } |
| 4437 | 4482 |
| 4483 HTMLScriptElement* Document::currentScript() const |
| 4484 { |
| 4485 return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() :
nullptr; |
| 4486 } |
| 4487 |
| 4438 void Document::pushCurrentScript(PassRefPtrWillBeRawPtr<HTMLScriptElement> newCu
rrentScript) | 4488 void Document::pushCurrentScript(PassRefPtrWillBeRawPtr<HTMLScriptElement> newCu
rrentScript) |
| 4439 { | 4489 { |
| 4440 ASSERT(newCurrentScript); | 4490 ASSERT(newCurrentScript); |
| 4441 m_currentScriptStack.append(newCurrentScript); | 4491 m_currentScriptStack.append(newCurrentScript); |
| 4442 } | 4492 } |
| 4443 | 4493 |
| 4444 void Document::popCurrentScript() | 4494 void Document::popCurrentScript() |
| 4445 { | 4495 { |
| 4446 ASSERT(!m_currentScriptStack.isEmpty()); | 4496 ASSERT(!m_currentScriptStack.isEmpty()); |
| 4447 m_currentScriptStack.removeLast(); | 4497 m_currentScriptStack.removeLast(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4499 if (m_frame) { | 4549 if (m_frame) { |
| 4500 #if ENABLE(OILPAN) | 4550 #if ENABLE(OILPAN) |
| 4501 return this; | 4551 return this; |
| 4502 #else | 4552 #else |
| 4503 return m_weakFactory.createWeakPtr(); | 4553 return m_weakFactory.createWeakPtr(); |
| 4504 #endif | 4554 #endif |
| 4505 } | 4555 } |
| 4506 return nullptr; | 4556 return nullptr; |
| 4507 } | 4557 } |
| 4508 | 4558 |
| 4559 ScriptRunner* Document::scriptRunner() const |
| 4560 { |
| 4561 return m_scriptRunner.get(); |
| 4562 } |
| 4563 |
| 4509 PassRefPtrWillBeRawPtr<Attr> Document::createAttribute(const AtomicString& name,
ExceptionState& exceptionState) | 4564 PassRefPtrWillBeRawPtr<Attr> Document::createAttribute(const AtomicString& name,
ExceptionState& exceptionState) |
| 4510 { | 4565 { |
| 4511 if (isHTMLDocument() && name != name.lower()) | 4566 if (isHTMLDocument() && name != name.lower()) |
| 4512 UseCounter::count(*this, UseCounter::HTMLDocumentCreateAttributeNameNotL
owercase); | 4567 UseCounter::count(*this, UseCounter::HTMLDocumentCreateAttributeNameNotL
owercase); |
| 4513 return createAttributeNS(nullAtom, name, exceptionState, true); | 4568 return createAttributeNS(nullAtom, name, exceptionState, true); |
| 4514 } | 4569 } |
| 4515 | 4570 |
| 4516 PassRefPtrWillBeRawPtr<Attr> Document::createAttributeNS(const AtomicString& nam
espaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState, bo
ol shouldIgnoreNamespaceChecks) | 4571 PassRefPtrWillBeRawPtr<Attr> Document::createAttributeNS(const AtomicString& nam
espaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState, bo
ol shouldIgnoreNamespaceChecks) |
| 4517 { | 4572 { |
| 4518 AtomicString prefix, localName; | 4573 AtomicString prefix, localName; |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5567 return; | 5622 return; |
| 5568 } | 5623 } |
| 5569 if (m_hasAutofocused) | 5624 if (m_hasAutofocused) |
| 5570 return; | 5625 return; |
| 5571 m_hasAutofocused = true; | 5626 m_hasAutofocused = true; |
| 5572 ASSERT(!m_autofocusElement); | 5627 ASSERT(!m_autofocusElement); |
| 5573 m_autofocusElement = element; | 5628 m_autofocusElement = element; |
| 5574 m_taskRunner->postTask(BLINK_FROM_HERE, AutofocusTask::create()); | 5629 m_taskRunner->postTask(BLINK_FROM_HERE, AutofocusTask::create()); |
| 5575 } | 5630 } |
| 5576 | 5631 |
| 5632 Element* Document::autofocusElement() const |
| 5633 { |
| 5634 return m_autofocusElement.get(); |
| 5635 } |
| 5636 |
| 5577 Element* Document::activeElement() const | 5637 Element* Document::activeElement() const |
| 5578 { | 5638 { |
| 5579 if (Element* element = adjustedFocusedElement()) | 5639 if (Element* element = adjustedFocusedElement()) |
| 5580 return element; | 5640 return element; |
| 5581 return body(); | 5641 return body(); |
| 5582 } | 5642 } |
| 5583 | 5643 |
| 5584 bool Document::hasFocus() const | 5644 bool Document::hasFocus() const |
| 5585 { | 5645 { |
| 5586 return page() && page()->focusController().isDocumentFocused(*this); | 5646 return page() && page()->focusController().isDocumentFocused(*this); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5834 #ifndef NDEBUG | 5894 #ifndef NDEBUG |
| 5835 using namespace blink; | 5895 using namespace blink; |
| 5836 void showLiveDocumentInstances() | 5896 void showLiveDocumentInstances() |
| 5837 { | 5897 { |
| 5838 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5898 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
| 5839 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5899 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 5840 for (Document* document : set) | 5900 for (Document* document : set) |
| 5841 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5901 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
| 5842 } | 5902 } |
| 5843 #endif | 5903 #endif |
| OLD | NEW |