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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 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
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 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 // FIXME: We should fix TextEncoding to speak AtomicString anyway. 1251 // FIXME: We should fix TextEncoding to speak AtomicString anyway.
1252 return AtomicString(encoding().name()); 1252 return AtomicString(encoding().name());
1253 } 1253 }
1254 1254
1255 void Document::setContentLanguage(const AtomicString& language) { 1255 void Document::setContentLanguage(const AtomicString& language) {
1256 if (m_contentLanguage == language) 1256 if (m_contentLanguage == language)
1257 return; 1257 return;
1258 m_contentLanguage = language; 1258 m_contentLanguage = language;
1259 1259
1260 // Document's style depends on the content language. 1260 // Document's style depends on the content language.
1261 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( 1261 setNeedsStyleRecalc(
1262 StyleChangeReason::Language)); 1262 SubtreeStyleChange,
1263 StyleChangeReasonForTracing::create(StyleChangeReason::Language));
1263 } 1264 }
1264 1265
1265 void Document::setXMLVersion(const String& version, 1266 void Document::setXMLVersion(const String& version,
1266 ExceptionState& exceptionState) { 1267 ExceptionState& exceptionState) {
1267 if (!XMLDocumentParser::supportsXMLVersion(version)) { 1268 if (!XMLDocumentParser::supportsXMLVersion(version)) {
1268 exceptionState.throwDOMException( 1269 exceptionState.throwDOMException(
1269 NotSupportedError, 1270 NotSupportedError,
1270 "This document does not support the XML version '" + version + "'."); 1271 "This document does not support the XML version '" + version + "'.");
1271 return; 1272 return;
1272 } 1273 }
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 body->setNeedsStyleRecalc(SubtreeStyleChange, 1880 body->setNeedsStyleRecalc(SubtreeStyleChange,
1880 StyleChangeReasonForTracing::create( 1881 StyleChangeReasonForTracing::create(
1881 StyleChangeReason::WritingModeChange)); 1882 StyleChangeReason::WritingModeChange));
1882 } 1883 }
1883 } 1884 }
1884 1885
1885 if (const ComputedStyle* style = documentElement()->computedStyle()) { 1886 if (const ComputedStyle* style = documentElement()->computedStyle()) {
1886 if (style->direction() != rootDirection || 1887 if (style->direction() != rootDirection ||
1887 style->getWritingMode() != rootWritingMode) 1888 style->getWritingMode() != rootWritingMode)
1888 documentElement()->setNeedsStyleRecalc( 1889 documentElement()->setNeedsStyleRecalc(
1889 SubtreeStyleChange, StyleChangeReasonForTracing::create( 1890 SubtreeStyleChange,
1890 StyleChangeReason::WritingModeChange)); 1891 StyleChangeReasonForTracing::create(
1892 StyleChangeReason::WritingModeChange));
1891 } 1893 }
1892 } 1894 }
1893 1895
1894 #if DCHECK_IS_ON() 1896 #if DCHECK_IS_ON()
1895 static void assertLayoutTreeUpdated(Node& root) { 1897 static void assertLayoutTreeUpdated(Node& root) {
1896 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) { 1898 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) {
1897 // We leave some nodes with dirty bits in the tree because they don't 1899 // We leave some nodes with dirty bits in the tree because they don't
1898 // matter like Comment and ProcessingInstruction nodes. 1900 // matter like Comment and ProcessingInstruction nodes.
1899 // TODO(esprehn): Don't even mark those nodes as needing recalcs in the 1901 // TODO(esprehn): Don't even mark those nodes as needing recalcs in the
1900 // first place. 1902 // first place.
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2932 // page. The old i-Bench suite does this. When this happens don't bother 2934 // page. The old i-Bench suite does this. When this happens don't bother
2933 // painting or laying out. 2935 // painting or laying out.
2934 m_loadEventProgress = LoadEventCompleted; 2936 m_loadEventProgress = LoadEventCompleted;
2935 return; 2937 return;
2936 } 2938 }
2937 2939
2938 // We used to force a synchronous display and flush here. This really isn't 2940 // We used to force a synchronous display and flush here. This really isn't
2939 // necessary and can in fact be actively harmful if pages are loading at a 2941 // necessary and can in fact be actively harmful if pages are loading at a
2940 // rate of > 60fps 2942 // rate of > 60fps
2941 // (if your platform is syncing flushes and limiting them to 60fps). 2943 // (if your platform is syncing flushes and limiting them to 60fps).
2942 if (!localOwner() || (localOwner()->layoutObject() && 2944 if (!localOwner() ||
2943 !localOwner()->layoutObject()->needsLayout())) { 2945 (localOwner()->layoutObject() &&
2946 !localOwner()->layoutObject()->needsLayout())) {
2944 updateStyleAndLayoutTree(); 2947 updateStyleAndLayoutTree();
2945 2948
2946 // Always do a layout after loading if needed. 2949 // Always do a layout after loading if needed.
2947 if (view() && !layoutViewItem().isNull() && 2950 if (view() && !layoutViewItem().isNull() &&
2948 (!layoutViewItem().firstChild() || layoutViewItem().needsLayout())) 2951 (!layoutViewItem().firstChild() || layoutViewItem().needsLayout()))
2949 view()->layout(); 2952 view()->layout();
2950 } 2953 }
2951 2954
2952 m_loadEventProgress = LoadEventCompleted; 2955 m_loadEventProgress = LoadEventCompleted;
2953 2956
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 return *m_elemSheet; 3439 return *m_elemSheet;
3437 } 3440 }
3438 3441
3439 void Document::maybeHandleHttpRefresh(const String& content, 3442 void Document::maybeHandleHttpRefresh(const String& content,
3440 HttpRefreshType httpRefreshType) { 3443 HttpRefreshType httpRefreshType) {
3441 if (m_isViewSource || !m_frame) 3444 if (m_isViewSource || !m_frame)
3442 return; 3445 return;
3443 3446
3444 double delay; 3447 double delay;
3445 String refreshURLString; 3448 String refreshURLString;
3446 if (!parseHTTPRefresh(content, httpRefreshType == HttpRefreshFromMetaTag 3449 if (!parseHTTPRefresh(content,
3447 ? isHTMLSpace<UChar> 3450 httpRefreshType == HttpRefreshFromMetaTag
3448 : nullptr, 3451 ? isHTMLSpace<UChar>
3452 : nullptr,
3449 delay, refreshURLString)) 3453 delay, refreshURLString))
3450 return; 3454 return;
3451 KURL refreshURL = 3455 KURL refreshURL =
3452 refreshURLString.isEmpty() ? url() : completeURL(refreshURLString); 3456 refreshURLString.isEmpty() ? url() : completeURL(refreshURLString);
3453 3457
3454 if (refreshURL.protocolIsJavaScript()) { 3458 if (refreshURL.protocolIsJavaScript()) {
3455 String message = 3459 String message =
3456 "Refused to refresh " + m_url.elidedString() + " to a javascript: URL"; 3460 "Refused to refresh " + m_url.elidedString() + " to a javascript: URL";
3457 addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, 3461 addConsoleMessage(ConsoleMessage::create(SecurityMessageSource,
3458 ErrorMessageLevel, message)); 3462 ErrorMessageLevel, message));
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
4084 m_focusedElement.get()); 4088 m_focusedElement.get());
4085 4089
4086 SetFocusedElementDone: 4090 SetFocusedElementDone:
4087 updateStyleAndLayoutTree(); 4091 updateStyleAndLayoutTree();
4088 if (LocalFrame* frame = this->frame()) 4092 if (LocalFrame* frame = this->frame())
4089 frame->selection().didChangeFocus(); 4093 frame->selection().didChangeFocus();
4090 return !focusChangeBlocked; 4094 return !focusChangeBlocked;
4091 } 4095 }
4092 4096
4093 void Document::clearFocusedElement() { 4097 void Document::clearFocusedElement() {
4094 setFocusedElement(nullptr, FocusParams(SelectionBehaviorOnFocus::None, 4098 setFocusedElement(
4095 WebFocusTypeNone, nullptr)); 4099 nullptr,
4100 FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr));
4096 } 4101 }
4097 4102
4098 void Document::setSequentialFocusNavigationStartingPoint(Node* node) { 4103 void Document::setSequentialFocusNavigationStartingPoint(Node* node) {
4099 if (!m_frame) 4104 if (!m_frame)
4100 return; 4105 return;
4101 if (!node) { 4106 if (!node) {
4102 m_sequentialFocusNavigationStartingPoint = nullptr; 4107 m_sequentialFocusNavigationStartingPoint = nullptr;
4103 return; 4108 return;
4104 } 4109 }
4105 DCHECK_EQ(node->document(), this); 4110 DCHECK_EQ(node->document(), this);
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
5103 bool newValue = m_designMode; 5108 bool newValue = m_designMode;
5104 if (equalIgnoringCase(value, "on")) { 5109 if (equalIgnoringCase(value, "on")) {
5105 newValue = true; 5110 newValue = true;
5106 UseCounter::count(*this, UseCounter::DocumentDesignModeEnabeld); 5111 UseCounter::count(*this, UseCounter::DocumentDesignModeEnabeld);
5107 } else if (equalIgnoringCase(value, "off")) { 5112 } else if (equalIgnoringCase(value, "off")) {
5108 newValue = false; 5113 newValue = false;
5109 } 5114 }
5110 if (newValue == m_designMode) 5115 if (newValue == m_designMode)
5111 return; 5116 return;
5112 m_designMode = newValue; 5117 m_designMode = newValue;
5113 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create( 5118 setNeedsStyleRecalc(
5114 StyleChangeReason::DesignMode)); 5119 SubtreeStyleChange,
5120 StyleChangeReasonForTracing::create(StyleChangeReason::DesignMode));
5115 } 5121 }
5116 5122
5117 Document* Document::parentDocument() const { 5123 Document* Document::parentDocument() const {
5118 if (!m_frame) 5124 if (!m_frame)
5119 return 0; 5125 return 0;
5120 Frame* parent = m_frame->tree().parent(); 5126 Frame* parent = m_frame->tree().parent();
5121 if (!parent || !parent->isLocalFrame()) 5127 if (!parent || !parent->isLocalFrame())
5122 return 0; 5128 return 0;
5123 return toLocalFrame(parent)->document(); 5129 return toLocalFrame(parent)->document();
5124 } 5130 }
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
6397 return false; 6403 return false;
6398 } 6404 }
6399 return true; 6405 return true;
6400 } 6406 }
6401 6407
6402 bool Document::isSecureContext( 6408 bool Document::isSecureContext(
6403 const SecureContextCheck privilegeContextCheck) const { 6409 const SecureContextCheck privilegeContextCheck) const {
6404 bool isSecure = isSecureContextImpl(privilegeContextCheck); 6410 bool isSecure = isSecureContextImpl(privilegeContextCheck);
6405 if (getSandboxFlags() != SandboxNone) { 6411 if (getSandboxFlags() != SandboxNone) {
6406 UseCounter::count( 6412 UseCounter::count(
6407 *this, isSecure 6413 *this,
6408 ? UseCounter::SecureContextCheckForSandboxedOriginPassed 6414 isSecure ? UseCounter::SecureContextCheckForSandboxedOriginPassed
6409 : UseCounter::SecureContextCheckForSandboxedOriginFailed); 6415 : UseCounter::SecureContextCheckForSandboxedOriginFailed);
6410 } 6416 }
6411 UseCounter::count(*this, isSecure ? UseCounter::SecureContextCheckPassed 6417 UseCounter::count(*this,
6412 : UseCounter::SecureContextCheckFailed); 6418 isSecure ? UseCounter::SecureContextCheckPassed
6419 : UseCounter::SecureContextCheckFailed);
6413 return isSecure; 6420 return isSecure;
6414 } 6421 }
6415 6422
6416 void Document::enforceInsecureRequestPolicy(WebInsecureRequestPolicy policy) { 6423 void Document::enforceInsecureRequestPolicy(WebInsecureRequestPolicy policy) {
6417 // Combine the new policy with the existing policy, as a base policy may be 6424 // Combine the new policy with the existing policy, as a base policy may be
6418 // inherited from a remote parent before this page's policy is set. In other 6425 // inherited from a remote parent before this page's policy is set. In other
6419 // words, insecure requests should be upgraded or blocked if _either_ the 6426 // words, insecure requests should be upgraded or blocked if _either_ the
6420 // existing policy or the newly enforced policy triggers upgrades or 6427 // existing policy or the newly enforced policy triggers upgrades or
6421 // blockage. 6428 // blockage.
6422 setInsecureRequestPolicy(getInsecureRequestPolicy() | policy); 6429 setInsecureRequestPolicy(getInsecureRequestPolicy() | policy);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
6598 } 6605 }
6599 6606
6600 void showLiveDocumentInstances() { 6607 void showLiveDocumentInstances() {
6601 WeakDocumentSet& set = liveDocumentSet(); 6608 WeakDocumentSet& set = liveDocumentSet();
6602 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6609 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6603 for (blink::Document* document : set) 6610 for (blink::Document* document : set)
6604 fprintf(stderr, "- Document %p URL: %s\n", document, 6611 fprintf(stderr, "- Document %p URL: %s\n", document,
6605 document->url().getString().utf8().data()); 6612 document->url().getString().utf8().data());
6606 } 6613 }
6607 #endif 6614 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp ('k') | third_party/WebKit/Source/core/dom/DocumentLifecycle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698