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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 } | 794 } |
795 | 795 |
796 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { | 796 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
797 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Alert); | 797 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Alert); |
798 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { | 798 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { |
799 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'alert()' during microtask execution.")
); | 799 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'alert()' during microtask execution.")
); |
800 return; | 800 return; |
801 } | 801 } |
802 } | 802 } |
803 | 803 |
804 frame()->document()->updateLayoutTree(); | 804 frame()->document()->updateStyleAndLayoutTree(); |
805 | 805 |
806 FrameHost* host = frame()->host(); | 806 FrameHost* host = frame()->host(); |
807 if (!host) | 807 if (!host) |
808 return; | 808 return; |
809 | 809 |
810 host->chromeClient().openJavaScriptAlert(frame(), message); | 810 host->chromeClient().openJavaScriptAlert(frame(), message); |
811 } | 811 } |
812 | 812 |
813 bool LocalDOMWindow::confirm(ScriptState* scriptState, const String& message) | 813 bool LocalDOMWindow::confirm(ScriptState* scriptState, const String& message) |
814 { | 814 { |
815 if (!frame()) | 815 if (!frame()) |
816 return false; | 816 return false; |
817 | 817 |
818 if (frame()->document()->isSandboxed(SandboxModals)) { | 818 if (frame()->document()->isSandboxed(SandboxModals)) { |
819 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); | 819 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); |
820 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { | 820 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { |
821 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'confirm()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); | 821 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'confirm()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); |
822 return false; | 822 return false; |
823 } | 823 } |
824 } | 824 } |
825 | 825 |
826 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { | 826 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
827 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Confirm); | 827 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Confirm); |
828 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { | 828 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { |
829 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'confirm()' during microtask execution.
")); | 829 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'confirm()' during microtask execution.
")); |
830 return false; | 830 return false; |
831 } | 831 } |
832 } | 832 } |
833 | 833 |
834 frame()->document()->updateLayoutTree(); | 834 frame()->document()->updateStyleAndLayoutTree(); |
835 | 835 |
836 FrameHost* host = frame()->host(); | 836 FrameHost* host = frame()->host(); |
837 if (!host) | 837 if (!host) |
838 return false; | 838 return false; |
839 | 839 |
840 return host->chromeClient().openJavaScriptConfirm(frame(), message); | 840 return host->chromeClient().openJavaScriptConfirm(frame(), message); |
841 } | 841 } |
842 | 842 |
843 String LocalDOMWindow::prompt(ScriptState* scriptState, const String& message, c
onst String& defaultValue) | 843 String LocalDOMWindow::prompt(ScriptState* scriptState, const String& message, c
onst String& defaultValue) |
844 { | 844 { |
845 if (!frame()) | 845 if (!frame()) |
846 return String(); | 846 return String(); |
847 | 847 |
848 if (frame()->document()->isSandboxed(SandboxModals)) { | 848 if (frame()->document()->isSandboxed(SandboxModals)) { |
849 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); | 849 UseCounter::count(frame()->document(), UseCounter::DialogInSandboxedCont
ext); |
850 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { | 850 if (RuntimeEnabledFeatures::sandboxBlocksModalsEnabled()) { |
851 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'prompt()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); | 851 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'prompt()'. The document is sandboxed,
and the 'allow-modals' keyword is not set.")); |
852 return String(); | 852 return String(); |
853 } | 853 } |
854 } | 854 } |
855 | 855 |
856 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { | 856 if (v8::MicrotasksScope::IsRunningMicrotasks(scriptState->isolate())) { |
857 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Prompt); | 857 Deprecation::countDeprecation(frame()->document(), UseCounter::During_Mi
crotask_Prompt); |
858 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { | 858 if (RuntimeEnabledFeatures::disableBlockingMethodsDuringMicrotasksEnable
d()) { |
859 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'prompt()' during microtask execution."
)); | 859 frameConsole()->addMessage(ConsoleMessage::create(SecurityMessageSou
rce, ErrorMessageLevel, "Ignored call to 'prompt()' during microtask execution."
)); |
860 return String(); | 860 return String(); |
861 } | 861 } |
862 } | 862 } |
863 | 863 |
864 frame()->document()->updateLayoutTree(); | 864 frame()->document()->updateStyleAndLayoutTree(); |
865 | 865 |
866 FrameHost* host = frame()->host(); | 866 FrameHost* host = frame()->host(); |
867 if (!host) | 867 if (!host) |
868 return String(); | 868 return String(); |
869 | 869 |
870 String returnValue; | 870 String returnValue; |
871 if (host->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue
, returnValue)) | 871 if (host->chromeClient().openJavaScriptPrompt(frame(), message, defaultValue
, returnValue)) |
872 return returnValue; | 872 return returnValue; |
873 | 873 |
874 return String(); | 874 return String(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 | 925 |
926 FrameHost* host = frame->host(); | 926 FrameHost* host = frame->host(); |
927 if (!host) | 927 if (!host) |
928 return FloatSize(); | 928 return FloatSize(); |
929 | 929 |
930 // The main frame's viewport size depends on the page scale. Since the | 930 // The main frame's viewport size depends on the page scale. Since the |
931 // initial page scale depends on the content width and is set after a | 931 // initial page scale depends on the content width and is set after a |
932 // layout, perform one now so queries during page load will use the up to | 932 // layout, perform one now so queries during page load will use the up to |
933 // date viewport. | 933 // date viewport. |
934 if (host->settings().viewportEnabled() && frame->isMainFrame()) | 934 if (host->settings().viewportEnabled() && frame->isMainFrame()) |
935 frame->document()->updateLayoutIgnorePendingStylesheets(); | 935 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
936 | 936 |
937 // FIXME: This is potentially too much work. We really only need to know the
dimensions of the parent frame's layoutObject. | 937 // FIXME: This is potentially too much work. We really only need to know the
dimensions of the parent frame's layoutObject. |
938 if (Frame* parent = frame->tree().parent()) { | 938 if (Frame* parent = frame->tree().parent()) { |
939 if (parent && parent->isLocalFrame()) | 939 if (parent && parent->isLocalFrame()) |
940 toLocalFrame(parent)->document()->updateLayoutIgnorePendingStyleshee
ts(); | 940 toLocalFrame(parent)->document()->updateStyleAndLayoutIgnorePendingS
tylesheets(); |
941 } | 941 } |
942 | 942 |
943 return frame->isMainFrame() && !host->settings().inertVisualViewport() | 943 return frame->isMainFrame() && !host->settings().inertVisualViewport() |
944 ? FloatSize(host->visualViewport().visibleRect().size()) | 944 ? FloatSize(host->visualViewport().visibleRect().size()) |
945 : FloatSize(view->visibleContentRect(IncludeScrollbars).size()); | 945 : FloatSize(view->visibleContentRect(IncludeScrollbars).size()); |
946 } | 946 } |
947 | 947 |
948 int LocalDOMWindow::innerHeight() const | 948 int LocalDOMWindow::innerHeight() const |
949 { | 949 { |
950 if (!frame()) | 950 if (!frame()) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 return 0; | 997 return 0; |
998 | 998 |
999 FrameView* view = frame()->view(); | 999 FrameView* view = frame()->view(); |
1000 if (!view) | 1000 if (!view) |
1001 return 0; | 1001 return 0; |
1002 | 1002 |
1003 FrameHost* host = frame()->host(); | 1003 FrameHost* host = frame()->host(); |
1004 if (!host) | 1004 if (!host) |
1005 return 0; | 1005 return 0; |
1006 | 1006 |
1007 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 1007 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1008 | 1008 |
1009 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); | 1009 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1010 double viewportX = viewport->scrollPositionDouble().x(); | 1010 double viewportX = viewport->scrollPositionDouble().x(); |
1011 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); | 1011 return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); |
1012 } | 1012 } |
1013 | 1013 |
1014 double LocalDOMWindow::scrollY() const | 1014 double LocalDOMWindow::scrollY() const |
1015 { | 1015 { |
1016 if (!frame()) | 1016 if (!frame()) |
1017 return 0; | 1017 return 0; |
1018 | 1018 |
1019 FrameView* view = frame()->view(); | 1019 FrameView* view = frame()->view(); |
1020 if (!view) | 1020 if (!view) |
1021 return 0; | 1021 return 0; |
1022 | 1022 |
1023 FrameHost* host = frame()->host(); | 1023 FrameHost* host = frame()->host(); |
1024 if (!host) | 1024 if (!host) |
1025 return 0; | 1025 return 0; |
1026 | 1026 |
1027 frame()->document()->updateLayoutIgnorePendingStylesheets(); | 1027 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1028 | 1028 |
1029 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); | 1029 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1030 double viewportY = viewport->scrollPositionDouble().y(); | 1030 double viewportY = viewport->scrollPositionDouble().y(); |
1031 return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); | 1031 return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); |
1032 } | 1032 } |
1033 | 1033 |
1034 const AtomicString& LocalDOMWindow::name() const | 1034 const AtomicString& LocalDOMWindow::name() const |
1035 { | 1035 { |
1036 if (!isCurrentlyDisplayedInFrame()) | 1036 if (!isCurrentlyDisplayedInFrame()) |
1037 return nullAtom; | 1037 return nullAtom; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 if (!isCurrentlyDisplayedInFrame()) | 1105 if (!isCurrentlyDisplayedInFrame()) |
1106 return nullptr; | 1106 return nullptr; |
1107 | 1107 |
1108 unsigned colonStart = pseudoElement[0] == ':' ? (pseudoElement[1] == ':' ? 2
: 1) : 0; | 1108 unsigned colonStart = pseudoElement[0] == ':' ? (pseudoElement[1] == ':' ? 2
: 1) : 0; |
1109 CSSSelector::PseudoType pseudoType = CSSSelector::parsePseudoType(AtomicStri
ng(pseudoElement.substring(colonStart)), false); | 1109 CSSSelector::PseudoType pseudoType = CSSSelector::parsePseudoType(AtomicStri
ng(pseudoElement.substring(colonStart)), false); |
1110 if (pseudoType == CSSSelector::PseudoUnknown && !pseudoElement.isEmpty()) | 1110 if (pseudoType == CSSSelector::PseudoUnknown && !pseudoElement.isEmpty()) |
1111 return nullptr; | 1111 return nullptr; |
1112 | 1112 |
1113 unsigned rulesToInclude = StyleResolver::AuthorCSSRules; | 1113 unsigned rulesToInclude = StyleResolver::AuthorCSSRules; |
1114 PseudoId pseudoId = CSSSelector::pseudoId(pseudoType); | 1114 PseudoId pseudoId = CSSSelector::pseudoId(pseudoType); |
1115 element->document().updateLayoutTree(); | 1115 element->document().updateStyleAndLayoutTree(); |
1116 return frame()->document()->ensureStyleResolver().pseudoCSSRulesForElement(e
lement, pseudoId, rulesToInclude); | 1116 return frame()->document()->ensureStyleResolver().pseudoCSSRulesForElement(e
lement, pseudoId, rulesToInclude); |
1117 } | 1117 } |
1118 | 1118 |
1119 double LocalDOMWindow::devicePixelRatio() const | 1119 double LocalDOMWindow::devicePixelRatio() const |
1120 { | 1120 { |
1121 if (!frame()) | 1121 if (!frame()) |
1122 return 0.0; | 1122 return 0.0; |
1123 | 1123 |
1124 return frame()->devicePixelRatio(); | 1124 return frame()->devicePixelRatio(); |
1125 } | 1125 } |
1126 | 1126 |
1127 void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior)
const | 1127 void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior)
const |
1128 { | 1128 { |
1129 if (!isCurrentlyDisplayedInFrame()) | 1129 if (!isCurrentlyDisplayedInFrame()) |
1130 return; | 1130 return; |
1131 | 1131 |
1132 document()->updateLayoutIgnorePendingStylesheets(); | 1132 document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1133 | 1133 |
1134 FrameView* view = frame()->view(); | 1134 FrameView* view = frame()->view(); |
1135 if (!view) | 1135 if (!view) |
1136 return; | 1136 return; |
1137 | 1137 |
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); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 FrameHost* host = frame()->host(); | 1175 FrameHost* host = frame()->host(); |
1176 if (!host) | 1176 if (!host) |
1177 return; | 1177 return; |
1178 | 1178 |
1179 x = ScrollableArea::normalizeNonFiniteScroll(x); | 1179 x = ScrollableArea::normalizeNonFiniteScroll(x); |
1180 y = ScrollableArea::normalizeNonFiniteScroll(y); | 1180 y = ScrollableArea::normalizeNonFiniteScroll(y); |
1181 | 1181 |
1182 // It is only necessary to have an up-to-date layout if the position may be
clamped, | 1182 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
1183 // which is never the case for (0, 0). | 1183 // which is never the case for (0, 0). |
1184 if (x || y) | 1184 if (x || y) |
1185 document()->updateLayoutIgnorePendingStylesheets(); | 1185 document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1186 | 1186 |
1187 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); | 1187 DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFa
ctor()); |
1188 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); | 1188 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1189 viewport->setScrollPosition(layoutPos, ProgrammaticScroll, ScrollBehaviorAut
o); | 1189 viewport->setScrollPosition(layoutPos, ProgrammaticScroll, ScrollBehaviorAut
o); |
1190 } | 1190 } |
1191 | 1191 |
1192 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const | 1192 void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const |
1193 { | 1193 { |
1194 if (!isCurrentlyDisplayedInFrame()) | 1194 if (!isCurrentlyDisplayedInFrame()) |
1195 return; | 1195 return; |
1196 | 1196 |
1197 FrameView* view = frame()->view(); | 1197 FrameView* view = frame()->view(); |
1198 if (!view) | 1198 if (!view) |
1199 return; | 1199 return; |
1200 | 1200 |
1201 FrameHost* host = frame()->host(); | 1201 FrameHost* host = frame()->host(); |
1202 if (!host) | 1202 if (!host) |
1203 return; | 1203 return; |
1204 | 1204 |
1205 // It is only necessary to have an up-to-date layout if the position may be
clamped, | 1205 // It is only necessary to have an up-to-date layout if the position may be
clamped, |
1206 // which is never the case for (0, 0). | 1206 // which is never the case for (0, 0). |
1207 if (!scrollToOptions.hasLeft() | 1207 if (!scrollToOptions.hasLeft() |
1208 || !scrollToOptions.hasTop() | 1208 || !scrollToOptions.hasTop() |
1209 || scrollToOptions.left() | 1209 || scrollToOptions.left() |
1210 || scrollToOptions.top()) { | 1210 || scrollToOptions.top()) { |
1211 document()->updateLayoutIgnorePendingStylesheets(); | 1211 document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1212 } | 1212 } |
1213 | 1213 |
1214 double scaledX = 0.0; | 1214 double scaledX = 0.0; |
1215 double scaledY = 0.0; | 1215 double scaledY = 0.0; |
1216 | 1216 |
1217 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); | 1217 ScrollableArea* viewport = host->settings().inertVisualViewport() ? view->la
youtViewportScrollableArea() : view->getScrollableArea(); |
1218 | 1218 |
1219 DoublePoint currentOffset = viewport->scrollPositionDouble(); | 1219 DoublePoint currentOffset = viewport->scrollPositionDouble(); |
1220 scaledX = currentOffset.x(); | 1220 scaledX = currentOffset.x(); |
1221 scaledY = currentOffset.y(); | 1221 scaledY = currentOffset.y(); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 { | 1535 { |
1536 // If the LocalDOMWindow still has a frame reference, that frame must point | 1536 // If the LocalDOMWindow still has a frame reference, that frame must point |
1537 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | 1537 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation |
1538 // where script execution leaks between different LocalDOMWindows. | 1538 // where script execution leaks between different LocalDOMWindows. |
1539 if (m_frameObserver->frame()) | 1539 if (m_frameObserver->frame()) |
1540 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); | 1540 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() =
= this); |
1541 return m_frameObserver->frame(); | 1541 return m_frameObserver->frame(); |
1542 } | 1542 } |
1543 | 1543 |
1544 } // namespace blink | 1544 } // namespace blink |
OLD | NEW |