double CppVariant::toDouble() const { if (isInt32()) return static_cast<double>(value.intValue); if (isDouble()) return value.doubleValue; BLINK_ASSERT_NOT_REACHED(); return 0; }
void TestInterfaces::windowClosed(WebTestProxyBase* proxy) { vector<WebTestProxyBase*>::iterator pos = find(m_windowList.begin(), m_windowList.end(), proxy); if (pos == m_windowList.end()) { BLINK_ASSERT_NOT_REACHED(); return; } m_windowList.erase(pos); }
int ScrollbarGroup::visibleWidth() const { if (m_horizontalScrollbar) return m_horizontalScrollbar->scrollbar()->width(); if (m_verticalScrollbar) return m_verticalScrollbar->scrollbar()->width(); BLINK_ASSERT_NOT_REACHED(); return 0; }
IntPoint ScrollbarGroup::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint& parentPoint) const { if (m_horizontalScrollbar && scrollbar == m_horizontalScrollbar->scrollbar()) return m_horizontalScrollbar->convertFromContainingViewToScrollbar(parentPoint); if (m_verticalScrollbar && scrollbar == m_verticalScrollbar->scrollbar()) return m_verticalScrollbar->convertFromContainingViewToScrollbar(parentPoint); BLINK_ASSERT_NOT_REACHED(); return IntPoint(); }
TestPlugin::Primitive TestPlugin::parsePrimitive(const WebString& string) { static const WebString kPrimitiveNone = WebString::fromUTF8("none"); static const WebString kPrimitiveTriangle = WebString::fromUTF8("triangle"); Primitive primitive = PrimitiveNone; if (string == kPrimitiveNone) primitive = PrimitiveNone; else if (string == kPrimitiveTriangle) primitive = PrimitiveTriangle; else BLINK_ASSERT_NOT_REACHED(); return primitive; }
// FIXME: This method should already exist. Use it. // For now just parse primary colors. void TestPlugin::parseColor(const WebString& string, unsigned color[3]) { color[0] = color[1] = color[2] = 0; if (string == "black") return; if (string == "red") color[0] = 255; else if (string == "green") color[1] = 255; else if (string == "blue") color[2] = 255; else BLINK_ASSERT_NOT_REACHED(); }
void WebTestThemeControlWin::markState() { // The horizontal lines in a read only control are spaced by this amount. const int readOnlyLineOffset = 5; // The length of a triangle side for the corner marks. const int triangleSize = 5; switch (m_state) { case UnknownState: case DisabledState: case NormalState: case IndeterminateState: // Don't visually mark these states (color is enough). break; case ReadOnlyState: // Drawing lines across the control. for (int i = m_top + readOnlyLineOffset; i < m_bottom; i += readOnlyLineOffset) line(m_left + 1, i, m_right - 1, i, readOnlyColor); break; case HotState: // Draw a triangle in the upper left corner of the control. triangle(m_left, m_top, m_left + triangleSize, m_top, m_left, m_top + triangleSize, m_edgeColor); break; case HoverState: // Draw a triangle in the upper right corner of the control. triangle(m_right, m_top, m_right, m_top + triangleSize, m_right - triangleSize, m_top, m_edgeColor); break; case FocusedState: // Draw a triangle in the bottom right corner of the control. triangle(m_right, m_bottom, m_right - triangleSize, m_bottom, m_right, m_bottom - triangleSize, m_edgeColor); break; case PressedState: // Draw a triangle in the bottom left corner of the control. triangle(m_left, m_bottom, m_left, m_bottom - triangleSize, m_left + triangleSize, m_bottom, m_edgeColor); break; default: BLINK_ASSERT_NOT_REACHED(); break; } }
bool TestPlugin::handleDragStatusUpdate(WebDragStatus dragStatus, const WebDragData&, WebDragOperationsMask, const WebPoint& position, const WebPoint& screenPosition) { const char* dragStatusName = 0; switch (dragStatus) { case WebDragStatusEnter: dragStatusName = "DragEnter"; break; case WebDragStatusOver: dragStatusName = "DragOver"; break; case WebDragStatusLeave: dragStatusName = "DragLeave"; break; case WebDragStatusDrop: dragStatusName = "DragDrop"; break; case WebDragStatusUnknown: BLINK_ASSERT_NOT_REACHED(); } m_delegate->printMessage(std::string("Plugin received event: ") + dragStatusName + "\n"); return false; }
void WebTestThemeControlWin::draw() { int halfWidth = m_width / 2; int halfHeight = m_height / 2; int quarterWidth = m_width / 4; int quarterHeight = m_height / 4; // Indent amounts for the check in a checkbox or radio button. const int checkIndent = 3; // Indent amounts for short and long sides of the scrollbar notches. const int notchLongOffset = 1; const int notchShortOffset = 4; const int noOffset = 0; // Indent amounts for the short and long sides of a scroll thumb box. const int thumbLongIndent = 0; const int thumbShortIndent = 2; // Indents for the crosshatch on a scroll grip. const int gripLongIndent = 3; const int gripShortIndent = 5; // Indents for the the slider track. const int sliderIndent = 2; switch (m_type) { case UnknownType: BLINK_ASSERT_NOT_REACHED(); break; case TextFieldType: // We render this by hand outside of this function. BLINK_ASSERT_NOT_REACHED(); break; case PushButtonType: // push buttons render as a rounded rectangle roundRect(m_bgColor); break; case UncheckedBoxType: // Unchecked boxes are simply plain boxes. box(m_irect, m_bgColor); break; case CheckedBoxType: nestedBoxes(checkIndent, checkIndent, checkIndent, checkIndent, m_bgColor, m_fgColor); break; case IndeterminateCheckboxType: // Indeterminate checkbox is a box containing '-'. nestedBoxes(checkIndent, halfHeight, checkIndent, halfHeight, m_bgColor, m_fgColor); break; case UncheckedRadioType: circle(SkIntToScalar(halfHeight), m_bgColor); break; case CheckedRadioType: circle(SkIntToScalar(halfHeight), m_bgColor); circle(SkIntToScalar(halfHeight - checkIndent), m_fgColor); break; case HorizontalScrollTrackBackType: { // Draw a box with a notch at the left. int longOffset = halfHeight - notchLongOffset; int shortOffset = m_width - notchShortOffset; nestedBoxes(noOffset, longOffset, shortOffset, longOffset, m_bgColor, m_edgeColor); break; } case HorizontalScrollTrackForwardType: { // Draw a box with a notch at the right. int longOffset = halfHeight - notchLongOffset; int shortOffset = m_width - notchShortOffset; nestedBoxes(shortOffset, longOffset, noOffset, longOffset, m_bgColor, m_fgColor); break; } case VerticalScrollTrackBackType: { // Draw a box with a notch at the top. int longOffset = halfWidth - notchLongOffset; int shortOffset = m_height - notchShortOffset; nestedBoxes(longOffset, noOffset, longOffset, shortOffset, m_bgColor, m_fgColor); break; } case VerticalScrollTrackForwardType: { // Draw a box with a notch at the bottom. int longOffset = halfWidth - notchLongOffset; int shortOffset = m_height - notchShortOffset; nestedBoxes(longOffset, shortOffset, longOffset, noOffset, m_bgColor, m_fgColor); break; } case HorizontalScrollThumbType: // Draw a narrower box on top of the outside box. nestedBoxes(thumbLongIndent, thumbShortIndent, thumbLongIndent, thumbShortIndent, m_bgColor, m_bgColor); break; case VerticalScrollThumbType: // Draw a shorter box on top of the outside box. nestedBoxes(thumbShortIndent, thumbLongIndent, thumbShortIndent, thumbLongIndent, m_bgColor, m_bgColor); break; case HorizontalSliderThumbType: case VerticalSliderThumbType: // Slider thumbs are ovals. oval(m_bgColor); break; case HorizontalScrollGripType: { // Draw a horizontal crosshatch for the grip. int longOffset = halfWidth - gripLongIndent; line(m_left + gripLongIndent, m_top + halfHeight, m_right - gripLongIndent, m_top + halfHeight, m_fgColor); line(m_left + longOffset, m_top + gripShortIndent, m_left + longOffset, m_bottom - gripShortIndent, m_fgColor); line(m_right - longOffset, m_top + gripShortIndent, m_right - longOffset, m_bottom - gripShortIndent, m_fgColor); break; } case VerticalScrollGripType: { // Draw a vertical crosshatch for the grip. int longOffset = halfHeight - gripLongIndent; line(m_left + halfWidth, m_top + gripLongIndent, m_left + halfWidth, m_bottom - gripLongIndent, m_fgColor); line(m_left + gripShortIndent, m_top + longOffset, m_right - gripShortIndent, m_top + longOffset, m_fgColor); line(m_left + gripShortIndent, m_bottom - longOffset, m_right - gripShortIndent, m_bottom - longOffset, m_fgColor); break; } case LeftArrowType: // Draw a left arrow inside a box. box(m_irect, m_bgColor); triangle(m_right - quarterWidth, m_top + quarterHeight, m_right - quarterWidth, m_bottom - quarterHeight, m_left + quarterWidth, m_top + halfHeight, m_fgColor); break; case RightArrowType: // Draw a left arrow inside a box. box(m_irect, m_bgColor); triangle(m_left + quarterWidth, m_top + quarterHeight, m_right - quarterWidth, m_top + halfHeight, m_left + quarterWidth, m_bottom - quarterHeight, m_fgColor); break; case UpArrowType: // Draw an up arrow inside a box. box(m_irect, m_bgColor); triangle(m_left + quarterWidth, m_bottom - quarterHeight, m_left + halfWidth, m_top + quarterHeight, m_right - quarterWidth, m_bottom - quarterHeight, m_fgColor); break; case DownArrowType: // Draw a down arrow inside a box. box(m_irect, m_bgColor); triangle(m_left + quarterWidth, m_top + quarterHeight, m_right - quarterWidth, m_top + quarterHeight, m_left + halfWidth, m_bottom - quarterHeight, m_fgColor); break; case HorizontalSliderTrackType: { // Draw a narrow rect for the track plus box hatches on the ends. SkIRect lirect; lirect = m_irect; lirect.inset(noOffset, halfHeight - sliderIndent); box(lirect, m_bgColor); line(m_left, m_top, m_left, m_bottom, m_edgeColor); line(m_right, m_top, m_right, m_bottom, m_edgeColor); break; } case VerticalSliderTrackType: { // Draw a narrow rect for the track plus box hatches on the ends. SkIRect lirect; lirect = m_irect; lirect.inset(halfWidth - sliderIndent, noOffset); box(lirect, m_bgColor); line(m_left, m_top, m_right, m_top, m_edgeColor); line(m_left, m_bottom, m_right, m_bottom, m_edgeColor); break; } case DropDownButtonType: // Draw a box with a big down arrow on top. box(m_irect, m_bgColor); triangle(m_left + quarterWidth, m_top, m_right - quarterWidth, m_top, m_left + halfWidth, m_bottom, m_fgColor); break; default: BLINK_ASSERT_NOT_REACHED(); break; } markState(); }