Skip to content

Implement Element.client{Top,Left,Width,Height} #1713

Closed

Description

@jdm

http://dev.w3.org/csswg/cssom-view/#extensions-to-the-element-interface

Looking into the scrollTop and scrollLeft getters could be fun as well. Not sure what work would be involved with the setters, though.

Activity

  1. lpy commented on Feb 20, 2014

    @lpy
    Contributor

    I will work on this one.

  2. lpy commented on Mar 9, 2014

    @lpy
    Contributor

    I have a question about the get_css_select_results.

    The get_css_select_results I implement in Node

        #[inline]
        pub fn get_css_select_results(&self) -> Arc<ComputedValues> {
            unsafe {
                let layout_data_ref = self.layout_data.data_cell.borrow();
                let shared_style_ref: *SharedLayoutData = cast::transmute(&layout_data_ref.get().get_ref().data);
                (*shared_style_ref).style.as_ref().unwrap().clone()
            }
        }
    

    The SharedLayoutData I implement in style.

    use extra::arc::Arc;
    use properties::ComputedValues;
    pub struct SharedLayoutData {
        /// The results of CSS styling for this node.
        style: Option<Arc<ComputedValues>>,
    }
    impl SharedLayoutData {
        pub fn new() -> SharedLayoutData {
            SharedLayoutData {
                style: None,
            }
        }
    }
    

    Then I change the style in PrivateLayoutData to shared_style: SharedLayoutData

    The problem is that the get_ref() in get_css_select_results will return None.

    The test code is

    <html>
      <div id="div" style="width:100px; height:100px; padding:10px; border:5px solid;"></div>
      <script>
        var div = document.getElementById("div");
        alert(div);
        alert(div.clientTop);
      </script>
    </html>

    I am still trying to figure it out. Any idea? Thank you.
    Please see my patch here

  3. lpy commented on Mar 9, 2014

    @lpy
    Contributor

    By the way, I did have one time that the code work.

  4. lpy commented on Mar 9, 2014

    @lpy
    Contributor

    Also, the alert(div.style) returns undefined.

  5. jdm commented on Mar 9, 2014

    @jdm
    MemberAuthor

    The problem is that the script code is racing with layout, which may not have finished yet. At minimum you'll need to call Node::wait_until_safe_to_modify_dom, which will block until any pending layout operations are complete.

  6. jdm commented on Mar 9, 2014

    @jdm
    MemberAuthor

    The unimplemented style property is tracked in #1721.

  7. lpy commented on Mar 9, 2014

    @lpy
    Contributor

    It didn't work to me.

  8. lpy commented on Mar 9, 2014

    @lpy
    Contributor

    Error message:

    task 'ScriptTask' failed at 'called `Option::unwrap()` on a `None` value', /Users/lpy/moz/servo/src/compiler/rust/src/libstd/option.rs:133
    failed at 'assertion failed: self.live_allocs.is_null()', /Users/lpy/moz/servo/src/compiler/rust/src/libstd/rt/local_heap.rs:135
    [1]    83669 illegal hardware instruction  ./servo ../../test.html
    
  9. lpy commented on Mar 9, 2014

    @lpy
    Contributor

    I called wait_until_safe_to_modify_dom before the unsafe block in get_css_select_results.

  10. jdm commented on Mar 9, 2014

    @jdm
    MemberAuthor

    Can you push your code to a branch?

  11. lpy commented on Mar 11, 2014

    @lpy
    Contributor

    @pcwalton @metajack @kmcallister Hi! Do you know how to extract the layout information from the layout task in the script? The query_layout can't return the things I want. I want display, content, border, padding, etc.

  12. jdm commented on Mar 11, 2014

    @jdm
    MemberAuthor

    @lpy You can create a new message to send via query_layout and calculate whatever you need. You don't have to rely on existing message types.

  13. jdm commented on Apr 1, 2014

    @jdm
    MemberAuthor

    Are you still working on this, @lpy?

  14. removed
    A-content/dom
    on Oct 23, 2014
  15. removed
    C-assigned
    on Dec 17, 2014
  16. added
    C-is-this-done
    on Jul 28, 2015
  17. frewsxcv commented on Jul 28, 2015

    @frewsxcv
    Contributor

    Was this completed in #6797?

    /cc @glennw

  18. added
    A-content/dom
    on Jul 28, 2015
  19. jdm commented on Jul 28, 2015

    @jdm
    MemberAuthor

    Yep!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/domC-is-this-done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions