[LFC] Formatting contexts should take const Box&
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Apr 2018 14:40:24 +0000 (14:40 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Apr 2018 14:40:24 +0000 (14:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185031

Reviewed by Sam Weinig.

The formatting root boxes are supposed to be all const. The only reason why
they are not is because WeakPtr<> does not support const objects yet.
Use const_cast instead (remove it when WeakPtr<> gains const support).

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::FormattingContext):
* layout/FormattingContext.h:
* layout/LayoutContext.cpp:
(WebCore::Layout::LayoutContext::LayoutContext):
(WebCore::Layout::LayoutContext::formattingContext):
* layout/LayoutContext.h:
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::BlockFormattingContext):
* layout/blockformatting/BlockFormattingContext.h:
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::InlineFormattingContext):
* layout/inlineformatting/InlineFormattingContext.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231094 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.cpp
Source/WebCore/layout/FormattingContext.h
Source/WebCore/layout/LayoutContext.cpp
Source/WebCore/layout/LayoutContext.h
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.h
Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
Source/WebCore/layout/inlineformatting/InlineFormattingContext.h

index 1b34fdd..803047a 100644 (file)
@@ -1,5 +1,30 @@
 2018-04-27  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC] Formatting contexts should take const Box&
+        https://bugs.webkit.org/show_bug.cgi?id=185031
+
+        Reviewed by Sam Weinig.
+
+        The formatting root boxes are supposed to be all const. The only reason why
+        they are not is because WeakPtr<> does not support const objects yet.
+        Use const_cast instead (remove it when WeakPtr<> gains const support).
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::FormattingContext):
+        * layout/FormattingContext.h:
+        * layout/LayoutContext.cpp:
+        (WebCore::Layout::LayoutContext::LayoutContext):
+        (WebCore::Layout::LayoutContext::formattingContext):
+        * layout/LayoutContext.h:
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::BlockFormattingContext):
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::InlineFormattingContext):
+        * layout/inlineformatting/InlineFormattingContext.h:
+
+2018-04-27  Zalan Bujtas  <zalan@apple.com>
+
         [LFC] Add layout tree iterators.
         https://bugs.webkit.org/show_bug.cgi?id=185058
 
index 9855bad..87ef299 100644 (file)
@@ -35,8 +35,8 @@ namespace Layout {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingContext);
 
-FormattingContext::FormattingContext(Box& formattingContextRoot)
-    : m_root(makeWeakPtr(formattingContextRoot))
+FormattingContext::FormattingContext(const Box& formattingContextRoot)
+    : m_root(makeWeakPtr(const_cast<Box&>(formattingContextRoot)))
 {
 }
 
index e86cff9..38c5a4a 100644 (file)
@@ -41,7 +41,7 @@ class Box;
 class FormattingContext {
     WTF_MAKE_ISO_ALLOCATED(FormattingContext);
 public:
-    FormattingContext(Box& formattingContextRoot);
+    FormattingContext(const Box& formattingContextRoot);
     virtual ~FormattingContext();
 
     virtual void layout(FormattingState&) = 0;
index 938dd2b..2e363a4 100644 (file)
@@ -40,8 +40,8 @@ namespace Layout {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutContext);
 
-LayoutContext::LayoutContext(Box& root)
-    : m_root(makeWeakPtr(root))
+LayoutContext::LayoutContext(const Box& root)
+    : m_root(makeWeakPtr(const_cast<Box&>(root)))
 {
 }
 
@@ -59,7 +59,7 @@ FormattingState& LayoutContext::formattingState(const FormattingContext& context
     }).iterator->value;
 }
 
-std::unique_ptr<FormattingContext> LayoutContext::formattingContext(Box& formattingContextRoot)
+std::unique_ptr<FormattingContext> LayoutContext::formattingContext(const Box& formattingContextRoot)
 {
     if (formattingContextRoot.establishesBlockFormattingContext())
         return std::make_unique<BlockFormattingContext>(formattingContextRoot);
index 15007d6..838b527 100644 (file)
@@ -50,7 +50,7 @@ class StyleDiff;
 class LayoutContext {
     WTF_MAKE_ISO_ALLOCATED(LayoutContext);
 public:
-    LayoutContext(Box& root);
+    LayoutContext(const Box& root);
 
     void updateLayout();
 
@@ -62,7 +62,7 @@ public:
 
 private:
     FormattingState& formattingState(const FormattingContext&);
-    std::unique_ptr<FormattingContext> formattingContext(Box& formattingContextRoot);
+    std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot);
 
     WeakPtr<Box> m_root;
     HashMap<const Box*, std::unique_ptr<FormattingState>> m_formattingStates;
index d37e181..70f7739 100644 (file)
@@ -36,7 +36,7 @@ namespace Layout {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(BlockFormattingContext);
 
-BlockFormattingContext::BlockFormattingContext(Box& formattingContextRoot)
+BlockFormattingContext::BlockFormattingContext(const Box& formattingContextRoot)
     : FormattingContext(formattingContextRoot)
 {
 }
index f12e7e7..b45940e 100644 (file)
@@ -43,7 +43,7 @@ class Box;
 class BlockFormattingContext : public FormattingContext {
     WTF_MAKE_ISO_ALLOCATED(BlockFormattingContext);
 public:
-    BlockFormattingContext(Box& formattingContextRoot);
+    BlockFormattingContext(const Box& formattingContextRoot);
 
     void layout(FormattingState&) override;
     std::unique_ptr<FormattingState> formattingState() const override;
index 7d1b764..db7008a 100644 (file)
@@ -36,7 +36,7 @@ namespace Layout {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingContext);
 
-InlineFormattingContext::InlineFormattingContext(Box& formattingContextRoot)
+InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoot)
     : FormattingContext(formattingContextRoot)
 {
 }
index 6026060..6686e9b 100644 (file)
@@ -41,7 +41,7 @@ class InlineFormattingState;
 class InlineFormattingContext : public FormattingContext {
     WTF_MAKE_ISO_ALLOCATED(InlineFormattingContext);
 public:
-    InlineFormattingContext(Box& formattingContextRoot);
+    InlineFormattingContext(const Box& formattingContextRoot);
 
     void layout(FormattingState&) override;
     std::unique_ptr<FormattingState> formattingState() const override;