|
Lines 56-61
a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp_sec1
|
| 56 |
#include "WebDataSource.h" |
56 |
#include "WebDataSource.h" |
| 57 |
#include "WebDevToolsAgentClient.h" |
57 |
#include "WebDevToolsAgentClient.h" |
| 58 |
#include "WebFrameImpl.h" |
58 |
#include "WebFrameImpl.h" |
|
|
59 |
#include "WebInputEvent.h" |
| 59 |
#include "platform/WebRect.h" |
60 |
#include "platform/WebRect.h" |
| 60 |
#include "platform/WebString.h" |
61 |
#include "platform/WebString.h" |
| 61 |
#include "platform/WebURL.h" |
62 |
#include "platform/WebURL.h" |
|
Lines 77-82
static const int viewportGutter = 97;
a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp_sec2
|
| 77 |
|
78 |
|
| 78 |
// Use 99 as a big z-order number so that highlight is above other overlays. |
79 |
// Use 99 as a big z-order number so that highlight is above other overlays. |
| 79 |
static const int highlight = 99; |
80 |
static const int highlight = 99; |
|
|
81 |
|
| 82 |
static const int devToolsDashBoard = 100; |
| 80 |
} |
83 |
} |
| 81 |
|
84 |
|
| 82 |
namespace WebKit { |
85 |
namespace WebKit { |
|
Lines 366-371
private:
a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp_sec3
|
| 366 |
double m_originalZoomFactor; |
369 |
double m_originalZoomFactor; |
| 367 |
}; |
370 |
}; |
| 368 |
|
371 |
|
|
|
372 |
class DevToolsDashBoard : public WebPageOverlay { |
| 373 |
public: |
| 374 |
DevToolsDashBoard(WebViewImpl* webView, WebDevToolsAgentImpl* webDevToolsAgentImpl) |
| 375 |
: m_webView(webView) |
| 376 |
, m_webDevToolsAgent(webDevToolsAgentImpl) |
| 377 |
, m_button(this) |
| 378 |
{ |
| 379 |
m_webView->addPageOverlay(this, OverlayZOrders::devToolsDashBoard); |
| 380 |
} |
| 381 |
|
| 382 |
~DevToolsDashBoard() |
| 383 |
{ |
| 384 |
m_webView->removePageOverlay(this); |
| 385 |
} |
| 386 |
|
| 387 |
void handleInputEvent(const WebMouseEvent* mouseEvent) |
| 388 |
{ |
| 389 |
bool isFocused, isPressed; |
| 390 |
m_button.getState(isFocused, isPressed); |
| 391 |
isFocused = m_button.drawRectContains(mouseEvent->x, mouseEvent->y); |
| 392 |
switch (mouseEvent->type) { |
| 393 |
case WebInputEvent::MouseUp: |
| 394 |
if (isFocused && isPressed) |
| 395 |
m_webDevToolsAgent->resumeDebugger(); |
| 396 |
isPressed = false; |
| 397 |
break; |
| 398 |
case WebInputEvent::MouseDown: |
| 399 |
if (isFocused) |
| 400 |
isPressed = true; |
| 401 |
break; |
| 402 |
default: |
| 403 |
break; |
| 404 |
} |
| 405 |
m_button.updateState(isFocused, isPressed); |
| 406 |
} |
| 407 |
|
| 408 |
private: |
| 409 |
static const int fontSize = 30; |
| 410 |
static const int buttonWidth = 40; |
| 411 |
static const int buttonHeight = 40; |
| 412 |
// Negative vaule means counting from the right/bottom |
| 413 |
static const int buttonX = -190; |
| 414 |
static const int buttonY = 25; |
| 415 |
static const int textX = -145; |
| 416 |
static const int textY = 52; |
| 417 |
static const RGBA32 textColor = 0xFFFF0000; |
| 418 |
static const RGBA32 backgroundColor = 0x1F000000; |
| 419 |
|
| 420 |
class Button { |
| 421 |
public: |
| 422 |
Button(DevToolsDashBoard* devToolsDashBoard) |
| 423 |
: m_dashBoard(devToolsDashBoard) |
| 424 |
, m_drawRect() |
| 425 |
, m_isFocused(false) |
| 426 |
, m_isPressed(false) |
| 427 |
{ |
| 428 |
m_drawRect.setSize(IntSize(buttonWidth, buttonHeight)); |
| 429 |
} |
| 430 |
|
| 431 |
void draw(GraphicsContext* context) |
| 432 |
{ |
| 433 |
DEFINE_STATIC_LOCAL(RefPtr<Image>, buttonImageDefault, (Image::loadPlatformResource("mediaplayerPlayDisabled"))); |
| 434 |
DEFINE_STATIC_LOCAL(RefPtr<Image>, buttonImage, (Image::loadPlatformResource("mediaplayerPlay"))); |
| 435 |
DEFINE_STATIC_LOCAL(RefPtr<Image>, buttonImageDown, (Image::loadPlatformResource("mediaplayerPlayDown"))); |
| 436 |
DEFINE_STATIC_LOCAL(RefPtr<Image>, buttonImageHover, (Image::loadPlatformResource("mediaplayerPlayHover"))); |
| 437 |
Image* image = 0; |
| 438 |
if (m_isFocused) { |
| 439 |
if (m_isPressed) |
| 440 |
image = buttonImageDown.get(); |
| 441 |
else |
| 442 |
image = buttonImage.get(); |
| 443 |
} else { |
| 444 |
if (m_isPressed) |
| 445 |
image = buttonImageHover.get(); |
| 446 |
else |
| 447 |
image = buttonImageDefault.get(); |
| 448 |
} |
| 449 |
context->drawImage(image, ColorSpaceDeviceRGB, m_drawRect); |
| 450 |
} |
| 451 |
|
| 452 |
void getState(bool& isFocused, bool& isPressed) |
| 453 |
{ |
| 454 |
isFocused = m_isFocused; |
| 455 |
isPressed = m_isPressed; |
| 456 |
} |
| 457 |
|
| 458 |
void updateState(bool isFocused, bool isPressed) |
| 459 |
{ |
| 460 |
if (m_isFocused != isFocused || m_isPressed != isPressed) { |
| 461 |
m_isFocused = isFocused; |
| 462 |
m_isPressed = isPressed; |
| 463 |
m_dashBoard->m_webView->pageOverlays()->update(); |
| 464 |
} |
| 465 |
} |
| 466 |
|
| 467 |
bool drawRectContains(int x, int y) |
| 468 |
{ |
| 469 |
return m_drawRect.contains(x, y); |
| 470 |
} |
| 471 |
|
| 472 |
void setLocation(const IntPoint& location) |
| 473 |
{ |
| 474 |
m_drawRect.setLocation(location); |
| 475 |
} |
| 476 |
|
| 477 |
private: |
| 478 |
DevToolsDashBoard* m_dashBoard; |
| 479 |
IntRect m_drawRect; |
| 480 |
bool m_isFocused; |
| 481 |
bool m_isPressed; |
| 482 |
}; |
| 483 |
|
| 484 |
IntPoint DashBoardIntPoint(int x, int y, const IntSize& viewSize) |
| 485 |
{ |
| 486 |
if (x < 0) |
| 487 |
x += viewSize.width(); |
| 488 |
if (y < 0) |
| 489 |
y += viewSize.height(); |
| 490 |
return IntPoint(x, y); |
| 491 |
} |
| 492 |
|
| 493 |
void setUpFontDescription(FontDescription& fontDescription, WebCore::Settings* settings) |
| 494 |
{ |
| 495 |
fontDescription.setRenderingMode(settings->fontRenderingMode()); |
| 496 |
fontDescription.setComputedSize(fontSize); |
| 497 |
const AtomicString& fixedFontFamily = settings->fixedFontFamily(); |
| 498 |
if (!fixedFontFamily.isEmpty()) { |
| 499 |
fontDescription.setGenericFamily(FontDescription::MonospaceFamily); |
| 500 |
fontDescription.firstFamily().setFamily(fixedFontFamily); |
| 501 |
fontDescription.firstFamily().appendFamily(0); |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
void drawText(GraphicsContext& context, String text, FloatPoint point) |
| 506 |
{ |
| 507 |
Frame* frame = m_webView->page() ? m_webView->page()->mainFrame() : 0; |
| 508 |
if (!frame) |
| 509 |
return; |
| 510 |
Settings* settings = frame->settings(); |
| 511 |
FontDescription desc; |
| 512 |
setUpFontDescription(desc, settings); |
| 513 |
Font font = Font(desc, 0, 0); |
| 514 |
font.update(0); |
| 515 |
context.drawText(font, text, point); |
| 516 |
} |
| 517 |
|
| 518 |
virtual void paintPageOverlay(WebCanvas* canvas) |
| 519 |
{ |
| 520 |
GraphicsContextBuilder builder(canvas); |
| 521 |
GraphicsContext& context = builder.context(); |
| 522 |
|
| 523 |
context.setFillColor(backgroundColor, ColorSpaceDeviceRGB); |
| 524 |
context.drawRect(IntRect(IntPoint(), m_webView->size())); |
| 525 |
|
| 526 |
m_button.setLocation(DashBoardIntPoint(buttonX, buttonY, m_webView->size())); |
| 527 |
m_button.draw(&context); |
| 528 |
|
| 529 |
context.setFillColor(textColor, ColorSpaceDeviceRGB); |
| 530 |
drawText(context, "Paused", DashBoardIntPoint(textX, textY, m_webView->size())); |
| 531 |
} |
| 532 |
|
| 533 |
WebViewImpl* m_webView; |
| 534 |
WebDevToolsAgentImpl* m_webDevToolsAgent; |
| 535 |
int m_buttonState; |
| 536 |
Button m_button; |
| 537 |
}; |
| 538 |
|
| 369 |
|
539 |
|
| 370 |
WebDevToolsAgentImpl::WebDevToolsAgentImpl( |
540 |
WebDevToolsAgentImpl::WebDevToolsAgentImpl( |
| 371 |
WebViewImpl* webViewImpl, |
541 |
WebViewImpl* webViewImpl, |
|
Lines 444-449
void WebDevToolsAgentImpl::webViewResized()
a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp_sec4
|
| 444 |
m_metricsSupport->webViewResized(); |
614 |
m_metricsSupport->webViewResized(); |
| 445 |
} |
615 |
} |
| 446 |
|
616 |
|
|
|
617 |
void WebDevToolsAgentImpl::handleInputEvent(const WebInputEvent* inputEvent) |
| 618 |
{ |
| 619 |
if (m_devToolsDashBoard && WebInputEvent::isMouseEventType(inputEvent->type)) |
| 620 |
m_devToolsDashBoard->handleInputEvent(static_cast<const WebMouseEvent*>(inputEvent)); |
| 621 |
} |
| 622 |
|
| 623 |
void WebDevToolsAgentImpl::showPauseWarning() |
| 624 |
{ |
| 625 |
if (!m_devToolsDashBoard) |
| 626 |
m_devToolsDashBoard = adoptPtr(new DevToolsDashBoard(m_webViewImpl, this)); |
| 627 |
} |
| 628 |
|
| 629 |
void WebDevToolsAgentImpl::hidePauseWarning() |
| 630 |
{ |
| 631 |
if (m_devToolsDashBoard) |
| 632 |
m_devToolsDashBoard.clear(); |
| 633 |
} |
| 634 |
|
| 447 |
void WebDevToolsAgentImpl::overrideDeviceMetrics(int width, int height, float fontScaleFactor, bool fitWindow) |
635 |
void WebDevToolsAgentImpl::overrideDeviceMetrics(int width, int height, float fontScaleFactor, bool fitWindow) |
| 448 |
{ |
636 |
{ |
| 449 |
if (!width && !height) { |
637 |
if (!width && !height) { |
|
Lines 614-617
WebString WebDevToolsAgent::disconnectEventAsText()
a/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp_sec5
|
| 614 |
return channel.m_message; |
802 |
return channel.m_message; |
| 615 |
} |
803 |
} |
| 616 |
|
804 |
|
|
|
805 |
void WebDevToolsAgentImpl::resumeDebugger() |
| 806 |
{ |
| 807 |
if (InspectorController* controller = inspectorController()) |
| 808 |
controller->resume(); |
| 809 |
} |
| 810 |
|
| 617 |
} // namespace WebKit |
811 |
} // namespace WebKit |