Example #1
0
static void logPluginRequest(Page* page, const String& mimeType, const String& url, bool success)
{
    if (!page || !page->settings()->diagnosticLoggingEnabled())
        return;

    String newMIMEType = mimeType;
    if (!newMIMEType) {
        // Try to figure out the MIME type from the URL extension.
        newMIMEType = findPluginMIMETypeFromURL(page, url);
        if (!newMIMEType)
            return;
    }

    PluginData* pluginData = page->pluginData();
    String pluginFile = pluginData ? pluginData->pluginFileForMimeType(newMIMEType) : String();
    String description = !pluginFile ? newMIMEType : pluginFile;

    ChromeClient* client = page->chrome().client();
    client->logDiagnosticMessage(success ? DiagnosticLoggingKeys::pluginLoadedKey() : DiagnosticLoggingKeys::pluginLoadingFailedKey(), description, DiagnosticLoggingKeys::noopKey());

    if (!page->hasSeenAnyPlugin())
        client->logDiagnosticMessage(DiagnosticLoggingKeys::pageContainsAtLeastOnePluginKey(), emptyString(), DiagnosticLoggingKeys::noopKey());
    
    if (!page->hasSeenPlugin(description))
        client->logDiagnosticMessage(DiagnosticLoggingKeys::pageContainsPluginKey(), description, DiagnosticLoggingKeys::noopKey());

    page->sawPlugin(description);
}
Example #2
0
void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotification notification)
{
    if (obj && obj->isAccessibilityScrollbar() && notification == AXValueChanged) {
        // Send document value changed on scrollbar value changed notification.
        Scrollbar* scrollBar = static_cast<AccessibilityScrollbar*>(obj)->scrollbar();
        if (!scrollBar || !scrollBar->parent() || !scrollBar->parent()->isFrameView())
            return;
        Document* document = toFrameView(scrollBar->parent())->frame()->document();
        if (document != document->topDocument())
            return;
        obj = get(document->renderer());
    }

    if (!obj || !obj->document() || !obj->documentFrameView() || !obj->documentFrameView()->frame() || !obj->documentFrameView()->frame()->page())
        return;

    ChromeClient* client = obj->documentFrameView()->frame()->page()->chrome().client();
    if (!client)
        return;

    switch (notification) {
    case AXActiveDescendantChanged:
        if (!obj->document()->focusedNode() || (obj->node() != obj->document()->focusedNode()))
            break;

        // Calling handleFocusedUIElementChanged will focus the new active
        // descendant and send the AXFocusedUIElementChanged notification.
        handleFocusedUIElementChanged(0, obj->document()->focusedNode());
        break;
    case AXAriaAttributeChanged:
    case AXAutocorrectionOccured:
    case AXCheckedStateChanged:
    case AXChildrenChanged:
    case AXFocusedUIElementChanged:
    case AXInvalidStatusChanged:
    case AXLayoutComplete:
    case AXLiveRegionChanged:
    case AXLoadComplete:
    case AXMenuListItemSelected:
    case AXMenuListValueChanged:
    case AXRowCollapsed:
    case AXRowCountChanged:
    case AXRowExpanded:
    case AXScrolledToAnchor:
    case AXSelectedChildrenChanged:
    case AXSelectedTextChanged:
    case AXTextChanged:
    case AXValueChanged:
        break;
    }

    client->postAccessibilityNotification(obj, notification);
}
void RenderThemeQStyle::setPaletteFromPageClientIfExists(QPalette& palette) const
{
    if (!m_page)
        return;

    ChromeClient* chromeClient = m_page->chrome().client();
    if (!chromeClient)
        return;

    if (QWebPageClient* pageClient = chromeClient->platformPageClient())
        palette = pageClient->palette();
}
void ColorInputType::handleDOMActivateEvent(Event* event)
{
    if (element().isDisabledFormControl() || !element().layoutObject())
        return;

    if (!UserGestureIndicator::processingUserGesture())
        return;

    ChromeClient* chromeClient = this->chromeClient();
    if (chromeClient && !m_chooser)
        m_chooser = chromeClient->openColorChooser(element().document().frame(), this, valueAsColor());

    event->setDefaultHandled();
}
Example #5
0
void RenderThemeQt::setPaletteFromPageClientIfExists(QPalette& palette) const
{
    // If the webview has a custom palette, use it
    if (!m_page)
        return;
    Chrome* chrome = m_page->chrome();
    if (!chrome)
        return;
    ChromeClient* chromeClient = chrome->client();
    if (!chromeClient)
        return;
    QWebPageClient* pageClient = chromeClient->platformPageClient();
    if (!pageClient)
        return;
    palette = pageClient->palette();
}
Example #6
0
void TextFieldInputType::createShadowSubtree()
{
    ASSERT(element()->hasShadowRoot());

    ASSERT(!m_innerText);
    ASSERT(!m_innerBlock);
    ASSERT(!m_innerSpinButton);

    Document* document = element()->document();
    ChromeClient* chromeClient = document->page() ? document->page()->chrome()->client() : 0;
    bool shouldAddDecorations = chromeClient && chromeClient->willAddTextFieldDecorationsTo(element());
    bool shouldHaveSpinButton = this->shouldHaveSpinButton();
    bool createsContainer = shouldHaveSpinButton || needsContainer() || shouldAddDecorations;

    ExceptionCode ec = 0;
    m_innerText = TextControlInnerTextElement::create(document);
    if (!createsContainer) {
        element()->shadowTree()->oldestShadowRoot()->appendChild(m_innerText, ec);
        return;
    }

    ShadowRoot* shadowRoot = element()->shadowTree()->oldestShadowRoot();
    m_container = HTMLDivElement::create(document);
    m_container->setShadowPseudoId("-webkit-textfield-decoration-container");
    shadowRoot->appendChild(m_container, ec);

    m_innerBlock = TextControlInnerElement::create(document);
    m_innerBlock->appendChild(m_innerText, ec);
    m_container->appendChild(m_innerBlock, ec);

#if ENABLE(INPUT_SPEECH)
    ASSERT(!m_speechButton);
    if (element()->isSpeechEnabled()) {
        m_speechButton = InputFieldSpeechButtonElement::create(document);
        m_container->appendChild(m_speechButton, ec);
    }
#endif

    if (shouldHaveSpinButton) {
        m_innerSpinButton = SpinButtonElement::create(document);
        m_container->appendChild(m_innerSpinButton, ec);
    }

    if (shouldAddDecorations)
        chromeClient->addTextFieldDecorationsTo(element());
}
Example #7
0
void TextFieldInputType::createShadowSubtree()
{
    ASSERT(element()->shadow());

    ASSERT(!m_innerText);
    ASSERT(!m_innerBlock);
    ASSERT(!m_innerSpinButton);

    Document* document = element()->document();
    ChromeClient* chromeClient = document->page() ? document->page()->chrome()->client() : 0;
    bool shouldAddDecorations = chromeClient && chromeClient->willAddTextFieldDecorationsTo(element());
    bool shouldHaveSpinButton = this->shouldHaveSpinButton();
    bool createsContainer = shouldHaveSpinButton || needsContainer() || shouldAddDecorations;

    m_innerText = TextControlInnerTextElement::create(document);
    if (!createsContainer) {
        element()->userAgentShadowRoot()->appendChild(m_innerText, IGNORE_EXCEPTION);
        return;
    }

    ShadowRoot* shadowRoot = element()->userAgentShadowRoot();
    m_container = TextControlInnerContainer::create(document);
    m_container->setPseudo(AtomicString("-webkit-textfield-decoration-container", AtomicString::ConstructFromLiteral));
    shadowRoot->appendChild(m_container, IGNORE_EXCEPTION);

    m_innerBlock = TextControlInnerElement::create(document);
    m_innerBlock->appendChild(m_innerText, IGNORE_EXCEPTION);
    m_container->appendChild(m_innerBlock, IGNORE_EXCEPTION);

#if ENABLE(INPUT_SPEECH)
    ASSERT(!m_speechButton);
    if (element()->isSpeechEnabled()) {
        m_speechButton = InputFieldSpeechButtonElement::create(document);
        m_container->appendChild(m_speechButton, IGNORE_EXCEPTION);
    }
#endif

    if (shouldHaveSpinButton) {
        m_innerSpinButton = SpinButtonElement::create(document, *this);
        m_container->appendChild(m_innerSpinButton, IGNORE_EXCEPTION);
    }

    if (shouldAddDecorations)
        chromeClient->addTextFieldDecorationsTo(element());
}
Example #8
0
bool RenderSVGRoot::isEmbeddedThroughSVGImage() const
{
    if (!node())
        return false;

    Frame* frame = node()->document()->frame();
    if (!frame)
        return false;

    // Test whether we're embedded through an img.
    if (!frame->page() || !frame->page()->chrome())
        return false;

    ChromeClient* chromeClient = frame->page()->chrome()->client();
    if (!chromeClient || !chromeClient->isSVGImageChromeClient())
        return false;

    return true;
}
Example #9
0
void FormData::generateFiles(Document* document)
{
    ASSERT(!m_hasGeneratedFiles);

    if (m_hasGeneratedFiles)
        return;

    Page* page = document->page();
    if (!page)
        return;
    ChromeClient* client = page->chrome()->client();

    size_t n = m_elements.size();
    for (size_t i = 0; i < n; ++i) {
        FormDataElement& e = m_elements[i];
        if (e.m_type == FormDataElement::encodedFile && e.m_shouldGenerateFile) {
            e.m_generatedFilename = client->generateReplacementFile(e.m_filename);
            m_hasGeneratedFiles = true;
        }
    }
}
void RenderThemeQt::setPaletteFromPageClientIfExists(QPalette& palette) const
{
#if USE(QT_MOBILE_THEME)
    static QPalette lightGrayPalette(Qt::lightGray);
    palette = lightGrayPalette;
    return;
#endif
    // If the webview has a custom palette, use it
    if (!m_page)
        return;
    Chrome* chrome = m_page->chrome();
    if (!chrome)
        return;
    ChromeClient* chromeClient = chrome->client();
    if (!chromeClient)
        return;
    QWebPageClient* pageClient = chromeClient->platformPageClient();
    if (!pageClient)
        return;
    palette = pageClient->palette();
}
Example #11
0
TEST_F(ChromeClientTest, SetToolTipFlood) {
  ChromeClientToolTipLogger logger;
  ChromeClient* client = &logger;
  HitTestResult result(HitTestRequest(HitTestRequest::Move),
                       LayoutPoint(10, 20));
  Document* doc = Document::create();
  Element* element = HTMLElement::create(HTMLNames::divTag, *doc);
  element->setAttribute(HTMLNames::titleAttr, "tooltip");
  result.setInnerNode(element);

  client->setToolTip(*doc->frame(), result);
  EXPECT_EQ("tooltip", logger.toolTipForLastSetToolTip());

  // seToolTip(HitTestResult) again in the same condition.
  logger.clearToolTipForLastSetToolTip();
  client->setToolTip(*doc->frame(), result);
  // setToolTip(String,TextDirection) should not be called.
  EXPECT_EQ(String(), logger.toolTipForLastSetToolTip());

  // Cancel the tooltip, and setToolTip(HitTestResult) again.
  client->clearToolTip(*doc->frame());
  logger.clearToolTipForLastSetToolTip();
  client->setToolTip(*doc->frame(), result);
  // setToolTip(String,TextDirection) should not be called.
  EXPECT_EQ(String(), logger.toolTipForLastSetToolTip());

  logger.clearToolTipForLastSetToolTip();
  element->setAttribute(HTMLNames::titleAttr, "updated");
  client->setToolTip(*doc->frame(), result);
  // setToolTip(String,TextDirection) should be called because tooltip string
  // is different from the last one.
  EXPECT_EQ("updated", logger.toolTipForLastSetToolTip());
}
Example #12
0
void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotification notification)
{
    if (!obj || !obj->document() || !obj->documentFrameView() || !obj->documentFrameView()->frame() || !obj->documentFrameView()->frame()->page())
        return;

    ChromeClient* client = obj->documentFrameView()->frame()->page()->chrome()->client();
    if (!client)
        return;

    switch (notification) {
    case AXActiveDescendantChanged:
        if (!obj->document()->focusedNode() || (obj->node() != obj->document()->focusedNode()))
            break;

        // Calling handleFocusedUIElementChanged will focus the new active
        // descendant and send the AXFocusedUIElementChanged notification.
        handleFocusedUIElementChanged(0, obj->document()->focusedNode()->renderer());
        break;
    case AXCheckedStateChanged:
    case AXChildrenChanged:
    case AXFocusedUIElementChanged:
    case AXLayoutComplete:
    case AXLiveRegionChanged:
    case AXLoadComplete:
    case AXMenuListValueChanged:
    case AXRowCollapsed:
    case AXRowCountChanged:
    case AXRowExpanded:
    case AXScrolledToAnchor:
    case AXSelectedChildrenChanged:
    case AXSelectedTextChanged:
    case AXValueChanged:
        break;
    }

    client->postAccessibilityNotification(obj, notification);
}
WebScreenOrientationType ScreenOrientationController::effectiveType(ChromeClient& chromeClient)
{
    return m_override ? m_overrideType : chromeClient.screenInfo().orientationType;
}
unsigned short ScreenOrientationController::effectiveAngle(ChromeClient& chromeClient)
{
    return m_override ? m_overrideAngle : chromeClient.screenInfo().orientationAngle;
}
Example #15
0
ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const
{
    // Default bits: no focus, no mouse over
    option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);

    if (!isEnabled(o))
        option.state &= ~QStyle::State_Enabled;

    if (isReadOnlyControl(o))
        // Readonly is supported on textfields.
        option.state |= QStyle::State_ReadOnly;

    if (supportsFocus(o->style()->appearance()) && isFocused(o)) {
        option.state |= QStyle::State_HasFocus;
        option.state |= QStyle::State_KeyboardFocusChange;
    }

    if (isHovered(o))
        option.state |= QStyle::State_MouseOver;

    option.direction = Qt::LeftToRight;
    if (o->style() && o->style()->direction() == WebCore::RTL)
        option.direction = Qt::RightToLeft;

    ControlPart result = o->style()->appearance();

    switch (result) {
    case PushButtonPart:
    case SquareButtonPart:
    case ButtonPart:
    case ButtonBevelPart:
    case ListItemPart:
    case MenulistButtonPart:
    case SearchFieldResultsButtonPart:
    case SearchFieldCancelButtonPart: {
        if (isPressed(o))
            option.state |= QStyle::State_Sunken;
        else if (result == PushButtonPart)
            option.state |= QStyle::State_Raised;
        break;
    }
    }

    if (result == RadioPart || result == CheckboxPart)
        option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off);

#ifdef Q_WS_MAEMO_5
    static QPalette lightGrayPalette(Qt::lightGray);
    option.palette = lightGrayPalette;
#else
    // If the owner widget has a custom palette, use it
    Page* page = o->document()->page();
    if (page) {
        ChromeClient* client = page->chrome()->client();
        QWebPageClient* pageClient = client->platformPageClient();
        if (pageClient)
            option.palette = pageClient->palette();
    }
#endif

    return result;
}