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