| 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 2406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2417 | 2417 |
| 2418 Frame* focusedFrame = focusedCoreFrame(); | 2418 Frame* focusedFrame = focusedCoreFrame(); |
| 2419 if (!focusedFrame->isLocalFrame()) | 2419 if (!focusedFrame->isLocalFrame()) |
| 2420 return info; | 2420 return info; |
| 2421 | 2421 |
| 2422 LocalFrame* focused = toLocalFrame(focusedFrame); | 2422 LocalFrame* focused = toLocalFrame(focusedFrame); |
| 2423 if (!focused) | 2423 if (!focused) |
| 2424 return info; | 2424 return info; |
| 2425 | 2425 |
| 2426 FrameSelection& selection = focused->selection(); | 2426 FrameSelection& selection = focused->selection(); |
| 2427 if (!selection.isAvailable()) { |
| 2428 // plugins/mouse-capture-inside-shadow.html reaches here. |
| 2429 return info; |
| 2430 } |
| 2427 Element* element = selection.selection().rootEditableElement(); | 2431 Element* element = selection.selection().rootEditableElement(); |
| 2428 if (!element) | 2432 if (!element) |
| 2429 return info; | 2433 return info; |
| 2430 | 2434 |
| 2431 info.inputMode = inputModeOfFocusedElement(); | 2435 info.inputMode = inputModeOfFocusedElement(); |
| 2432 | 2436 |
| 2433 info.type = textInputType(); | 2437 info.type = textInputType(); |
| 2434 info.flags = textInputFlags(); | 2438 info.flags = textInputFlags(); |
| 2435 if (info.type == WebTextInputTypeNone) | 2439 if (info.type == WebTextInputTypeNone) |
| 2436 return info; | 2440 return info; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2465 | 2469 |
| 2466 return info; | 2470 return info; |
| 2467 } | 2471 } |
| 2468 | 2472 |
| 2469 WebTextInputType WebViewImpl::textInputType() | 2473 WebTextInputType WebViewImpl::textInputType() |
| 2470 { | 2474 { |
| 2471 LocalFrame* focusedFrame = m_page->focusController().focusedFrame(); | 2475 LocalFrame* focusedFrame = m_page->focusController().focusedFrame(); |
| 2472 if (!focusedFrame) | 2476 if (!focusedFrame) |
| 2473 return WebTextInputTypeNone; | 2477 return WebTextInputTypeNone; |
| 2474 | 2478 |
| 2479 if (!focusedFrame->selection().isAvailable()) { |
| 2480 // "mouse-capture-inside-shadow.html" reaches here. |
| 2481 return WebTextInputTypeNone; |
| 2482 } |
| 2483 |
| 2475 // It's important to preserve the equivalence of textInputInfo().type and te
xtInputType(), | 2484 // It's important to preserve the equivalence of textInputInfo().type and te
xtInputType(), |
| 2476 // so perform the same rootEditableElement() existence check here for consis
tency. | 2485 // so perform the same rootEditableElement() existence check here for consis
tency. |
| 2477 if (!focusedFrame || !focusedFrame->selection().selection().rootEditableElem
ent()) | 2486 if (!focusedFrame->selection().selection().rootEditableElement()) |
| 2478 return WebTextInputTypeNone; | 2487 return WebTextInputTypeNone; |
| 2479 | 2488 |
| 2480 Document* document = focusedFrame->document(); | 2489 Document* document = focusedFrame->document(); |
| 2481 if (!document) | 2490 if (!document) |
| 2482 return WebTextInputTypeNone; | 2491 return WebTextInputTypeNone; |
| 2483 | 2492 |
| 2484 Element* element = document->focusedElement(); | 2493 Element* element = document->focusedElement(); |
| 2485 if (!element) | 2494 if (!element) |
| 2486 return WebTextInputTypeNone; | 2495 return WebTextInputTypeNone; |
| 2487 | 2496 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2616 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const | 2625 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const |
| 2617 { | 2626 { |
| 2618 const Frame* frame = focusedCoreFrame(); | 2627 const Frame* frame = focusedCoreFrame(); |
| 2619 if (!frame || !frame->isLocalFrame()) | 2628 if (!frame || !frame->isLocalFrame()) |
| 2620 return false; | 2629 return false; |
| 2621 | 2630 |
| 2622 const LocalFrame* localFrame = toLocalFrame(frame); | 2631 const LocalFrame* localFrame = toLocalFrame(frame); |
| 2623 if (!localFrame) | 2632 if (!localFrame) |
| 2624 return false; | 2633 return false; |
| 2625 FrameSelection& selection = localFrame->selection(); | 2634 FrameSelection& selection = localFrame->selection(); |
| 2635 if (!selection.isAvailable()) { |
| 2636 // plugins/mouse-capture-inside-shadow.html reaches here. |
| 2637 return false; |
| 2638 } |
| 2626 | 2639 |
| 2627 if (selection.isCaret()) { | 2640 if (selection.isCaret()) { |
| 2628 anchor = focus = selection.absoluteCaretBounds(); | 2641 anchor = focus = selection.absoluteCaretBounds(); |
| 2629 } else { | 2642 } else { |
| 2630 const EphemeralRange selectedRange = selection.selection().toNormalizedE
phemeralRange(); | 2643 const EphemeralRange selectedRange = selection.selection().toNormalizedE
phemeralRange(); |
| 2631 if (selectedRange.isNull()) | 2644 if (selectedRange.isNull()) |
| 2632 return false; | 2645 return false; |
| 2633 anchor = localFrame->editor().firstRectForRange(EphemeralRange(selectedR
ange.startPosition())); | 2646 anchor = localFrame->editor().firstRectForRange(EphemeralRange(selectedR
ange.startPosition())); |
| 2634 focus = localFrame->editor().firstRectForRange(EphemeralRange(selectedRa
nge.endPosition())); | 2647 focus = localFrame->editor().firstRectForRange(EphemeralRange(selectedRa
nge.endPosition())); |
| 2635 } | 2648 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2648 if (container && container->supportsInputMethod()) | 2661 if (container && container->supportsInputMethod()) |
| 2649 return container->plugin(); | 2662 return container->plugin(); |
| 2650 return nullptr; | 2663 return nullptr; |
| 2651 } | 2664 } |
| 2652 | 2665 |
| 2653 bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirecti
on& end) const | 2666 bool WebViewImpl::selectionTextDirection(WebTextDirection& start, WebTextDirecti
on& end) const |
| 2654 { | 2667 { |
| 2655 const Frame* frame = focusedCoreFrame(); | 2668 const Frame* frame = focusedCoreFrame(); |
| 2656 if (!frame || frame->isRemoteFrame()) | 2669 if (!frame || frame->isRemoteFrame()) |
| 2657 return false; | 2670 return false; |
| 2658 FrameSelection& selection = toLocalFrame(frame)->selection(); | 2671 const FrameSelection& selection = toLocalFrame(frame)->selection(); |
| 2672 if (!selection.isAvailable()) { |
| 2673 // plugins/mouse-capture-inside-shadow.html reaches here. |
| 2674 return false; |
| 2675 } |
| 2659 if (selection.selection().toNormalizedEphemeralRange().isNull()) | 2676 if (selection.selection().toNormalizedEphemeralRange().isNull()) |
| 2660 return false; | 2677 return false; |
| 2661 start = toWebTextDirection(primaryDirectionOf(*selection.start().anchorNode(
))); | 2678 start = toWebTextDirection(primaryDirectionOf(*selection.start().anchorNode(
))); |
| 2662 end = toWebTextDirection(primaryDirectionOf(*selection.end().anchorNode())); | 2679 end = toWebTextDirection(primaryDirectionOf(*selection.end().anchorNode())); |
| 2663 return true; | 2680 return true; |
| 2664 } | 2681 } |
| 2665 | 2682 |
| 2666 bool WebViewImpl::isSelectionAnchorFirst() const | 2683 bool WebViewImpl::isSelectionAnchorFirst() const |
| 2667 { | 2684 { |
| 2668 const Frame* frame = focusedCoreFrame(); | 2685 const Frame* frame = focusedCoreFrame(); |
| 2669 if (!frame || frame->isRemoteFrame()) | 2686 if (!frame || frame->isRemoteFrame()) |
| 2670 return false; | 2687 return false; |
| 2671 return toLocalFrame(frame)->selection().selection().isBaseFirst(); | 2688 FrameSelection& selection = toLocalFrame(frame)->selection(); |
| 2689 if (!selection.isAvailable()) { |
| 2690 // plugins/mouse-capture-inside-shadow.html reaches here. |
| 2691 return false; |
| 2692 } |
| 2693 return selection.selection().isBaseFirst(); |
| 2672 } | 2694 } |
| 2673 | 2695 |
| 2674 WebColor WebViewImpl::backgroundColor() const | 2696 WebColor WebViewImpl::backgroundColor() const |
| 2675 { | 2697 { |
| 2676 if (isTransparent()) | 2698 if (isTransparent()) |
| 2677 return Color::transparent; | 2699 return Color::transparent; |
| 2678 if (!m_page) | 2700 if (!m_page) |
| 2679 return m_baseBackgroundColor; | 2701 return m_baseBackgroundColor; |
| 2680 if (!m_page->mainFrame()) | 2702 if (!m_page->mainFrame()) |
| 2681 return m_baseBackgroundColor; | 2703 return m_baseBackgroundColor; |
| (...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4553 { | 4575 { |
| 4554 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than | 4576 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than |
| 4555 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4577 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
| 4556 if (!page()) | 4578 if (!page()) |
| 4557 return 1; | 4579 return 1; |
| 4558 | 4580 |
| 4559 return page()->deviceScaleFactor(); | 4581 return page()->deviceScaleFactor(); |
| 4560 } | 4582 } |
| 4561 | 4583 |
| 4562 } // namespace blink | 4584 } // namespace blink |
| OLD | NEW |