source: webkit/trunk/Source/WebCore/loader/FrameLoaderStateMachine.cpp

Last change on this file was 136031, checked in by Nate Chapin, 12 years ago

Move empty loading to DocumentLoader, simplify FrameLoader::init()
https://bugs.webkit.org/show_bug.cgi?id=101512

Reviewed by Adam Barth.

Source/WebCore:

No new tests, though several outputs changed because we no longer send resource

load callbacks for empty loads.

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::DocumentLoader):
(WebCore::DocumentLoader::~DocumentLoader):
(WebCore::DocumentLoader::finishedLoading):
(WebCore::DocumentLoader::commitData):
(WebCore::DocumentLoader::clearMainResourceLoader):
(WebCore::DocumentLoader::isLoadingInAPISense):
(WebCore::DocumentLoader::documentURL):
(WebCore::DocumentLoader::isLoadingMainResource):
(WebCore::DocumentLoader::maybeLoadEmpty):
(WebCore):
(WebCore::DocumentLoader::startLoadingMainResource): Handle empty main resource

loads directly here.

  • loader/DocumentLoader.h:

(WebCore::DocumentLoader::serverRedirectSourceForHistory):
(DocumentLoader):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::FrameLoader): Initialize some variables whose values

were previously being reset in init(). Given that the FrameLoader is in
an inconsistent state before init() is called anyway, there doesn't seem
to be a disadvantage to just initializing them to their post-init() values.

(WebCore::FrameLoader::init): Just call startLoadingMainResource(), instead of

doing a bunch of direct calls to functions FrameLoader shouldn't know about.

  • loader/FrameLoaderStateMachine.cpp:

(WebCore::FrameLoaderStateMachine::FrameLoaderStateMachine):

  • loader/FrameLoaderStateMachine.h:
  • loader/MainResourceLoader.cpp: Throughout, remove the concept of an empty load.

(WebCore::MainResourceLoader::loadNow): This only returned true when an empty

load got deferred, which won't happen now. Return void and always treat
as returning false.

  • loader/MainResourceLoader.h:

(MainResourceLoader):

Tools:

  • DumpRenderTree/chromium/WebViewHost.cpp:

(WebViewHost::updateForCommittedLoad): This function doesn't play nicely with empty urls and incorrectly

interprets them as a non-empty load. This change is required for

http/tests/navigation/new-window-redirect-history.html to continue to pass in chromium.

  • TestWebKitAPI/Tests/WebKit2/AboutBlankLoad.cpp: This test relies on a callback that no longer

is sent for about:blank loads. Hook into didFinishLoadForFrame() instead.

(TestWebKitAPI::didFinishLoadForFrame):
(TestWebKitAPI::TEST):

LayoutTests:

Don't expect resource load callbacks for empty loads.

  • http/tests/inspector/network/network-iframe-load-and-delete.html:
  • http/tests/loading/redirect-methods-expected.txt:
  • http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt:
  • http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt:
  • http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt:
  • Property svn:eol-style set to native
File size: 2.6 KB
Line 
1/*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Google, Inc. nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "config.h"
30#include "FrameLoaderStateMachine.h"
31
32#include <wtf/Assertions.h>
33
34namespace WebCore {
35
36
37FrameLoaderStateMachine::FrameLoaderStateMachine()
38 : m_state(CreatingInitialEmptyDocument)
39{
40}
41
42bool FrameLoaderStateMachine::committingFirstRealLoad() const
43{
44 return m_state == DisplayingInitialEmptyDocument;
45}
46
47bool FrameLoaderStateMachine::committedFirstRealDocumentLoad() const
48{
49 return m_state >= DisplayingInitialEmptyDocumentPostCommit;
50}
51
52bool FrameLoaderStateMachine::creatingInitialEmptyDocument() const
53{
54 return m_state == CreatingInitialEmptyDocument;
55}
56
57bool FrameLoaderStateMachine::isDisplayingInitialEmptyDocument() const
58{
59 return m_state == DisplayingInitialEmptyDocument || m_state == DisplayingInitialEmptyDocumentPostCommit;
60}
61
62bool FrameLoaderStateMachine::firstLayoutDone() const
63{
64 return m_state == FirstLayoutDone;
65}
66
67void FrameLoaderStateMachine::advanceTo(State state)
68{
69 ASSERT(State(m_state + 1) == state || (firstLayoutDone() && state == CommittedFirstRealLoad));
70 m_state = state;
71}
72
73} // namespace WebCore
Note: See TracBrowser for help on using the repository browser.