| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 446 |
| 447 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior) | 447 bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
havior selectionBehavior) |
| 448 { | 448 { |
| 449 LocalFrame* focused = focusedCoreFrame(); | 449 LocalFrame* focused = focusedCoreFrame(); |
| 450 if (!focused || !m_imeAcceptEvents) | 450 if (!focused || !m_imeAcceptEvents) |
| 451 return false; | 451 return false; |
| 452 | 452 |
| 453 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); | 453 return focused->inputMethodController().confirmCompositionOrInsertText(text,
selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : Inp
utMethodController::DoNotKeepSelection); |
| 454 } | 454 } |
| 455 | 455 |
| 456 bool WebViewImpl::compositionRange(size_t* location, size_t* length) | |
| 457 { | |
| 458 LocalFrame* focused = focusedCoreFrame(); | |
| 459 if (!focused || !m_imeAcceptEvents) | |
| 460 return false; | |
| 461 | |
| 462 RefPtr<Range> range = focused->inputMethodController().compositionRange(); | |
| 463 if (!range) | |
| 464 return false; | |
| 465 | |
| 466 Element* editable = focused->selection().rootEditableElementOrDocumentElemen
t(); | |
| 467 ASSERT(editable); | |
| 468 PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get()
)); | |
| 469 if (plainTextRange.isNull()) | |
| 470 return false; | |
| 471 *location = plainTextRange.start(); | |
| 472 *length = plainTextRange.length(); | |
| 473 return true; | |
| 474 } | |
| 475 | |
| 476 WebTextInputInfo WebViewImpl::textInputInfo() | 456 WebTextInputInfo WebViewImpl::textInputInfo() |
| 477 { | 457 { |
| 478 WebTextInputInfo info; | 458 WebTextInputInfo info; |
| 479 | 459 |
| 480 LocalFrame* focused = focusedCoreFrame(); | 460 LocalFrame* focused = focusedCoreFrame(); |
| 481 if (!focused) | 461 if (!focused) |
| 482 return info; | 462 return info; |
| 483 | 463 |
| 484 FrameSelection& selection = focused->selection(); | 464 FrameSelection& selection = focused->selection(); |
| 485 Element* element = selection.selection().rootEditableElement(); | 465 Element* element = selection.selection().rootEditableElement(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 return WebVector<WebCompositionUnderline>(); | 555 return WebVector<WebCompositionUnderline>(); |
| 576 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl
ler().customCompositionUnderlines(); | 556 const Vector<CompositionUnderline>& underlines = focused->inputMethodControl
ler().customCompositionUnderlines(); |
| 577 WebVector<WebCompositionUnderline> results(underlines.size()); | 557 WebVector<WebCompositionUnderline> results(underlines.size()); |
| 578 for (size_t index = 0; index < underlines.size(); ++index) { | 558 for (size_t index = 0; index < underlines.size(); ++index) { |
| 579 CompositionUnderline underline = underlines[index]; | 559 CompositionUnderline underline = underlines[index]; |
| 580 results[index] = WebCompositionUnderline(underline.startOffset, underlin
e.endOffset, static_cast<WebColor>(underline.color.rgb()), underline.thick, stat
ic_cast<WebColor>(underline.backgroundColor.rgb())); | 560 results[index] = WebCompositionUnderline(underline.startOffset, underlin
e.endOffset, static_cast<WebColor>(underline.color.rgb()), underline.thick, stat
ic_cast<WebColor>(underline.backgroundColor.rgb())); |
| 581 } | 561 } |
| 582 return results; | 562 return results; |
| 583 } | 563 } |
| 584 | 564 |
| 585 WebColor WebViewImpl::backgroundColor() const | |
| 586 { | |
| 587 if (isTransparent()) | |
| 588 return Color::transparent; | |
| 589 if (!m_page) | |
| 590 return m_baseBackgroundColor; | |
| 591 if (!m_page->mainFrame()) | |
| 592 return m_baseBackgroundColor; | |
| 593 FrameView* view = m_page->mainFrame()->view(); | |
| 594 return view->documentBackgroundColor().rgb(); | |
| 595 } | |
| 596 | |
| 597 // WebView -------------------------------------------------------------------- | 565 // WebView -------------------------------------------------------------------- |
| 598 | 566 |
| 599 WebSettingsImpl* WebViewImpl::settingsImpl() | 567 WebSettingsImpl* WebViewImpl::settingsImpl() |
| 600 { | 568 { |
| 601 if (!m_webSettings) | 569 if (!m_webSettings) |
| 602 m_webSettings = adoptPtr(new WebSettingsImpl(&m_page->settings())); | 570 m_webSettings = adoptPtr(new WebSettingsImpl(&m_page->settings())); |
| 603 ASSERT(m_webSettings); | 571 ASSERT(m_webSettings); |
| 604 return m_webSettings.get(); | 572 return m_webSettings.get(); |
| 605 } | 573 } |
| 606 | 574 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 617 WebFrame* WebViewImpl::focusedFrame() | 585 WebFrame* WebViewImpl::focusedFrame() |
| 618 { | 586 { |
| 619 return WebFrame::fromFrame(focusedCoreFrame()); | 587 return WebFrame::fromFrame(focusedCoreFrame()); |
| 620 } | 588 } |
| 621 | 589 |
| 622 void WebViewImpl::injectModule(const WebString& path) | 590 void WebViewImpl::injectModule(const WebString& path) |
| 623 { | 591 { |
| 624 RefPtr<Document> document = m_page->mainFrame()->document(); | 592 RefPtr<Document> document = m_page->mainFrame()->document(); |
| 625 RefPtr<HTMLImportElement> import = HTMLImportElement::create(*document); | 593 RefPtr<HTMLImportElement> import = HTMLImportElement::create(*document); |
| 626 import->setAttribute(HTMLNames::srcAttr, path); | 594 import->setAttribute(HTMLNames::srcAttr, path); |
| 627 if (!document->documentElement()) | 595 document->appendChild(import.release()); |
| 628 return; | |
| 629 document->documentElement()->appendChild(import.release()); | |
| 630 } | 596 } |
| 631 | 597 |
| 632 void WebViewImpl::setFocusedFrame(WebFrame* frame) | 598 void WebViewImpl::setFocusedFrame(WebFrame* frame) |
| 633 { | 599 { |
| 634 if (!frame) { | 600 if (!frame) { |
| 635 // Clears the focused frame if any. | 601 // Clears the focused frame if any. |
| 636 LocalFrame* focusedFrame = focusedCoreFrame(); | 602 LocalFrame* focusedFrame = focusedCoreFrame(); |
| 637 if (focusedFrame) | 603 if (focusedFrame) |
| 638 focusedFrame->selection().setFocused(false); | 604 focusedFrame->selection().setFocused(false); |
| 639 return; | 605 return; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, | 805 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, |
| 840 bool isInitialState) { | 806 bool isInitialState) { |
| 841 if (!page()) | 807 if (!page()) |
| 842 return; | 808 return; |
| 843 | 809 |
| 844 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState =
= WebPageVisibilityStateHidden); | 810 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState =
= WebPageVisibilityStateHidden); |
| 845 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int>
(visibilityState)), isInitialState); | 811 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int>
(visibilityState)), isInitialState); |
| 846 } | 812 } |
| 847 | 813 |
| 848 } // namespace blink | 814 } // namespace blink |
| OLD | NEW |