summaryrefslogtreecommitdiff
path: root/Source/WebCore/page
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-09-26 10:42:44 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-09-26 10:42:44 +0200
commit33b26980cb24288b5a9f2590ccf32a949281bb79 (patch)
treecc0203dac37338b24b0b25a4694c0b76d4e4164b /Source/WebCore/page
parent715be629d51174233403237bfc563cf150087dc8 (diff)
downloadqtwebkit-33b26980cb24288b5a9f2590ccf32a949281bb79.tar.gz
Imported WebKit commit c596dd7f03007fa7ed896b928106497e8784b3b5 (http://svn.webkit.org/repository/webkit/trunk@129610)
New snapshot that removes QtQuick1 support (to be moved into QtQuick1 module)
Diffstat (limited to 'Source/WebCore/page')
-rw-r--r--Source/WebCore/page/ContentSecurityPolicy.cpp39
-rw-r--r--Source/WebCore/page/ContentSecurityPolicy.h1
-rw-r--r--Source/WebCore/page/FrameView.cpp21
-rw-r--r--Source/WebCore/page/LayoutMilestones.h41
-rw-r--r--Source/WebCore/page/Page.cpp21
-rw-r--r--Source/WebCore/page/Page.h7
6 files changed, 106 insertions, 24 deletions
diff --git a/Source/WebCore/page/ContentSecurityPolicy.cpp b/Source/WebCore/page/ContentSecurityPolicy.cpp
index 4bb3a88a8..2667a8284 100644
--- a/Source/WebCore/page/ContentSecurityPolicy.cpp
+++ b/Source/WebCore/page/ContentSecurityPolicy.cpp
@@ -500,13 +500,15 @@ bool CSPSourceList::parsePath(const UChar* begin, const UChar* end, String& path
// path/to/file.js?query=string || path/to/file.js#anchor
// ^ ^
if (position < end)
- return false;
+ m_policy->reportInvalidPathCharacter(m_directiveName, String(begin, end - begin), *position);
- path = decodeURLEscapeSequences(String(begin, end - begin));
+ path = decodeURLEscapeSequences(String(begin, position - begin));
if (!path.endsWith('/'))
path = path + '/';
- ASSERT(position == end && path.endsWith('/'));
+ ASSERT(position <= end);
+ ASSERT(position == end || (*position == '#' || *position == '?'));
+ ASSERT(path.endsWith('/'));
return true;
}
@@ -885,7 +887,12 @@ bool CSPDirectiveList::checkEvalAndReportViolation(SourceListDirective* directiv
{
if (checkEval(directive))
return true;
- reportViolation(directive->text(), consoleMessage + "\"" + directive->text() + "\".\n", KURL(), contextURL, contextLine, callStack);
+
+ String suffix = String();
+ if (directive == m_defaultSrc)
+ suffix = " Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.";
+
+ reportViolation(directive->text(), consoleMessage + "\"" + directive->text() + "\"." + suffix + "\n", KURL(), contextURL, contextLine, callStack);
if (!m_reportOnly) {
m_policy->reportBlockedScriptExecutionToInspector(directive->text());
return false;
@@ -918,7 +925,12 @@ bool CSPDirectiveList::checkInlineAndReportViolation(SourceListDirective* direct
{
if (checkInline(directive))
return true;
- reportViolation(directive->text(), consoleMessage + "\"" + directive->text() + "\".\n", KURL(), contextURL, contextLine);
+
+ String suffix = String();
+ if (directive == m_defaultSrc)
+ suffix = makeString(" Note that '", (isScript ? "script" : "style"), "-src' was not explicitly set, so 'default-src' is used as a fallback.");
+
+ reportViolation(directive->text(), consoleMessage + "\"" + directive->text() + "\"." + suffix + "\n", KURL(), contextURL, contextLine);
if (!m_reportOnly) {
if (isScript)
@@ -939,7 +951,11 @@ bool CSPDirectiveList::checkSourceAndReportViolation(SourceListDirective* direct
if (type == "form")
prefix = "Refused to send form data to '";
- reportViolation(directive->text(), makeString(prefix, url.string(), "' because it violates the following Content Security Policy directive: \"", directive->text(), "\".\n"), url);
+ String suffix = String();
+ if (directive == m_defaultSrc)
+ suffix = " Note that '" + type + "-src' was not explicitly set, so 'default-src' is used as a fallback.";
+
+ reportViolation(directive->text(), prefix + url.string() + "' because it violates the following Content Security Policy directive: \"" + directive->text() + "\"." + suffix + "\n", url);
return denyIfEnforcingPolicy();
}
@@ -1573,6 +1589,17 @@ void ContentSecurityPolicy::reportInvalidDirectiveValueCharacter(const String& d
logToConsole(message);
}
+void ContentSecurityPolicy::reportInvalidPathCharacter(const String& directiveName, const String& value, const char invalidChar) const
+{
+ ASSERT(invalidChar == '#' || invalidChar == '?');
+
+ String ignoring = "The fragment identifier, including the '#', will be ignored.";
+ if (invalidChar == '?')
+ ignoring = "The query component, including the '?', will be ignored.";
+ String message = makeString("The source list for Content Security Policy directive '", directiveName, "' contains a source with an invalid path: '", value, "'. ", ignoring);
+ logToConsole(message);
+}
+
void ContentSecurityPolicy::reportInvalidNonce(const String& nonce) const
{
String message = makeString("Ignoring invalid Content Security Policy script nonce: '", nonce, "'.\n");
diff --git a/Source/WebCore/page/ContentSecurityPolicy.h b/Source/WebCore/page/ContentSecurityPolicy.h
index 7fb751fbf..39e049e10 100644
--- a/Source/WebCore/page/ContentSecurityPolicy.h
+++ b/Source/WebCore/page/ContentSecurityPolicy.h
@@ -101,6 +101,7 @@ public:
void reportDuplicateDirective(const String&) const;
void reportInvalidDirectiveValueCharacter(const String& directiveName, const String& value) const;
+ void reportInvalidPathCharacter(const String& directiveName, const String& value, const char) const;
void reportInvalidNonce(const String&) const;
void reportInvalidPluginTypes(const String&) const;
void reportInvalidSourceExpression(const String& directiveName, const String& source) const;
diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp
index 2925823e6..9f7274627 100644
--- a/Source/WebCore/page/FrameView.cpp
+++ b/Source/WebCore/page/FrameView.cpp
@@ -2432,11 +2432,19 @@ void FrameView::performPostLayoutTasks()
m_frame->selection()->setCaretRectNeedsUpdate();
m_frame->selection()->updateAppearance();
+ LayoutMilestones milestonesOfInterest = 0;
+ LayoutMilestones milestonesAchieved = 0;
+ Page* page = m_frame->page();
+ if (page)
+ milestonesOfInterest = page->layoutMilestones();
+
if (m_nestedLayoutCount <= 1) {
if (m_firstLayoutCallbackPending) {
m_firstLayoutCallbackPending = false;
m_frame->loader()->didFirstLayout();
- if (Page* page = m_frame->page()) {
+ if (milestonesOfInterest & DidFirstLayout)
+ milestonesAchieved |= DidFirstLayout;
+ if (page) {
if (page->mainFrame() == m_frame)
page->startCountingRelevantRepaintedObjects();
}
@@ -2449,10 +2457,15 @@ void FrameView::performPostLayoutTasks()
// If the layout was done with pending sheets, we are not in fact visually non-empty yet.
if (m_isVisuallyNonEmpty && !m_frame->document()->didLayoutWithPendingStylesheets() && m_firstVisuallyNonEmptyLayoutCallbackPending) {
m_firstVisuallyNonEmptyLayoutCallbackPending = false;
- m_frame->loader()->didFirstVisuallyNonEmptyLayout();
+ if (milestonesOfInterest & DidFirstVisuallyNonEmptyLayout)
+ milestonesAchieved |= DidFirstVisuallyNonEmptyLayout;
}
}
+ m_frame->loader()->didLayout(milestonesAchieved);
+
+ // FIXME: We should consider adding DidLayout as a LayoutMilestone. That would let us merge this
+ // with didLayout(LayoutMilestones).
m_frame->loader()->client()->dispatchDidLayout();
RenderView* root = rootRenderer(this);
@@ -2464,7 +2477,7 @@ void FrameView::performPostLayoutTasks()
break;
}
- if (Page* page = m_frame->page()) {
+ if (page) {
if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
scrollingCoordinator->frameViewLayoutUpdated(this);
}
@@ -2493,7 +2506,7 @@ void FrameView::performPostLayoutTasks()
#if ENABLE(INSPECTOR)
if (InspectorInstrumentation::hasFrontends()) {
- if (Page* page = m_frame->page()) {
+ if (page) {
if (page->mainFrame() == m_frame) {
if (InspectorClient* inspectorClient = page->inspectorController()->inspectorClient())
inspectorClient->didResizeMainFrame(m_frame.get());
diff --git a/Source/WebCore/page/LayoutMilestones.h b/Source/WebCore/page/LayoutMilestones.h
new file mode 100644
index 000000000..dbfcf143b
--- /dev/null
+++ b/Source/WebCore/page/LayoutMilestones.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LayoutMilestones_h
+#define LayoutMilestones_h
+
+namespace WebCore {
+
+enum LayoutMilestoneFlag {
+ DidFirstLayout = 1 << 0,
+ DidFirstVisuallyNonEmptyLayout = 1 << 1,
+ DidHitRelevantRepaintedObjectsAreaThreshold = 1 << 2
+};
+
+typedef unsigned LayoutMilestones;
+
+} // namespace WebCore
+
+#endif // LayoutMilestones_h
diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp
index 62b4c55b5..1793df15e 100644
--- a/Source/WebCore/page/Page.cpp
+++ b/Source/WebCore/page/Page.cpp
@@ -162,6 +162,7 @@ Page::Page(PageClients& pageClients)
, m_visibilityState(PageVisibilityStateVisible)
#endif
, m_displayID(0)
+ , m_layoutMilestones(0)
, m_isCountingRelevantRepaintedObjects(false)
#ifndef NDEBUG
, m_isPainting(false)
@@ -1115,25 +1116,19 @@ PageVisibilityState Page::visibilityState() const
}
#endif
-// FIXME: gPaintedObjectCounterThreshold is no longer used for calculating relevant repainted areas,
-// and it should be removed. For the time being, it is useful because it allows us to avoid doing
-// any of this work for ports that don't make sure of didNewFirstVisuallyNonEmptyLayout. We should
-// remove this when we resolve <rdar://problem/10791680> Need to merge didFirstVisuallyNonEmptyLayout
-// and didNewFirstVisuallyNonEmptyLayout
-static uint64_t gPaintedObjectCounterThreshold = 0;
+void Page::addLayoutMilestones(LayoutMilestones milestones)
+{
+ // In the future, we may want a function that replaces m_layoutMilestones instead of just adding to it.
+ m_layoutMilestones |= milestones;
+}
// These are magical constants that might be tweaked over time.
static double gMinimumPaintedAreaRatio = 0.1;
static double gMaximumUnpaintedAreaRatio = 0.04;
-void Page::setRelevantRepaintedObjectsCounterThreshold(uint64_t threshold)
-{
- gPaintedObjectCounterThreshold = threshold;
-}
-
bool Page::isCountingRelevantRepaintedObjects() const
{
- return m_isCountingRelevantRepaintedObjects && gPaintedObjectCounterThreshold > 0;
+ return m_isCountingRelevantRepaintedObjects && (m_layoutMilestones & DidHitRelevantRepaintedObjectsAreaThreshold);
}
void Page::startCountingRelevantRepaintedObjects()
@@ -1187,7 +1182,7 @@ void Page::addRelevantRepaintedObject(RenderObject* object, const LayoutRect& ob
m_isCountingRelevantRepaintedObjects = false;
resetRelevantPaintedObjectCounter();
if (Frame* frame = mainFrame())
- frame->loader()->didNewFirstVisuallyNonEmptyLayout();
+ frame->loader()->didLayout(DidHitRelevantRepaintedObjectsAreaThreshold);
}
}
diff --git a/Source/WebCore/page/Page.h b/Source/WebCore/page/Page.h
index ba26ce819..cd6c665b4 100644
--- a/Source/WebCore/page/Page.h
+++ b/Source/WebCore/page/Page.h
@@ -24,6 +24,7 @@
#include "FeatureObserver.h"
#include "FrameLoaderTypes.h"
#include "FindOptions.h"
+#include "LayoutMilestones.h"
#include "LayoutTypes.h"
#include "PageVisibilityState.h"
#include "Pagination.h"
@@ -326,8 +327,10 @@ namespace WebCore {
PlatformDisplayID displayID() const { return m_displayID; }
+ void addLayoutMilestones(LayoutMilestones);
+ LayoutMilestones layoutMilestones() const { return m_layoutMilestones; }
+
bool isCountingRelevantRepaintedObjects() const;
- void setRelevantRepaintedObjectsCounterThreshold(uint64_t);
void startCountingRelevantRepaintedObjects();
void resetRelevantPaintedObjectCounter();
void addRelevantRepaintedObject(RenderObject*, const LayoutRect& objectPaintRect);
@@ -447,6 +450,8 @@ namespace WebCore {
#endif
PlatformDisplayID m_displayID;
+ LayoutMilestones m_layoutMilestones;
+
HashSet<RenderObject*> m_relevantUnpaintedRenderObjects;
Region m_relevantPaintedRegion;
Region m_relevantUnpaintedRegion;