Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: sky/engine/core/dom/Document.cpp

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/dom/Document.h ('k') | sky/engine/core/dom/Document.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 * along with this library; see the file COPYING.LIB. If not, write to 23 * along with this library; see the file COPYING.LIB. If not, write to
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA. 25 * Boston, MA 02110-1301, USA.
26 */ 26 */
27 27
28 #include "sky/engine/config.h" 28 #include "sky/engine/config.h"
29 #include "sky/engine/core/dom/Document.h" 29 #include "sky/engine/core/dom/Document.h"
30 30
31 #include "gen/sky/core/HTMLElementFactory.h" 31 #include "gen/sky/core/HTMLElementFactory.h"
32 #include "gen/sky/platform/RuntimeEnabledFeatures.h" 32 #include "gen/sky/platform/RuntimeEnabledFeatures.h"
33 #include "sky/engine/bindings/core/v8/CustomElementConstructorBuilder.h" 33 #include "sky/engine/bindings2/exception_messages.h"
34 #include "sky/engine/bindings/core/v8/DOMDataStore.h" 34 #include "sky/engine/bindings2/exception_state.h"
35 #include "sky/engine/bindings/core/v8/Dictionary.h" 35 #include "sky/engine/bindings2/exception_state_placeholder.h"
36 #include "sky/engine/bindings/core/v8/ExceptionMessages.h"
37 #include "sky/engine/bindings/core/v8/ExceptionState.h"
38 #include "sky/engine/bindings/core/v8/ExceptionStatePlaceholder.h"
39 #include "sky/engine/bindings/core/v8/ScriptController.h"
40 #include "sky/engine/bindings/core/v8/V8DOMWrapper.h"
41 #include "sky/engine/bindings/core/v8/WindowProxy.h"
42 #include "sky/engine/core/animation/AnimationTimeline.h" 36 #include "sky/engine/core/animation/AnimationTimeline.h"
43 #include "sky/engine/core/animation/DocumentAnimations.h" 37 #include "sky/engine/core/animation/DocumentAnimations.h"
44 #include "sky/engine/core/css/CSSFontSelector.h" 38 #include "sky/engine/core/css/CSSFontSelector.h"
45 #include "sky/engine/core/css/CSSStyleDeclaration.h" 39 #include "sky/engine/core/css/CSSStyleDeclaration.h"
46 #include "sky/engine/core/css/CSSStyleSheet.h" 40 #include "sky/engine/core/css/CSSStyleSheet.h"
47 #include "sky/engine/core/css/MediaQueryMatcher.h" 41 #include "sky/engine/core/css/MediaQueryMatcher.h"
48 #include "sky/engine/core/css/StylePropertySet.h" 42 #include "sky/engine/core/css/StylePropertySet.h"
49 #include "sky/engine/core/css/StyleSheetContents.h" 43 #include "sky/engine/core/css/StyleSheetContents.h"
50 #include "sky/engine/core/css/parser/BisonCSSParser.h" 44 #include "sky/engine/core/css/parser/BisonCSSParser.h"
51 #include "sky/engine/core/css/resolver/FontBuilder.h" 45 #include "sky/engine/core/css/resolver/FontBuilder.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 #include "sky/engine/core/rendering/RenderView.h" 113 #include "sky/engine/core/rendering/RenderView.h"
120 #include "sky/engine/platform/DateComponents.h" 114 #include "sky/engine/platform/DateComponents.h"
121 #include "sky/engine/platform/EventDispatchForbiddenScope.h" 115 #include "sky/engine/platform/EventDispatchForbiddenScope.h"
122 #include "sky/engine/platform/Language.h" 116 #include "sky/engine/platform/Language.h"
123 #include "sky/engine/platform/Logging.h" 117 #include "sky/engine/platform/Logging.h"
124 #include "sky/engine/platform/ScriptForbiddenScope.h" 118 #include "sky/engine/platform/ScriptForbiddenScope.h"
125 #include "sky/engine/platform/TraceEvent.h" 119 #include "sky/engine/platform/TraceEvent.h"
126 #include "sky/engine/platform/network/HTTPParsers.h" 120 #include "sky/engine/platform/network/HTTPParsers.h"
127 #include "sky/engine/platform/text/SegmentedString.h" 121 #include "sky/engine/platform/text/SegmentedString.h"
128 #include "sky/engine/public/platform/Platform.h" 122 #include "sky/engine/public/platform/Platform.h"
129 #include "sky/engine/core/inspector/ScriptCallStack.h"
130 #include "sky/engine/wtf/CurrentTime.h" 123 #include "sky/engine/wtf/CurrentTime.h"
131 #include "sky/engine/wtf/DateMath.h" 124 #include "sky/engine/wtf/DateMath.h"
132 #include "sky/engine/wtf/HashFunctions.h" 125 #include "sky/engine/wtf/HashFunctions.h"
133 #include "sky/engine/wtf/MainThread.h" 126 #include "sky/engine/wtf/MainThread.h"
134 #include "sky/engine/wtf/StdLibExtras.h" 127 #include "sky/engine/wtf/StdLibExtras.h"
135 #include "sky/engine/wtf/TemporaryChange.h" 128 #include "sky/engine/wtf/TemporaryChange.h"
136 #include "sky/engine/wtf/text/StringBuffer.h" 129 #include "sky/engine/wtf/text/StringBuffer.h"
137 130
138 using namespace WTF; 131 using namespace WTF;
139 using namespace Unicode; 132 using namespace Unicode;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 412
420 void Document::childrenChanged(const ChildrenChange& change) 413 void Document::childrenChanged(const ChildrenChange& change)
421 { 414 {
422 ContainerNode::childrenChanged(change); 415 ContainerNode::childrenChanged(change);
423 m_documentElement = ElementTraversal::firstWithin(*this); 416 m_documentElement = ElementTraversal::firstWithin(*this);
424 } 417 }
425 418
426 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& exceptionState) 419 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& exceptionState)
427 { 420 {
428 if (!isValidName(name)) { 421 if (!isValidName(name)) {
429 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name."); 422 exceptionState.ThrowDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name.");
430 return nullptr; 423 return nullptr;
431 } 424 }
432 425
433 return HTMLElementFactory::createHTMLElement(name, *this, false); 426 return HTMLElementFactory::createHTMLElement(name, *this, false);
434 } 427 }
435 428
436 ScriptValue Document::registerElement(ScriptState* scriptState, const AtomicStri ng& name, ExceptionState& exceptionState) 429 PassRefPtr<DartValue> Document::registerElement(DartState*, const AtomicString& name, ExceptionState& exceptionState)
437 { 430 {
438 return registerElement(scriptState, name, Dictionary(), exceptionState); 431 // TODO(abarth): Add back custom elment registration.
439 } 432 return DartValue::Create();
440
441 ScriptValue Document::registerElement(ScriptState* scriptState, const AtomicStri ng& name, const Dictionary& options, ExceptionState& exceptionState)
442 {
443 CustomElementConstructorBuilder constructorBuilder(scriptState, &options);
444 registrationContext().registerElement(this, &constructorBuilder, name, excep tionState);
445 return constructorBuilder.bindingsReturnValue();
446 } 433 }
447 434
448 CustomElementMicrotaskRunQueue* Document::customElementMicrotaskRunQueue() 435 CustomElementMicrotaskRunQueue* Document::customElementMicrotaskRunQueue()
449 { 436 {
450 if (!m_customElementMicrotaskRunQueue) 437 if (!m_customElementMicrotaskRunQueue)
451 m_customElementMicrotaskRunQueue = CustomElementMicrotaskRunQueue::creat e(); 438 m_customElementMicrotaskRunQueue = CustomElementMicrotaskRunQueue::creat e();
452 return m_customElementMicrotaskRunQueue.get(); 439 return m_customElementMicrotaskRunQueue.get();
453 } 440 }
454 441
455 void Document::setImportsController(HTMLImportsController* controller) 442 void Document::setImportsController(HTMLImportsController* controller)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 501
515 PassRefPtr<Text> Document::createEditingTextNode(const String& text) 502 PassRefPtr<Text> Document::createEditingTextNode(const String& text)
516 { 503 {
517 return Text::createEditingText(*this, text); 504 return Text::createEditingText(*this, text);
518 } 505 }
519 506
520 bool Document::importContainerNodeChildren(ContainerNode* oldContainerNode, Pass RefPtr<ContainerNode> newContainerNode, ExceptionState& exceptionState) 507 bool Document::importContainerNodeChildren(ContainerNode* oldContainerNode, Pass RefPtr<ContainerNode> newContainerNode, ExceptionState& exceptionState)
521 { 508 {
522 for (Node* oldChild = oldContainerNode->firstChild(); oldChild; oldChild = o ldChild->nextSibling()) { 509 for (Node* oldChild = oldContainerNode->firstChild(); oldChild; oldChild = o ldChild->nextSibling()) {
523 RefPtr<Node> newChild = importNode(oldChild, true, exceptionState); 510 RefPtr<Node> newChild = importNode(oldChild, true, exceptionState);
524 if (exceptionState.hadException()) 511 if (exceptionState.had_exception())
525 return false; 512 return false;
526 newContainerNode->appendChild(newChild.release(), exceptionState); 513 newContainerNode->appendChild(newChild.release(), exceptionState);
527 if (exceptionState.hadException()) 514 if (exceptionState.had_exception())
528 return false; 515 return false;
529 } 516 }
530 517
531 return true; 518 return true;
532 } 519 }
533 520
534 PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionSt ate& exceptionState) 521 PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionSt ate& exceptionState)
535 { 522 {
536 switch (importedNode->nodeType()) { 523 switch (importedNode->nodeType()) {
537 case TEXT_NODE: 524 case TEXT_NODE:
(...skipping 11 matching lines...) Expand all
549 && !importContainerNodeChildren(toHTMLTemplateElement(oldElement )->content(), toHTMLTemplateElement(newElement)->content(), exceptionState)) 536 && !importContainerNodeChildren(toHTMLTemplateElement(oldElement )->content(), toHTMLTemplateElement(newElement)->content(), exceptionState))
550 return nullptr; 537 return nullptr;
551 } 538 }
552 539
553 return newElement.release(); 540 return newElement.release();
554 } 541 }
555 case DOCUMENT_FRAGMENT_NODE: { 542 case DOCUMENT_FRAGMENT_NODE: {
556 if (importedNode->isShadowRoot()) { 543 if (importedNode->isShadowRoot()) {
557 // ShadowRoot nodes should not be explicitly importable. 544 // ShadowRoot nodes should not be explicitly importable.
558 // Either they are imported along with their host node, or created i mplicitly. 545 // Either they are imported along with their host node, or created i mplicitly.
559 exceptionState.throwDOMException(NotSupportedError, "The node provid ed is a shadow root, which may not be imported."); 546 exceptionState.ThrowDOMException(NotSupportedError, "The node provid ed is a shadow root, which may not be imported.");
560 return nullptr; 547 return nullptr;
561 } 548 }
562 DocumentFragment* oldFragment = toDocumentFragment(importedNode); 549 DocumentFragment* oldFragment = toDocumentFragment(importedNode);
563 RefPtr<DocumentFragment> newFragment = createDocumentFragment(); 550 RefPtr<DocumentFragment> newFragment = createDocumentFragment();
564 if (deep && !importContainerNodeChildren(oldFragment, newFragment, excep tionState)) 551 if (deep && !importContainerNodeChildren(oldFragment, newFragment, excep tionState))
565 return nullptr; 552 return nullptr;
566 553
567 return newFragment.release(); 554 return newFragment.release();
568 } 555 }
569 case DOCUMENT_NODE: 556 case DOCUMENT_NODE:
570 exceptionState.throwDOMException(NotSupportedError, "The node provided i s a document, which may not be imported."); 557 exceptionState.ThrowDOMException(NotSupportedError, "The node provided i s a document, which may not be imported.");
571 return nullptr; 558 return nullptr;
572 } 559 }
573 560
574 ASSERT_NOT_REACHED(); 561 ASSERT_NOT_REACHED();
575 return nullptr; 562 return nullptr;
576 } 563 }
577 564
578 PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionState& ex ceptionState) 565 PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionState& ex ceptionState)
579 { 566 {
580 EventQueueScope scope; 567 EventQueueScope scope;
581 568
582 switch (source->nodeType()) { 569 switch (source->nodeType()) {
583 case DOCUMENT_NODE: 570 case DOCUMENT_NODE:
584 exceptionState.throwDOMException(NotSupportedError, "The node provided i s of type '" + source->nodeName() + "', which may not be adopted."); 571 exceptionState.ThrowDOMException(NotSupportedError, "The node provided i s of type '" + source->nodeName() + "', which may not be adopted.");
585 return nullptr; 572 return nullptr;
586 default: 573 default:
587 if (source->isShadowRoot()) { 574 if (source->isShadowRoot()) {
588 // ShadowRoot cannot disconnect itself from the host node. 575 // ShadowRoot cannot disconnect itself from the host node.
589 exceptionState.throwDOMException(HierarchyRequestError, "The node pr ovided is a shadow root, which may not be adopted."); 576 exceptionState.ThrowDOMException(HierarchyRequestError, "The node pr ovided is a shadow root, which may not be adopted.");
590 return nullptr; 577 return nullptr;
591 } 578 }
592 579
593 if (source->parentNode()) { 580 if (source->parentNode()) {
594 source->parentNode()->removeChild(source.get(), exceptionState); 581 source->parentNode()->removeChild(source.get(), exceptionState);
595 if (exceptionState.hadException()) 582 if (exceptionState.had_exception())
596 return nullptr; 583 return nullptr;
597 } 584 }
598 } 585 }
599 586
600 this->adoptIfNeeded(*source); 587 this->adoptIfNeeded(*source);
601 588
602 return source; 589 return source;
603 } 590 }
604 591
605 // FIXME: This should really be in a possible ElementFactory class 592 // FIXME: This should really be in a possible ElementFactory class
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 1390
1404 EventTarget* Document::errorEventTarget() 1391 EventTarget* Document::errorEventTarget()
1405 { 1392 {
1406 return domWindow(); 1393 return domWindow();
1407 } 1394 }
1408 1395
1409 void Document::logExceptionToConsole(const String& errorMessage, int scriptId, c onst String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallS tack> callStack) 1396 void Document::logExceptionToConsole(const String& errorMessage, int scriptId, c onst String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallS tack> callStack)
1410 { 1397 {
1411 RefPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessageSour ce, ErrorMessageLevel, errorMessage, sourceURL, lineNumber); 1398 RefPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessageSour ce, ErrorMessageLevel, errorMessage, sourceURL, lineNumber);
1412 consoleMessage->setScriptId(scriptId); 1399 consoleMessage->setScriptId(scriptId);
1413 consoleMessage->setCallStack(callStack);
1414 addMessage(consoleMessage.release()); 1400 addMessage(consoleMessage.release());
1415 } 1401 }
1416 1402
1417 void Document::setURL(const KURL& url) 1403 void Document::setURL(const KURL& url)
1418 { 1404 {
1419 const KURL& newURL = url.isEmpty() ? blankURL() : url; 1405 const KURL& newURL = url.isEmpty() ? blankURL() : url;
1420 if (newURL == m_url) 1406 if (newURL == m_url)
1421 return; 1407 return;
1422 1408
1423 m_url = newURL; 1409 m_url = newURL;
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 { 1896 {
1911 bool nameStart = true; 1897 bool nameStart = true;
1912 bool sawColon = false; 1898 bool sawColon = false;
1913 int colonPos = 0; 1899 int colonPos = 0;
1914 1900
1915 for (unsigned i = 0; i < length;) { 1901 for (unsigned i = 0; i < length;) {
1916 UChar32 c; 1902 UChar32 c;
1917 U16_NEXT(characters, i, length, c) 1903 U16_NEXT(characters, i, length, c)
1918 if (c == ':') { 1904 if (c == ':') {
1919 if (sawColon) { 1905 if (sawColon) {
1920 exceptionState.throwDOMException(NamespaceError, "The qualified name provided ('" + qualifiedName + "') contains multiple colons."); 1906 exceptionState.ThrowDOMException(NamespaceError, "The qualified name provided ('" + qualifiedName + "') contains multiple colons.");
1921 return false; // multiple colons: not allowed 1907 return false; // multiple colons: not allowed
1922 } 1908 }
1923 nameStart = true; 1909 nameStart = true;
1924 sawColon = true; 1910 sawColon = true;
1925 colonPos = i - 1; 1911 colonPos = i - 1;
1926 } else if (nameStart) { 1912 } else if (nameStart) {
1927 if (!isValidNameStart(c)) { 1913 if (!isValidNameStart(c)) {
1928 StringBuilder message; 1914 StringBuilder message;
1929 message.appendLiteral("The qualified name provided ('"); 1915 message.appendLiteral("The qualified name provided ('");
1930 message.append(qualifiedName); 1916 message.append(qualifiedName);
1931 message.appendLiteral("') contains the invalid name-start charac ter '"); 1917 message.appendLiteral("') contains the invalid name-start charac ter '");
1932 message.append(c); 1918 message.append(c);
1933 message.appendLiteral("'."); 1919 message.appendLiteral("'.");
1934 exceptionState.throwDOMException(InvalidCharacterError, message. toString()); 1920 exceptionState.ThrowDOMException(InvalidCharacterError, message. toString());
1935 return false; 1921 return false;
1936 } 1922 }
1937 nameStart = false; 1923 nameStart = false;
1938 } else { 1924 } else {
1939 if (!isValidNamePart(c)) { 1925 if (!isValidNamePart(c)) {
1940 StringBuilder message; 1926 StringBuilder message;
1941 message.appendLiteral("The qualified name provided ('"); 1927 message.appendLiteral("The qualified name provided ('");
1942 message.append(qualifiedName); 1928 message.append(qualifiedName);
1943 message.appendLiteral("') contains the invalid character '"); 1929 message.appendLiteral("') contains the invalid character '");
1944 message.append(c); 1930 message.append(c);
1945 message.appendLiteral("'."); 1931 message.appendLiteral("'.");
1946 exceptionState.throwDOMException(InvalidCharacterError, message. toString()); 1932 exceptionState.ThrowDOMException(InvalidCharacterError, message. toString());
1947 return false; 1933 return false;
1948 } 1934 }
1949 } 1935 }
1950 } 1936 }
1951 1937
1952 if (!sawColon) { 1938 if (!sawColon) {
1953 prefix = nullAtom; 1939 prefix = nullAtom;
1954 localName = qualifiedName; 1940 localName = qualifiedName;
1955 } else { 1941 } else {
1956 prefix = AtomicString(characters, colonPos); 1942 prefix = AtomicString(characters, colonPos);
1957 if (prefix.isEmpty()) { 1943 if (prefix.isEmpty()) {
1958 exceptionState.throwDOMException(NamespaceError, "The qualified name provided ('" + qualifiedName + "') has an empty namespace prefix."); 1944 exceptionState.ThrowDOMException(NamespaceError, "The qualified name provided ('" + qualifiedName + "') has an empty namespace prefix.");
1959 return false; 1945 return false;
1960 } 1946 }
1961 int prefixStart = colonPos + 1; 1947 int prefixStart = colonPos + 1;
1962 localName = AtomicString(characters + prefixStart, length - prefixStart) ; 1948 localName = AtomicString(characters + prefixStart, length - prefixStart) ;
1963 } 1949 }
1964 1950
1965 if (localName.isEmpty()) { 1951 if (localName.isEmpty()) {
1966 exceptionState.throwDOMException(NamespaceError, "The qualified name pro vided ('" + qualifiedName + "') has an empty local name."); 1952 exceptionState.ThrowDOMException(NamespaceError, "The qualified name pro vided ('" + qualifiedName + "') has an empty local name.");
1967 return false; 1953 return false;
1968 } 1954 }
1969 1955
1970 return true; 1956 return true;
1971 } 1957 }
1972 1958
1973 bool Document::parseQualifiedName(const AtomicString& qualifiedName, AtomicStrin g& prefix, AtomicString& localName, ExceptionState& exceptionState) 1959 bool Document::parseQualifiedName(const AtomicString& qualifiedName, AtomicStrin g& prefix, AtomicString& localName, ExceptionState& exceptionState)
1974 { 1960 {
1975 unsigned length = qualifiedName.length(); 1961 unsigned length = qualifiedName.length();
1976 1962
1977 if (!length) { 1963 if (!length) {
1978 exceptionState.throwDOMException(InvalidCharacterError, "The qualified n ame provided is empty."); 1964 exceptionState.ThrowDOMException(InvalidCharacterError, "The qualified n ame provided is empty.");
1979 return false; 1965 return false;
1980 } 1966 }
1981 1967
1982 if (qualifiedName.is8Bit()) 1968 if (qualifiedName.is8Bit())
1983 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character s8(), length, prefix, localName, exceptionState); 1969 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character s8(), length, prefix, localName, exceptionState);
1984 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16( ), length, prefix, localName, exceptionState); 1970 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16( ), length, prefix, localName, exceptionState);
1985 } 1971 }
1986 1972
1987 KURL Document::completeURL(const String& url) const 1973 KURL Document::completeURL(const String& url) const
1988 { 1974 {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 2081
2096 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt) 2082 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt)
2097 { 2083 {
2098 } 2084 }
2099 2085
2100 void Document::addMessage(PassRefPtr<ConsoleMessage> consoleMessage) 2086 void Document::addMessage(PassRefPtr<ConsoleMessage> consoleMessage)
2101 { 2087 {
2102 if (!m_frame) 2088 if (!m_frame)
2103 return; 2089 return;
2104 2090
2105 if (!consoleMessage->scriptState() && consoleMessage->url().isNull() && !con soleMessage->lineNumber()) { 2091 if (consoleMessage->url().isNull() && !consoleMessage->lineNumber()) {
2106 consoleMessage->setURL(url().string()); 2092 consoleMessage->setURL(url().string());
2107 if (parsing() && m_parser) { 2093 if (parsing() && m_parser) {
2108 if (!m_parser->isWaitingForScripts() && !m_parser->isExecutingScript ()) 2094 if (!m_parser->isWaitingForScripts() && !m_parser->isExecutingScript ())
2109 consoleMessage->setLineNumber(m_parser->textPosition().m_line.on eBasedInt()); 2095 consoleMessage->setLineNumber(m_parser->textPosition().m_line.on eBasedInt());
2110 } 2096 }
2111 } 2097 }
2112 m_frame->console().addMessage(consoleMessage); 2098 m_frame->console().addMessage(consoleMessage);
2113 } 2099 }
2114 2100
2115 void Document::decrementLoadEventDelayCount() 2101 void Document::decrementLoadEventDelayCount()
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2243 { 2229 {
2244 Page* page = this->page(); 2230 Page* page = this->page();
2245 if (!page) 2231 if (!page)
2246 return false; 2232 return false;
2247 if (!page->focusController().isActive() || !page->focusController().isFocuse d()) 2233 if (!page->focusController().isActive() || !page->focusController().isFocuse d())
2248 return false; 2234 return false;
2249 Frame* focusedFrame = page->focusController().focusedFrame(); 2235 Frame* focusedFrame = page->focusController().focusedFrame();
2250 return focusedFrame && focusedFrame == frame(); 2236 return focusedFrame && focusedFrame == frame();
2251 } 2237 }
2252 2238
2253 v8::Handle<v8::Object> Document::wrap(v8::Handle<v8::Object> creationContext, v8 ::Isolate* isolate)
2254 {
2255 ASSERT(!DOMDataStore::containsWrapperNonTemplate(this, isolate));
2256
2257 const WrapperTypeInfo* wrapperType = wrapperTypeInfo();
2258
2259 if (frame() && frame()->script().initializeMainWorld()) {
2260 // initializeMainWorld may have created a wrapper for the object, retry from the start.
2261 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperNonTemplate(thi s, isolate);
2262 if (!wrapper.IsEmpty())
2263 return wrapper;
2264 }
2265
2266 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , wrapperType, toScriptWrappableBase(), isolate);
2267 if (UNLIKELY(wrapper.IsEmpty()))
2268 return wrapper;
2269
2270 wrapperType->installConditionallyEnabledProperties(wrapper, isolate);
2271 V8DOMWrapper::associateObjectWithWrapperNonTemplate(this, wrapperType, wrapp er, isolate);
2272
2273 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
2274 if (world.isMainWorld() && frame())
2275 frame()->script().windowProxy(world)->updateDocumentWrapper(wrapper);
2276
2277 return wrapper;
2278 }
2279
2280 } // namespace blink 2239 } // namespace blink
2281 2240
2282 #ifndef NDEBUG 2241 #ifndef NDEBUG
2283 using namespace blink; 2242 using namespace blink;
2284 void showLiveDocumentInstances() 2243 void showLiveDocumentInstances()
2285 { 2244 {
2286 WeakDocumentSet& set = liveDocumentSet(); 2245 WeakDocumentSet& set = liveDocumentSet();
2287 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 2246 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
2288 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 2247 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
2289 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 2248 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
2290 } 2249 }
2291 } 2250 }
2292 #endif 2251 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Document.h ('k') | sky/engine/core/dom/Document.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698