Commit 6faa7f3a authored by enne@chromium.org's avatar enne@chromium.org

Remove unused WebTestProxy paint/canvas code

BUG=none

Review URL: https://codereview.chromium.org/282083003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271180 0039d316-1c4b-4281-b951-d872f2087c98
parent db00ff83
...@@ -2510,7 +2510,6 @@ std::string TestRunner::PathToLocalResource(const std::string& path) { ...@@ -2510,7 +2510,6 @@ std::string TestRunner::PathToLocalResource(const std::string& path) {
void TestRunner::SetBackingScaleFactor(double value, void TestRunner::SetBackingScaleFactor(double value,
v8::Handle<v8::Function> callback) { v8::Handle<v8::Function> callback) {
delegate_->setDeviceScaleFactor(value); delegate_->setDeviceScaleFactor(value);
proxy_->DiscardBackingStore();
delegate_->postTask(new InvokeCallbackTask(this, callback)); delegate_->postTask(new InvokeCallbackTask(this, callback));
} }
......
...@@ -312,15 +312,7 @@ WebView* WebTestProxyBase::GetWebView() const { ...@@ -312,15 +312,7 @@ WebView* WebTestProxyBase::GetWebView() const {
return static_cast<WebView*>(web_widget_); return static_cast<WebView*>(web_widget_);
} }
void WebTestProxyBase::DidForceResize() {
InvalidateAll();
DiscardBackingStore();
}
void WebTestProxyBase::Reset() { void WebTestProxyBase::Reset() {
paint_rect_ = WebRect();
canvas_.reset();
is_painting_ = false;
animate_scheduled_ = false; animate_scheduled_ = false;
resource_identifier_map_.clear(); resource_identifier_map_.clear();
log_console_output_ = true; log_console_output_ = true;
...@@ -428,11 +420,23 @@ void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) { ...@@ -428,11 +420,23 @@ void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) {
void WebTestProxyBase::CapturePixelsForPrinting( void WebTestProxyBase::CapturePixelsForPrinting(
const base::Callback<void(const SkBitmap&)>& callback) { const base::Callback<void(const SkBitmap&)>& callback) {
// TODO(enne): get rid of stateful canvas().
web_widget_->layout(); web_widget_->layout();
PaintPagesWithBoundaries();
DrawSelectionRect(GetCanvas()); WebSize pageSizeInPixels = web_widget_->size();
SkBaseDevice* device = skia::GetTopDevice(*GetCanvas()); WebFrame* webFrame = GetWebView()->mainFrame();
int pageCount = webFrame->printBegin(pageSizeInPixels);
int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1;
bool isOpaque = false;
skia::RefPtr<SkCanvas> canvas(skia::AdoptRef(skia::TryCreateBitmapCanvas(
pageSizeInPixels.width, totalHeight, isOpaque)));
if (canvas)
webFrame->printPagesWithBoundaries(canvas.get(), pageSizeInPixels);
webFrame->printEnd();
DrawSelectionRect(canvas.get());
SkBaseDevice* device = skia::GetTopDevice(*canvas);
const SkBitmap& bitmap = device->accessBitmap(false); const SkBitmap& bitmap = device->accessBitmap(false);
callback.Run(bitmap); callback.Run(bitmap);
} }
...@@ -459,48 +463,6 @@ void WebTestProxyBase::SetLogConsoleOutput(bool enabled) { ...@@ -459,48 +463,6 @@ void WebTestProxyBase::SetLogConsoleOutput(bool enabled) {
log_console_output_ = enabled; log_console_output_ = enabled;
} }
void WebTestProxyBase::PaintPagesWithBoundaries() {
DCHECK(!is_painting_);
DCHECK(GetCanvas());
is_painting_ = true;
WebSize pageSizeInPixels = web_widget_->size();
WebFrame* webFrame = GetWebView()->mainFrame();
int pageCount = webFrame->printBegin(pageSizeInPixels);
int totalHeight = pageCount * (pageSizeInPixels.height + 1) - 1;
SkCanvas* testCanvas =
skia::TryCreateBitmapCanvas(pageSizeInPixels.width, totalHeight, false);
if (testCanvas) {
DiscardBackingStore();
canvas_.reset(testCanvas);
} else {
webFrame->printEnd();
return;
}
webFrame->printPagesWithBoundaries(GetCanvas(), pageSizeInPixels);
webFrame->printEnd();
is_painting_ = false;
}
SkCanvas* WebTestProxyBase::GetCanvas() {
if (canvas_.get()) return canvas_.get();
WebSize widgetSize = web_widget_->size();
float deviceScaleFactor = GetWebView()->deviceScaleFactor();
int scaledWidth = static_cast<int>(
ceil(static_cast<float>(widgetSize.width) * deviceScaleFactor));
int scaledHeight = static_cast<int>(
ceil(static_cast<float>(widgetSize.height) * deviceScaleFactor));
// We're allocating the canvas to be non-opaque (third parameter), so we
// don't end up with uninitialized memory if a layout test doesn't damage
// the entire view.
canvas_.reset(skia::CreateBitmapCanvas(scaledWidth, scaledHeight, false));
return canvas_.get();
}
void WebTestProxyBase::DidDisplayAsync(const base::Closure& callback, void WebTestProxyBase::DidDisplayAsync(const base::Closure& callback,
const SkBitmap& bitmap) { const SkBitmap& bitmap) {
// Verify we actually composited. // Verify we actually composited.
...@@ -517,8 +479,6 @@ void WebTestProxyBase::DisplayAsyncThen(const base::Closure& callback) { ...@@ -517,8 +479,6 @@ void WebTestProxyBase::DisplayAsyncThen(const base::Closure& callback) {
base::Unretained(this), callback)); base::Unretained(this), callback));
} }
void WebTestProxyBase::DiscardBackingStore() { canvas_.reset(); }
WebMIDIClientMock* WebTestProxyBase::GetMIDIClientMock() { WebMIDIClientMock* WebTestProxyBase::GetMIDIClientMock() {
if (!m_midiClient.get()) m_midiClient.reset(new WebMIDIClientMock); if (!m_midiClient.get()) m_midiClient.reset(new WebMIDIClientMock);
return m_midiClient.get(); return m_midiClient.get();
...@@ -532,30 +492,6 @@ MockWebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizerMock() { ...@@ -532,30 +492,6 @@ MockWebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizerMock() {
return m_speechRecognizer.get(); return m_speechRecognizer.get();
} }
void WebTestProxyBase::DidInvalidateRect(const WebRect& rect) {
// paint_rect_ = paint_rect_ U rect
if (rect.isEmpty()) return;
if (paint_rect_.isEmpty()) {
paint_rect_ = rect;
return;
}
int left = min(paint_rect_.x, rect.x);
int top = min(paint_rect_.y, rect.y);
int right = max(paint_rect_.x + paint_rect_.width, rect.x + rect.width);
int bottom = max(paint_rect_.y + paint_rect_.height, rect.y + rect.height);
paint_rect_ = WebRect(left, top, right - left, bottom - top);
}
void WebTestProxyBase::DidScrollRect(int, int, const WebRect& clipRect) {
DidInvalidateRect(clipRect);
}
void WebTestProxyBase::InvalidateAll() {
paint_rect_ = WebRect(0, 0, INT_MAX, INT_MAX);
}
void WebTestProxyBase::ScheduleComposite() { InvalidateAll(); }
void WebTestProxyBase::ScheduleAnimation() { void WebTestProxyBase::ScheduleAnimation() {
if (!test_interfaces_->testRunner()->TestIsRunning()) return; if (!test_interfaces_->testRunner()->TestIsRunning()) return;
...@@ -574,19 +510,6 @@ void WebTestProxyBase::AnimateNow() { ...@@ -574,19 +510,6 @@ void WebTestProxyBase::AnimateNow() {
} }
} }
bool WebTestProxyBase::IsCompositorFramePending() const {
return animate_scheduled_ || !paint_rect_.isEmpty();
}
void WebTestProxyBase::Show(WebNavigationPolicy) { InvalidateAll(); }
void WebTestProxyBase::SetWindowRect(const WebRect& rect) {
InvalidateAll();
DiscardBackingStore();
}
void WebTestProxyBase::DidAutoResize(const WebSize&) { InvalidateAll(); }
void WebTestProxyBase::PostAccessibilityEvent(const blink::WebAXObject& obj, void WebTestProxyBase::PostAccessibilityEvent(const blink::WebAXObject& obj,
blink::WebAXEvent event) { blink::WebAXEvent event) {
// Only hook the accessibility events occured during the test run. // Only hook the accessibility events occured during the test run.
......
...@@ -111,17 +111,12 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback { ...@@ -111,17 +111,12 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
void SetLogConsoleOutput(bool enabled); void SetLogConsoleOutput(bool enabled);
// FIXME: Make this private again.
void ScheduleComposite();
void DidOpenChooser(); void DidOpenChooser();
void DidCloseChooser(); void DidCloseChooser();
bool IsChooserShown(); bool IsChooserShown();
void DisplayAsyncThen(const base::Closure& callback); void DisplayAsyncThen(const base::Closure& callback);
void DiscardBackingStore();
blink::WebMIDIClientMock* GetMIDIClientMock(); blink::WebMIDIClientMock* GetMIDIClientMock();
MockWebSpeechRecognizer* GetSpeechRecognizerMock(); MockWebSpeechRecognizer* GetSpeechRecognizerMock();
...@@ -129,8 +124,6 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback { ...@@ -129,8 +124,6 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
blink::WebView* GetWebView() const; blink::WebView* GetWebView() const;
void DidForceResize();
void PostSpellCheckEvent(const blink::WebString& eventName); void PostSpellCheckEvent(const blink::WebString& eventName);
// WebCompositeAndReadbackAsyncCallback implementation. // WebCompositeAndReadbackAsyncCallback implementation.
...@@ -140,14 +133,7 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback { ...@@ -140,14 +133,7 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
WebTestProxyBase(); WebTestProxyBase();
~WebTestProxyBase(); ~WebTestProxyBase();
void DidInvalidateRect(const blink::WebRect&);
void DidScrollRect(int, int, const blink::WebRect&);
void ScheduleAnimation(); void ScheduleAnimation();
bool IsCompositorFramePending() const;
// FIXME: Remove once we switch to use didForceResize.
void SetWindowRect(const blink::WebRect&);
void Show(blink::WebNavigationPolicy);
void DidAutoResize(const blink::WebSize&);
void PostAccessibilityEvent(const blink::WebAXObject&, blink::WebAXEvent); void PostAccessibilityEvent(const blink::WebAXObject&, blink::WebAXEvent);
void StartDragging(blink::WebLocalFrame*, const blink::WebDragData&, void StartDragging(blink::WebLocalFrame*, const blink::WebDragData&,
blink::WebDragOperationsMask, const blink::WebImage&, blink::WebDragOperationsMask, const blink::WebImage&,
...@@ -224,9 +210,6 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback { ...@@ -224,9 +210,6 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
template <class, typename, typename> template <class, typename, typename>
friend class WebFrameTestProxy; friend class WebFrameTestProxy;
void LocationChangeDone(blink::WebFrame*); void LocationChangeDone(blink::WebFrame*);
void PaintPagesWithBoundaries();
SkCanvas* GetCanvas();
void InvalidateAll();
void AnimateNow(); void AnimateNow();
void DrawSelectionRect(SkCanvas* canvas); void DrawSelectionRect(SkCanvas* canvas);
void DidDisplayAsync(const base::Closure& callback, const SkBitmap& bitmap); void DidDisplayAsync(const base::Closure& callback, const SkBitmap& bitmap);
...@@ -242,10 +225,6 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback { ...@@ -242,10 +225,6 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
scoped_ptr<SpellCheckClient> spellcheck_; scoped_ptr<SpellCheckClient> spellcheck_;
scoped_ptr<WebUserMediaClientMock> user_media_client_; scoped_ptr<WebUserMediaClientMock> user_media_client_;
// Painting.
scoped_ptr<SkCanvas> canvas_;
blink::WebRect paint_rect_;
bool is_painting_;
bool animate_scheduled_; bool animate_scheduled_;
std::map<unsigned, std::string> resource_identifier_map_; std::map<unsigned, std::string> resource_identifier_map_;
std::deque<base::Callback<void(const SkBitmap&)> > std::deque<base::Callback<void(const SkBitmap&)> >
...@@ -271,29 +250,7 @@ class WebTestProxy : public Base, public WebTestProxyBase { ...@@ -271,29 +250,7 @@ class WebTestProxy : public Base, public WebTestProxyBase {
virtual ~WebTestProxy() {} virtual ~WebTestProxy() {}
// WebViewClient implementation. // WebViewClient implementation.
virtual void didInvalidateRect(const blink::WebRect& rect) {
WebTestProxyBase::DidInvalidateRect(rect);
}
virtual void didScrollRect(int dx, int dy, const blink::WebRect& clipRect) {
WebTestProxyBase::DidScrollRect(dx, dy, clipRect);
}
virtual void scheduleComposite() { WebTestProxyBase::ScheduleComposite(); }
virtual void scheduleAnimation() { WebTestProxyBase::ScheduleAnimation(); } virtual void scheduleAnimation() { WebTestProxyBase::ScheduleAnimation(); }
virtual bool isCompositorFramePending() const {
return WebTestProxyBase::IsCompositorFramePending();
}
virtual void setWindowRect(const blink::WebRect& rect) {
WebTestProxyBase::SetWindowRect(rect);
Base::setWindowRect(rect);
}
virtual void show(blink::WebNavigationPolicy policy) {
WebTestProxyBase::Show(policy);
Base::show(policy);
}
virtual void didAutoResize(const blink::WebSize& newSize) {
WebTestProxyBase::DidAutoResize(newSize);
Base::didAutoResize(newSize);
}
virtual void postAccessibilityEvent(const blink::WebAXObject& object, virtual void postAccessibilityEvent(const blink::WebAXObject& object,
blink::WebAXEvent event) { blink::WebAXEvent event) {
WebTestProxyBase::PostAccessibilityEvent(object, event); WebTestProxyBase::PostAccessibilityEvent(object, event);
......
...@@ -147,7 +147,6 @@ void ForceResizeRenderView(RenderView* render_view, ...@@ -147,7 +147,6 @@ void ForceResizeRenderView(RenderView* render_view,
const WebSize& new_size) { const WebSize& new_size) {
RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view); RenderViewImpl* render_view_impl = static_cast<RenderViewImpl*>(render_view);
render_view_impl->ForceResizeForTesting(new_size); render_view_impl->ForceResizeForTesting(new_size);
GetWebTestProxyBase(render_view_impl)->DidForceResize();
} }
void SetDeviceScaleFactor(RenderView* render_view, float factor) { void SetDeviceScaleFactor(RenderView* render_view, float factor) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment