summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebCore/page/DOMWindow.cpp12
-rw-r--r--WebCore/page/DOMWindow.h2
-rw-r--r--WebCore/page/DOMWindow.idl2
-rw-r--r--WebCore/page/History.cpp33
-rw-r--r--WebCore/page/History.h5
-rw-r--r--WebCore/page/History.idl6
-rw-r--r--WebCore/platform/graphics/android/BaseLayerAndroid.cpp14
-rw-r--r--WebCore/platform/graphics/android/BaseLayerAndroid.h2
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.cpp13
-rw-r--r--WebCore/platform/graphics/android/LayerAndroid.h6
-rw-r--r--WebCore/platform/graphics/android/TiledPage.cpp4
-rw-r--r--WebCore/platform/graphics/android/TilesManager.cpp10
-rw-r--r--WebCore/platform/graphics/android/TilesManager.h1
13 files changed, 79 insertions, 31 deletions
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index 22e1355..17b4c3d 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -867,7 +867,7 @@ void DOMWindow::blur()
page->chrome()->unfocus();
}
-void DOMWindow::close()
+void DOMWindow::close(ScriptExecutionContext* context)
{
if (!m_frame)
return;
@@ -879,6 +879,16 @@ void DOMWindow::close()
if (m_frame != page->mainFrame())
return;
+ if (context) {
+ ASSERT(WTF::isMainThread());
+ Frame* activeFrame = static_cast<Document*>(context)->frame();
+ if (!activeFrame)
+ return;
+
+ if (!activeFrame->loader()->shouldAllowNavigation(m_frame))
+ return;
+ }
+
Settings* settings = m_frame->settings();
bool allowScriptsToCloseWindows = settings && settings->allowScriptsToCloseWindows();
diff --git a/WebCore/page/DOMWindow.h b/WebCore/page/DOMWindow.h
index 68b21ff..d0a6cce 100644
--- a/WebCore/page/DOMWindow.h
+++ b/WebCore/page/DOMWindow.h
@@ -147,7 +147,7 @@ namespace WebCore {
void focus();
void blur();
- void close();
+ void close(ScriptExecutionContext* = 0);
void print();
void stop();
diff --git a/WebCore/page/DOMWindow.idl b/WebCore/page/DOMWindow.idl
index 602289b..fe12287 100644
--- a/WebCore/page/DOMWindow.idl
+++ b/WebCore/page/DOMWindow.idl
@@ -65,7 +65,7 @@ module window {
[DoNotCheckDomainSecurity] void focus();
[DoNotCheckDomainSecurity] void blur();
- [DoNotCheckDomainSecurity] void close();
+ [DoNotCheckDomainSecurity, CallWith=ScriptExecutionContext] void close();
void print();
void stop();
diff --git a/WebCore/page/History.cpp b/WebCore/page/History.cpp
index 95b1350..f0a75fe 100644
--- a/WebCore/page/History.cpp
+++ b/WebCore/page/History.cpp
@@ -27,6 +27,7 @@
#include "History.h"
#include "BackForwardController.h"
+#include "Document.h"
#include "ExceptionCode.h"
#include "Frame.h"
#include "FrameLoader.h"
@@ -62,22 +63,44 @@ unsigned History::length() const
void History::back()
{
- if (!m_frame)
- return;
- m_frame->navigationScheduler()->scheduleHistoryNavigation(-1);
+ go(-1);
+}
+
+void History::back(ScriptExecutionContext* context)
+{
+ go(context, -1);
}
void History::forward()
{
+ go(1);
+}
+
+void History::forward(ScriptExecutionContext* context)
+{
+ go(context, 1);
+}
+
+void History::go(int distance)
+{
if (!m_frame)
return;
- m_frame->navigationScheduler()->scheduleHistoryNavigation(1);
+ m_frame->navigationScheduler()->scheduleHistoryNavigation(distance);
}
-void History::go(int distance)
+void History::go(ScriptExecutionContext* context, int distance)
{
if (!m_frame)
return;
+
+ ASSERT(WTF::isMainThread());
+ Frame* activeFrame = static_cast<Document*>(context)->frame();
+ if (!activeFrame)
+ return;
+
+ if (!activeFrame->loader()->shouldAllowNavigation(m_frame))
+ return;
+
m_frame->navigationScheduler()->scheduleHistoryNavigation(distance);
}
diff --git a/WebCore/page/History.h b/WebCore/page/History.h
index e885847..9ec1914 100644
--- a/WebCore/page/History.h
+++ b/WebCore/page/History.h
@@ -34,6 +34,7 @@
namespace WebCore {
class Frame;
+class ScriptExecutionContext;
class SerializedScriptValue;
typedef int ExceptionCode;
@@ -49,6 +50,10 @@ public:
void forward();
void go(int distance);
+ void back(ScriptExecutionContext*);
+ void forward(ScriptExecutionContext*);
+ void go(ScriptExecutionContext*, int distance);
+
enum StateObjectType {
StateObjectPush,
StateObjectReplace
diff --git a/WebCore/page/History.idl b/WebCore/page/History.idl
index d1be5ae..d8eac60 100644
--- a/WebCore/page/History.idl
+++ b/WebCore/page/History.idl
@@ -37,9 +37,9 @@ module window {
] History {
readonly attribute unsigned long length;
- [DoNotCheckDomainSecurity] void back();
- [DoNotCheckDomainSecurity] void forward();
- [DoNotCheckDomainSecurity] void go(in long distance);
+ [DoNotCheckDomainSecurity, CallWith=ScriptExecutionContext] void back();
+ [DoNotCheckDomainSecurity, CallWith=ScriptExecutionContext] void forward();
+ [DoNotCheckDomainSecurity, CallWith=ScriptExecutionContext] void go(in long distance);
[Custom, EnabledAtRuntime] void pushState(in any data, in DOMString title, in optional DOMString url)
raises(DOMException);
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
index 2f0e999..35c3b36 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.cpp
@@ -116,12 +116,11 @@ void BaseLayerAndroid::drawCanvas(SkCanvas* canvas)
}
#if USE(ACCELERATED_COMPOSITING)
-bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale)
+bool BaseLayerAndroid::drawBasePictureInGL(SkRect& viewport, float scale, double currentTime)
{
if (!m_glWebViewState)
return false;
- double currentTime = WTF::currentTime();
bool goingDown = m_previousVisible.fTop - viewport.fTop <= 0;
bool goingLeft = m_previousVisible.fLeft - viewport.fLeft >= 0;
@@ -282,7 +281,8 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
shader->setViewRect(viewRect);
shader->setViewport(visibleRect);
- ret = drawBasePictureInGL(visibleRect, scale);
+ double currentTime = WTF::currentTime();
+ ret = drawBasePictureInGL(visibleRect, scale, currentTime);
if (countChildren() >= 1) {
LayerAndroid* compositedRoot = static_cast<LayerAndroid*>(getChild(0));
@@ -311,7 +311,7 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
scale = m_glWebViewState->futureScale();
}
compositedRoot->setScale(scale);
- compositedRoot->computeTextureSize();
+ compositedRoot->computeTextureSize(currentTime);
compositedRoot->reserveGLTextures();
#ifdef DEBUG
@@ -337,12 +337,6 @@ bool BaseLayerAndroid::drawGL(IntRect& viewRect, SkRect& visibleRect,
glBindBuffer(GL_ARRAY_BUFFER, 0);
m_previousVisible = visibleRect;
-#ifdef DEBUG_COUNT
- XLOG("GLWebViewState(%d) DoubleBufferedTexture(%d) BaseTile(%d) TileSet(%d) TiledPage(%d)",
- GLWebViewState::count(), DoubleBufferedTexture::count(),
- BaseTile::count(), TileSet::count(), TiledPage::count());
-#endif // DEBUG_COUNT
-
#endif // USE(ACCELERATED_COMPOSITING)
#ifdef DEBUG
ClassTracker::instance()->show();
diff --git a/WebCore/platform/graphics/android/BaseLayerAndroid.h b/WebCore/platform/graphics/android/BaseLayerAndroid.h
index c57b13d..cb1caef 100644
--- a/WebCore/platform/graphics/android/BaseLayerAndroid.h
+++ b/WebCore/platform/graphics/android/BaseLayerAndroid.h
@@ -59,7 +59,7 @@ public:
void swapExtra(BaseLayerAndroid* base) { m_extra.swap(base->m_extra); }
private:
#if USE(ACCELERATED_COMPOSITING)
- bool drawBasePictureInGL(SkRect& viewport, float scale);
+ bool drawBasePictureInGL(SkRect& viewport, float scale, double currentTime);
GLWebViewState* m_glWebViewState;
android::Mutex m_drawLock;
diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp
index bee423c..7375cba 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -75,7 +75,8 @@ LayerAndroid::LayerAndroid(bool isRootLayer) : SkLayer(),
m_reservedTexture(0),
m_pictureUsed(0),
m_requestSent(false),
- m_scale(1)
+ m_scale(1),
+ m_lastComputeTextureSize(0)
{
m_backgroundColor = 0;
@@ -123,6 +124,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : SkLayer(layer),
m_dirty = layer.m_dirty;
m_pictureUsed = layer.m_pictureUsed;
m_scale = layer.m_scale;
+ m_lastComputeTextureSize = 0;
for (int i = 0; i < layer.countChildren(); i++)
addChild(layer.getChild(i)->copy())->unref();
@@ -147,7 +149,8 @@ LayerAndroid::LayerAndroid(SkPicture* picture) : SkLayer(),
m_drawingTexture(0),
m_reservedTexture(0),
m_requestSent(false),
- m_scale(1)
+ m_scale(1),
+ m_lastComputeTextureSize(0)
{
m_backgroundColor = 0;
m_dirty = false;
@@ -651,8 +654,12 @@ static inline bool compareLayerFullSize(const LayerAndroid* a, const LayerAndroi
return sizeA > sizeB;
}
-void LayerAndroid::computeTextureSize()
+void LayerAndroid::computeTextureSize(double time)
{
+ if (m_lastComputeTextureSize + s_computeTextureDelay > time)
+ return;
+ m_lastComputeTextureSize = time;
+
// First, we collect the layers, computing m_layerTextureRect
// as being clipped against the viewport
Vector <LayerAndroid*> layers;
diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h
index 2cb56c1..0d5a878 100644
--- a/WebCore/platform/graphics/android/LayerAndroid.h
+++ b/WebCore/platform/graphics/android/LayerAndroid.h
@@ -111,7 +111,7 @@ public:
void showLayers(int indent = 0);
// Texture size functions
- void computeTextureSize();
+ void computeTextureSize(double time);
void collect(Vector<LayerAndroid*>& layers,
int& size);
int clippedTextureSize() const;
@@ -325,6 +325,10 @@ private:
float m_scale;
+ // We try to not always compute the texture size, as this is quite heavy
+ static const double s_computeTextureDelay = 0.2; // 200 ms
+ double m_lastComputeTextureSize;
+
// This mutex serves two purposes. (1) It ensures that certain operations
// happen atomically and (2) it makes sure those operations are synchronized
// across all threads and cores.
diff --git a/WebCore/platform/graphics/android/TiledPage.cpp b/WebCore/platform/graphics/android/TiledPage.cpp
index 620aa6f..36988dd 100644
--- a/WebCore/platform/graphics/android/TiledPage.cpp
+++ b/WebCore/platform/graphics/android/TiledPage.cpp
@@ -49,8 +49,6 @@
#endif // DEBUG
-#define MAX_TILES 256
-
namespace WebCore {
using namespace android;
@@ -65,7 +63,7 @@ TiledPage::TiledPage(int id, GLWebViewState* state)
, m_latestPictureInval(0)
, m_prepare(false)
{
- m_baseTiles = new BaseTile[MAX_TILES];
+ m_baseTiles = new BaseTile[TilesManager::getMaxTextureAllocation() + 1];
#ifdef DEBUG_COUNT
ClassTracker::instance()->increment("TiledPage");
#endif
diff --git a/WebCore/platform/graphics/android/TilesManager.cpp b/WebCore/platform/graphics/android/TilesManager.cpp
index 571d9cc..0fb3b1b 100644
--- a/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/WebCore/platform/graphics/android/TilesManager.cpp
@@ -58,7 +58,7 @@
// at least 5 * 3 = 15 textures. We can also enable offscreen textures
#define EXPANDED_TILE_BOUNDS_X 1
#define EXPANDED_TILE_BOUNDS_Y 4
-#define MAX_TEXTURE_ALLOCATION (5+EXPANDED_TILE_BOUNDS_X*2)*(3+EXPANDED_TILE_BOUNDS_Y*2)*2
+#define MAX_TEXTURE_ALLOCATION (5+1+EXPANDED_TILE_BOUNDS_X*2)*(3+1+EXPANDED_TILE_BOUNDS_Y*2)*2
#define TILE_WIDTH 300
#define TILE_HEIGHT 300
@@ -78,6 +78,11 @@ GLint TilesManager::getMaxTextureSize()
return maxTextureSize;
}
+int TilesManager::getMaxTextureAllocation()
+{
+ return MAX_TEXTURE_ALLOCATION;
+}
+
TilesManager::TilesManager()
: m_layersMemoryUsage(0)
, m_maxTextureCount(0)
@@ -369,7 +374,8 @@ int TilesManager::maxTextureCount()
void TilesManager::setMaxTextureCount(int max)
{
XLOG("setMaxTextureCount: %d", max);
- if (m_maxTextureCount >= max && m_maxTextureCount)
+ if (max > MAX_TEXTURE_ALLOCATION ||
+ (m_maxTextureCount >= max && m_maxTextureCount))
return;
android::Mutex::Autolock lock(m_texturesLock);
diff --git a/WebCore/platform/graphics/android/TilesManager.h b/WebCore/platform/graphics/android/TilesManager.h
index eeb38fe..29b7fc1 100644
--- a/WebCore/platform/graphics/android/TilesManager.h
+++ b/WebCore/platform/graphics/android/TilesManager.h
@@ -45,6 +45,7 @@ class TilesManager {
public:
static TilesManager* instance();
static GLint getMaxTextureSize();
+ static int getMaxTextureAllocation();
static bool hardwareAccelerationEnabled()
{