OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 return; | 773 return; |
774 | 774 |
775 if (frame()->document()->isSandboxed(SandboxModals)) { | 775 if (frame()->document()->isSandboxed(SandboxModals)) { |
776 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); | 776 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); |
777 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { | 777 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { |
778 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'alert()'. The document is sandboxed, a
nd the 'allow-modals' keyword is not set.")); | 778 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'alert()'. The document is sandboxed, a
nd the 'allow-modals' keyword is not set.")); |
779 return; | 779 return; |
780 } | 780 } |
781 } | 781 } |
782 | 782 |
783 frame()->document()->updateLayoutTree(); | 783 frame()->document()->updateStyleAndLayoutTree(); |
784 | 784 |
785 FrameHost* host = frame()->host(); | 785 FrameHost* host = frame()->host(); |
786 if (!host) | 786 if (!host) |
787 return; | 787 return; |
788 | 788 |
789 host->chromeClient().openJavaScriptAlert(frame(), message); | 789 host->chromeClient().openJavaScriptAlert(frame(), message); |
790 } | 790 } |
791 | 791 |
792 bool LocalDOMWindow::confirm(const String& message) | 792 bool LocalDOMWindow::confirm(const String& message) |
793 { | 793 { |
794 if (!frame()) | 794 if (!frame()) |
795 return false; | 795 return false; |
796 | 796 |
797 if (frame()->document()->isSandboxed(SandboxModals)) { | 797 if (frame()->document()->isSandboxed(SandboxModals)) { |
798 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); | 798 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); |
799 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { | 799 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { |
800 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'confirm()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); | 800 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'confirm()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); |
801 return false; | 801 return false; |
802 } | 802 } |
803 } | 803 } |
804 | 804 |
805 frame()->document()->updateLayoutTree(); | 805 frame()->document()->updateStyleAndLayoutTree(); |
806 | 806 |
807 FrameHost* host = frame()->host(); | 807 FrameHost* host = frame()->host(); |
808 if (!host) | 808 if (!host) |
809 return false; | 809 return false; |
810 | 810 |
811 return host->chromeClient().openJavaScriptConfirm(frame(), message); | 811 return host->chromeClient().openJavaScriptConfirm(frame(), message); |
812 } | 812 } |
813 | 813 |
814 String LocalDOMWindow::prompt(const String& message, const String& defaultValue) | 814 String LocalDOMWindow::prompt(const String& message, const String& defaultValue) |
815 { | 815 { |
816 if (!frame()) | 816 if (!frame()) |
817 return String(); | 817 return String(); |
818 | 818 |
819 if (frame()->document()->isSandboxed(SandboxModals)) { | 819 if (frame()->document()->isSandboxed(SandboxModals)) { |
820 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); | 820 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); |
821 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { | 821 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { |
822 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'prompt()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); | 822 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'prompt()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); |
823 return String(); | 823 return String(); |
824 } | 824 } |
825 } | 825 } |
826 | 826 |
827 frame()->document()->updateLayoutTree(); | 827 frame()->document()->updateStyleAndLayoutTree(); |
828 | 828 |
829 FrameHost* host = frame()->host(); | 829 FrameHost* host = frame()->host(); |
830 if (!host) | 830 if (!host) |
831 return String(); | 831 return String(); |
832 | 832 |
833 String returnValue; | 833 String returnValue; |
834 if (host->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue
, returnValue)) | 834 if (host->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue
, returnValue)) |
835 return returnValue; | 835 return returnValue; |
836 | 836 |
837 return String(); | 837 return String(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 | 888 |
889 FrameHost* host = frame->host(); | 889 FrameHost* host = frame->host(); |
890 if (!host) | 890 if (!host) |
891 return FloatSize(); | 891 return FloatSize(); |
892 | 892 |
893 // The main frame's viewport size depends on the page scale. Since the | 893 // The main frame's viewport size depends on the page scale. Since the |
894 // initial page scale depends on the content width and is set after a | 894 // initial page scale depends on the content width and is set after a |
895 // layout, perform one now so queries during page load will use the up to | 895 // layout, perform one now so queries during page load will use the up to |
896 // date viewport. | 896 // date viewport. |
897 if (host->settings().viewportEnabled() && frame->isMainFrame()) | 897 if (host->settings().viewportEnabled() && frame->isMainFrame()) |
898 frame->document()->updateLayoutIgnorePendingStylesheets(); | 898 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
899 | 899 |
900 // FIXME: This is potentially too much work. We really only need to know the
dimensions of the parent frame's layoutObject. | 900 // FIXME: This is potentially too much work. We really only need to know the
dimensions of the parent frame's layoutObject. |
901 if (Frame* parent = frame->tree().parent()) { | 901 if (Frame* parent = frame->tree().parent()) { |
902 if (parent && parent->isLocalFrame()) | 902 if (parent && parent->isLocalFrame()) |
903 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee
ts(); | 903 toLocalFrame(parent)->document()->updateStyleAndLayoutIgnorePendingS
tylesheets(); |
904 } | 904 } |
905 | 905 |
906 return frame->isMainFrame() && !host->settings().inertVisualViewport() | 906 return frame->isMainFrame() && !host->settings().inertVisualViewport() |
907 ? FloatSize(host->visualViewport().visibleRect().size()) | 907 ? FloatSize(host->visualViewport().visibleRect().size()) |
908 : FloatSize(view->visibleContentRect(IncludeScrollbars).size()); | 908 : FloatSize(view->visibleContentRect(IncludeScrollbars).size()); |
909 } | 909 } |
910 | 910 |
911 int LocalDOMWindow::innerHeight() const | 911 int LocalDOMWindow::innerHeight() const |
912 { | 912 { |
913 if (!frame()) | 913 if (!frame()) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 return 0; | 960 return 0; |
961 | 961 |
962 FrameView* view = frame()->view(); | 962 FrameView* view = frame()->view(); |
963 if (!view) | 963 if (!view) |
964 return 0; | 964 return 0; |
965 | 965 |
966 FrameHost* host = frame()->host(); | 966 FrameHost* host = frame()->host(); |
967 if (!host) | 967 if (!host) |
968 return 0; | 968 return 0; |
969 | 969 |
970 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 970 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
971 | 971 |
972 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); | 972 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
973 double viewportX = viewport->scrollPositionDouble().x(); | 973 double viewportX = viewport->scrollPositionDouble().x(); |
974 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); | 974 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); |
975 } | 975 } |
976 | 976 |
977 double LocalDOMWindow::scrollY() const | 977 double LocalDOMWindow::scrollY() const |
978 { | 978 { |
979 if (!frame()) | 979 if (!frame()) |
980 return 0; | 980 return 0; |
981 | 981 |
982 FrameView* view = frame()->view(); | 982 FrameView* view = frame()->view(); |
983 if (!view) | 983 if (!view) |
984 return 0; | 984 return 0; |
985 | 985 |
986 FrameHost* host = frame()->host(); | 986 FrameHost* host = frame()->host(); |
987 if (!host) | 987 if (!host) |
988 return 0; | 988 return 0; |
989 | 989 |
990 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 990 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
991 | 991 |
992 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); | 992 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
993 double viewportY = viewport->scrollPositionDouble().y(); | 993 double viewportY = viewport->scrollPositionDouble().y(); |
994 return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); | 994 return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); |
995 } | 995 } |
996 | 996 |
997 const AtomicString& LocalDOMWindow::name() const | 997 const AtomicString& LocalDOMWindow::name() const |
998 { | 998 { |
999 if (!isCurrentlyDisplayedInFrame()) | 999 if (!isCurrentlyDisplayedInFrame()) |
1000 return nullAtom; | 1000 return nullAtom; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 if (!isCurrentlyDisplayedInFrame()) | 1068 if (!isCurrentlyDisplayedInFrame()) |
1069 return nullptr; | 1069 return nullptr; |
1070 | 1070 |
1071 unsigned colonStart = pseudoElement[0] == ':' ? (pseudoElement[1] == ':' ? 2
: 1) : 0; | 1071 unsigned colonStart = pseudoElement[0] == ':' ? (pseudoElement[1] == ':' ? 2
: 1) : 0; |
1072 CSSSelector::PseudoType pseudoType = CSSSelector::parsePseudoType(AtomicStri
ng(pseudoElement.substring(colonStart)), false); | 1072 CSSSelector::PseudoType pseudoType = CSSSelector::parsePseudoType(AtomicStri
ng(pseudoElement.substring(colonStart)), false); |
1073 if (pseudoType == CSSSelector::PseudoUnknown && !pseudoElement.isEmpty()) | 1073 if (pseudoType == CSSSelector::PseudoUnknown && !pseudoElement.isEmpty()) |
1074 return nullptr; | 1074 return nullptr; |
1075 | 1075 |
1076 unsigned rulesToInclude = StyleResolver::AuthorCSSRules; | 1076 unsigned rulesToInclude = StyleResolver::AuthorCSSRules; |
1077 PseudoId pseudoId = CSSSelector::pseudoId(pseudoType); | 1077 PseudoId pseudoId = CSSSelector::pseudoId(pseudoType); |
1078 element->document().updateLayoutTree(); | 1078 element->document().updateStyleAndLayoutTree(); |
1079 return frame()->document()->ensureStyleResolver().pseudoCSSRulesForElement(e
lement, pseudoId, rulesToInclude); | 1079 return frame()->document()->ensureStyleResolver().pseudoCSSRulesForElement(e
lement, pseudoId, rulesToInclude); |
1080 } | 1080 } |
1081 | 1081 |
1082 double LocalDOMWindow::devicePixelRatio() const | 1082 double LocalDOMWindow::devicePixelRatio() const |
1083 { | 1083 { |
1084 if (!frame()) | 1084 if (!frame()) |
1085 return 0.0; | 1085 return 0.0; |
1086 | 1086 |
1087 return frame()->devicePixelRatio(); | 1087 return frame()->devicePixelRatio(); |
1088 } | 1088 } |
1089 | 1089 |
1090 void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior)
const | 1090 void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior)
const |
1091 { | 1091 { |
1092 if (!isCurrentlyDisplayedInFrame()) | 1092 if (!isCurrentlyDisplayedInFrame()) |
1093 return; | 1093 return; |
1094 | 1094 |
1095 document()->updateLayoutIgnorePendingStylesheets(); | 1095 document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1096 | 1096 |
1097 FrameView* view = frame()->view(); | 1097 FrameView* view = frame()->view(); |
1098 if (!view) | 1098 if (!view) |
1099 return; | 1099 return; |
1100 | 1100 |
1101 FrameHost* host = frame()->host(); | 1101 FrameHost* host = frame()->host(); |
1102 if (!host) | 1102 if (!host) |
1103 return; | 1103 return; |
1104 | 1104 |
1105 x = ScrollableArea::normalizeNonFiniteScroll(x); | 1105 x = ScrollableArea::normalizeNonFiniteScroll(x); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 FrameHost* host = frame()->host(); | 1138 FrameHost* host = frame()->host(); |
1139 if (!host) | 1139 if (!host) |
1140 return; | 1140 return; |
1141 | 1141 |
1142 x = ScrollableArea::normalizeNonFiniteScroll(x); | 1142 x = ScrollableArea::normalizeNonFiniteScroll(x); |
1143 y = ScrollableArea::normalizeNonFiniteScroll(y); | 1143 y = ScrollableArea::normalizeNonFiniteScroll(y); |
1144 | 1144 |
1145 // It is only necessary to have an up-to-date layout if the position may be
clamped, | 1145 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
1146 // which is never the case for (0, 0). | 1146 // which is never the case for (0, 0). |
1147 if (x || y) | 1147 if (x || y) |
1148 document()->updateLayoutIgnorePendingStylesheets(); | 1148 document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1149 | 1149 |
1150 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); | 1150 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); |
1151 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); | 1151 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1152 viewport->setScrollPosition(layoutPos, ProgrammaticScroll, ScrollBehaviorAut
o); | 1152 viewport->setScrollPosition(layoutPos, ProgrammaticScroll, ScrollBehaviorAut
o); |
1153 } | 1153 } |
1154 | 1154 |
1155 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const | 1155 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const |
1156 { | 1156 { |
1157 if (!isCurrentlyDisplayedInFrame()) | 1157 if (!isCurrentlyDisplayedInFrame()) |
1158 return; | 1158 return; |
1159 | 1159 |
1160 FrameView* view = frame()->view(); | 1160 FrameView* view = frame()->view(); |
1161 if (!view) | 1161 if (!view) |
1162 return; | 1162 return; |
1163 | 1163 |
1164 FrameHost* host = frame()->host(); | 1164 FrameHost* host = frame()->host(); |
1165 if (!host) | 1165 if (!host) |
1166 return; | 1166 return; |
1167 | 1167 |
1168 // It is only necessary to have an up-to-date layout if the position may be
clamped, | 1168 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
1169 // which is never the case for (0, 0). | 1169 // which is never the case for (0, 0). |
1170 if (!scrollToOptions.hasLeft() | 1170 if (!scrollToOptions.hasLeft() |
1171 || !scrollToOptions.hasTop() | 1171 || !scrollToOptions.hasTop() |
1172 || scrollToOptions.left() | 1172 || scrollToOptions.left() |
1173 || scrollToOptions.top()) { | 1173 || scrollToOptions.top()) { |
1174 document()->updateLayoutIgnorePendingStylesheets(); | 1174 document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1175 } | 1175 } |
1176 | 1176 |
1177 double scaledX = 0.0; | 1177 double scaledX = 0.0; |
1178 double scaledY = 0.0; | 1178 double scaledY = 0.0; |
1179 | 1179 |
1180 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); | 1180 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1181 | 1181 |
1182 DoublePoint currentOffset = viewport->scrollPositionDouble(); | 1182 DoublePoint currentOffset = viewport->scrollPositionDouble(); |
1183 scaledX = currentOffset.x(); | 1183 scaledX = currentOffset.x(); |
1184 scaledY = currentOffset.y(); | 1184 scaledY = currentOffset.y(); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 { | 1505 { |
1506 // If the LocalDOMWindow still has a frame reference, that frame must point | 1506 // If the LocalDOMWindow still has a frame reference, that frame must point |
1507 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1507 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
1508 // where script execution leaks between different LocalDOMWindows. | 1508 // where script execution leaks between different LocalDOMWindows. |
1509 if (m_frameObserver->frame()) | 1509 if (m_frameObserver->frame()) |
1510 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); | 1510 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); |
1511 return m_frameObserver->frame(); | 1511 return m_frameObserver->frame(); |
1512 } | 1512 } |
1513 | 1513 |
1514 } // namespace blink | 1514 } // namespace blink |
OLD | NEW |